esphome-docs/components/sensor/hlw8012.rst

68 lines
2.8 KiB
ReStructuredText
Raw Normal View History

2018-08-24 22:44:01 +02:00
HLW8012 Power Sensor
====================
2018-11-14 22:12:27 +01:00
.. seo::
:description: Instructions for setting up HLW8012 power sensors for the Sonoff Pow R1
:image: hlw8012.png
2018-11-14 22:12:27 +01:00
:keywords: HLW8012, Sonoff Pow R1
2018-08-24 22:44:01 +02:00
The ``hlw8012`` sensor platform allows you to use your HLW8012 voltage/current and power sensors
(`datasheet <https://github.com/xoseperez/hlw8012/blob/master/docs/HLW8012.pdf>`__) sensors with
2019-02-16 23:25:23 +01:00
ESPHome. This sensor is commonly found in Sonoff POWs.
2018-08-24 22:44:01 +02:00
This sensor has two data outputs which both encode values using the frequency of a modulated signal: CF and CF1.
CF's frequency is proportional to the (active) power measured and CF1 is proportional to the current/voltage. Using
the SEL pin, one can choose between which mode to use.
2019-02-16 23:25:23 +01:00
ESPHome will continuously cycle the state of the SEL pin to measure current *and* voltage, though both cannot
2018-08-24 22:44:01 +02:00
be measured at the same exact points in time.
.. code-block:: yaml
2018-08-24 22:44:01 +02:00
# Example configuration entry
sensor:
- platform: hlw8012
sel_pin: 5
cf_pin: 14
cf1_pin: 13
current:
name: "HLW8012 Current"
voltage:
name: "HLW8012 Voltage"
power:
name: "HLW8012 Power"
2019-01-06 18:56:14 +01:00
update_interval: 60s
2018-08-24 22:44:01 +02:00
.. note::
The configuration above should work for Sonoff POWs (R1).
Configuration variables:
------------------------
- **sel_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The pin SEL is connected to.
- **cf_pin** (**Required**, :ref:`config-pin`): The pin CF is connected to.
- **cf1_pin** (**Required**, :ref:`config-pin`): The pin CF1 is connected to.
- **current** (*Optional*): Use the current value of the sensor in amperes. All options from
2019-02-17 12:28:17 +01:00
:ref:`Sensor <config-sensor>`.
2018-08-24 22:44:01 +02:00
- **power** (*Optional*): Use the (active) power value of the sensor in watts. All options from
2019-02-17 12:28:17 +01:00
:ref:`Sensor <config-sensor>`.
2018-08-24 22:44:01 +02:00
- **voltage** (*Optional*): Use the voltage value of the sensor in V (RMS).
2019-02-17 12:28:17 +01:00
All options from :ref:`Sensor <config-sensor>`.
2018-08-24 22:44:01 +02:00
- **current_resistor** (*Optional*, float): The value of the shunt resistor for current measurement.
Defaults to the Sonoff POW's value ``0.001 ohm``.
- **voltage_divider** (*Optional*, float): The value of the voltage divider on the board as ``(R_upstream + R_downstream) / R_downstream``.
Defaults to the Sonoff POW's value ``2351``.
- **change_mode_every** (*Optional*, int): After how many updates to cycle between the current/voltage measurement mode.
Note that the first value after switching is discarded because it is often inaccurate. Defaults to ``8``.
2019-01-06 18:56:14 +01:00
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the sensor. Defaults to ``60s``.
2018-08-24 22:44:01 +02:00
See Also
--------
- :ref:`sensor-filters`
- :apiref:`sensor/hlw8012.h`
2018-08-24 22:44:01 +02:00
- `HLW8012 Library <https://github.com/xoseperez/hlw8012>`__ by `Xose Pérez <https://github.com/xoseperez>`__
- :ghedit:`Edit`