CSE7761 Power Sensor
The cse7761 sensor platform allows you to use your CSE7761 voltage/current and power sensors
with ESPHome. This sensor is commonly found in the Sonoff Dual R3 v1.x and the Sonoff POW CT.
NOTE
SAFETY HAZARD: Some devices such as Sonoff POWs/Shelly/etc, have the digital GND connected directly to mains voltage so the GPIOs become LIVE during normal operation. Our advice is to mark these boards to prevent any use of the dangerous digital pins.
As the communication with the CSE7761 done using UART, you need
to have an UART bus in your configuration with the tx_pin and rx_pin connected to the CSE7761.
Additionally, you need to set the baud rate to 38400 and parity to EVEN.
# Example configuration entrysensor: - platform: cse7761 voltage: name: 'CSE7761 Voltage' current_1: name: 'CSE7761 Current 1' current_2: name: 'CSE7761 Current 2' active_power_1: name: 'CSE7761 Active Power 1' active_power_2: name: 'CSE7761 Active Power 2' energy_1: name: 'CSE7761 Energy 1' energy_2: name: 'CSE7761 Energy 2' frequency: name: 'CSE7761 Frequency' power_factor_1: name: 'CSE7761 Power Factor 1'NOTE
The configuration above should work for Sonoff Dual R3 v1.x. The Sonoff POW CT measures a single circuit with
a current transformer, so add current_input: current_transformer and use only the channel 1 sensors.
Configuration variables
Section titled “Configuration variables”-
current_input (Optional, string): How the board feeds current into the chip.
shuntfor boards with shunt resistors such as the Sonoff Dual R3, orcurrent_transformerfor boards with a current transformer such as the Sonoff POW CT. Defaults toshunt. The chip reports no load below about 10 mA with a shunt and below about 50 mA with a current transformer. -
voltage (Optional): Use the voltage value of the sensor in V (RMS). All options from Sensor.
-
current_1 (Optional): Use the current value of the channel 1 in amperes. All options from Sensor.
-
current_2 (Optional): Use the current value of the channel 2 in amperes. All options from Sensor.
-
active_power_1 (Optional): Use the (active) power value of the channel 1 in watts. All options from Sensor.
-
active_power_2 (Optional): Use the (active) power value of the channel 2 in watts. All options from Sensor.
-
energy_1 (Optional): Use the active energy counted by channel 1 in watt-hours. All options from Sensor.
-
energy_2 (Optional): Use the active energy counted by channel 2 in watt-hours. All options from Sensor.
-
frequency (Optional): Use the mains frequency in Hz. All options from Sensor.
-
power_factor_1 (Optional): Use the power factor of channel 1. The chip reports it for channel 1 only. All options from Sensor.
-
update_interval (Optional, Time): The interval to check the sensor. Defaults to
60s. -
uart_id (Optional, ID): Manually specify the ID of the UART Component if you want to use multiple UART buses.
The energy values come from the chip’s pulse counters and start from zero again after a reboot. Home Assistant’s
energy dashboard handles that reset because the sensors use total_increasing; for a daily total that survives
reboots, feed active_power_1 or active_power_2 into the Total Daily Energy
sensor.
Power Direction
Section titled “Power Direction”Active power is signed, so it shows which way power flows: a load reads positive and power fed back, for example from a solar inverter, reads negative. On the Sonoff Dual R3 v1.x the board wires the current into the chip the other way round, so normal loads read as negative watts. Flip the sign with a filter on each power sensor:
sensor: - platform: cse7761 active_power_1: name: 'CSE7761 Active Power 1' filters: - multiply: -1 active_power_2: name: 'CSE7761 Active Power 2' filters: - multiply: -1If a channel only ever powers loads, - lambda: return fabsf(x); also works, but it hides the direction.
On a board with a clip-on current transformer, such as the Sonoff POW CT, turn the clamp around instead.