CSE7766 with ESPHome: UART Power Monitoring for Sonoff POW R2

Configure the CSE7766 meter in a Sonoff POW R2 with ESPHome: verified UART settings, live AC measurements, daily kWh and Home Assistant setup, with essential mains-safety guidance.

The CSE7766 is a single-phase AC energy-monitoring IC used in the original Sonoff POW R2 and some other smart-power devices. ESPHome reads its measurements over a receive-only UART and exposes voltage, current, active power, apparent power, reactive power, power factor and accumulated energy to Home Assistant. This guide focuses on identifying compatible hardware, configuring a POW R2 already running ESPHome, and building reliable energy statistics rather than treating every device labelled “Sonoff POW” as electrically identical.

If you followed our BL0942 smart-plug guide, the overall workflow is familiar, but the serial settings and supported registers differ. The CSE7766 communicates at 4,800 baud with even parity; copying a BL0942 configuration will not work. The ESPHome CSE7766 component documentation and the ESPHome POW R2 device profile provide the hardware-specific reference for the example below.

Electrical safety comes before firmware

WARNING — MAINS VOLTAGE: A Sonoff POW R2 can have its digital ground and GPIOs at mains potential during normal operation. A 3.3 V logic label does not mean a safe, isolated reference. Never connect a USB programmer, oscilloscope ground, laptop, logic analyser or external ESP32 development board to an energised mains-connected POW R2. Do not use open-board mains wiring as a beginner project.

Keep the product closed and use its certified enclosure and rated terminals during normal operation. Any mains wiring, mounting, circuit protection or initial firmware service must be performed with the device isolated from power and by a person qualified to work on that installation. Verify the unit is de-energised using an appropriate procedure before any enclosure access; simply turning its relay off is not electrical isolation. When in doubt, choose a finished, safely enclosed metering device that supports local integration without opening it.

The code below is a configuration example for the identified ESP8266-based POW R2 hardware, not a generic pinout for newer POW variants or a recipe for attaching an unidentified meter IC to a loose ESP32 board. If your device is a POW R3, POW Elite, Dual R3, a different hardware revision or a clone, establish its actual microcontroller and metering chip first. Wrong relay pins can energise a load unexpectedly.

Identify the right hardware and component

The label on the enclosure identifies the product family, not necessarily the metering IC inside. Original POW R2 hardware is documented with an ESP8266 and CSE7766. ESPHome also lists the similar CSE7759B as supported by this component; that should not be confused with the differently interfaced CSE7759 used with other integrations. Check the actual model and revision against a device-specific profile, schematic or reliable teardown completed under safe conditions.

Hardware or chipESPHome approachWhy it matters
Sonoff POW R2, known ESP8266/CSE7766 revisioncse7766 over receive-only UARTThe reference implementation used throughout this guide.
CSE7759B compatible designcse7766 where verified by the manufacturer or ESPHome documentationThe similarly named CSE7759 is not interchangeable.
Sonoff Dual R3 v1.x with CSE7761cse7761 on its documented UARTDifferent IC, serial rate and two current channels.
BL0942-based smart plugbl0942Different protocol; refer to the separate BL0942 guide.
Newer or unidentified Sonoff POW modelIdentify its chip and MCU firstDo not assume the original POW R2 pin mapping applies.

CSE7766 returns RMS voltage in volts, RMS current in amperes, active power in watts and an energy counter in watt-hours. It may also report apparent power (VA), reactive power (var) and power factor. Active and apparent power are related but are not synonyms: a motor or power supply can draw a current that does not correspond to a purely resistive load.

UART wiring and the Sonoff POW R2 pin mapping

The CSE7766 transmits measurement frames to the ESP8266. For the documented POW R2 design, the receive connection is the ESP8266 hardware UART RX pin, exposed in ESPHome as RX. ESPHome uses 4800 baud and EVEN parity. You do not need to declare a transmit pin merely to receive meter frames. The device already has its internal metering connections: do not solder new UART wiring onto a powered board.

POW R2 functionDocumented ESP8266 assignmentESPHome use
Meter data into MCUUART RX / GPIO3uart: rx_pin: RX
Local push buttonGPIO0, active-lowGPIO binary sensor with pull-up and inversion
Power relayGPIO12GPIO switch; start with safe restore state
Blue status LEDGPIO13, active-lowOptional status LED
Serial logger on the metering UARTConflicts with receive pathlogger: baud_rate: 0

On an ordinary ESP32 development board, UART RX can be assigned to an appropriate available GPIO, but that does not make the meter’s mains-referenced serial connection electrically safe. A direct connection between a loose, USB-powered ESP32 and an unidentified mains metering module must not be inferred from the POW R2’s internal design.

For an installed POW R2, use the product’s existing mains-rated terminals and follow its power, current, ambient-temperature and circuit-protection ratings. Do not treat the IC’s measurement range as the permissible rating of the complete relay, connector or enclosure.

Complete ESPHome configuration for a documented POW R2

This example assumes an original ESP8266 POW R2 with ESPHome already installed. It includes the documented relay and button assignments plus the CSE7766 measurement channels. Keep the relay default OFF while validating your setup; changing its restore policy is a separate decision about what the connected appliance should do after a power outage. Copy the complete file into a named ESPHome YAML device and supply the Wi-Fi credentials via your normal secrets file.

substitutions:
  device_name: sonoff-pow-r2-meter
  publish_interval: 60s
esphome:
  name: ${device_name}
  friendly_name: Sonoff POW R2 Meter
esp8266:
  board: esp01_1m
logger:
  # Hardware serial is used to receive CSE7766 frames.
  baud_rate: 0
api:
ota:
  - platform: esphome
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
uart:
  id: meter_uart
  rx_pin: RX
  baud_rate: 4800
  parity: EVEN
switch:
  - platform: gpio
    id: pow_relay
    name: "POW R2 Relay"
    pin: GPIO12
    restore_mode: ALWAYS_OFF
binary_sensor:
  - platform: gpio
    name: "POW R2 Button"
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
    on_press:
      - switch.toggle: pow_relay
status_led:
  pin:
    number: GPIO13
    inverted: true
sensor:
  - platform: cse7766
    uart_id: meter_uart
    voltage:
      name: "POW R2 Voltage"
      filters:
        - throttle_average: ${publish_interval}
    current:
      name: "POW R2 Current"
      filters:
        - throttle_average: ${publish_interval}
    power:
      id: pow_active_power
      name: "POW R2 Active Power"
      filters:
        - throttle_average: ${publish_interval}
    energy:
      name: "POW R2 Meter Energy"
      filters:
        - throttle: ${publish_interval}
    apparent_power:
      name: "POW R2 Apparent Power"
      filters:
        - throttle_average: ${publish_interval}
    reactive_power:
      name: "POW R2 Reactive Power"
      filters:
        - throttle_average: ${publish_interval}
    power_factor:
      name: "POW R2 Power Factor"
      filters:
        - throttle_average: ${publish_interval}
time:
  - platform: homeassistant
    id: ha_time
  # See the next section for an optional daily-energy sensor.

The logger: baud_rate: 0 line disables serial logging so that hardware UART traffic is not shared with debug output; Wi-Fi/API logs remain available when the device is connected. The uart_id is optional for a single UART but makes the selected bus explicit. ESPHome’s official example uses a 60-second average because the chip emits multiple updates per second, whereas Home Assistant does not need that many state changes for a room-level consumption dashboard.

The above esp01_1m, relay, button and status-LED assignments are specific to the documented POW R2 device profile. They are deliberately not presented as universal settings for a standalone ESP32 or a different commercial plug. The button automation toggles a mains relay: remove that automation if local button control is inappropriate for the connected load. For a safety-critical appliance, neither a smart relay nor an ESPHome automation replaces independent protection.

Which measurements should you use?

EntityUnitTypical purpose
VoltageV RMSSpotting large supply variations; not a certified power-quality measurement.
CurrentA RMSIdentifying idle current, appliance operation and unusual consumption.
Active powerWThe instantaneous real electrical consumption used to calculate energy.
Apparent powerVAVoltage × current; useful when the load is not purely resistive.
Reactive powervarPhase-related component of alternating-current power.
Power factorUnitlessActive power divided by apparent power when values are valid.
Meter energyWhAccumulated measurement reported by the metering component; verify reset behaviour.

For example, a resistive 100 W load operating steadily for two hours consumes approximately 200 Wh, or 0.2 kWh. A 100 W reading is power now; a 0.2 kWh reading is energy over time. Home Assistant’s Energy dashboard expects a suitable energy sensor, not a power sensor presented under a different unit label.

Do not interpret an occasional low-load power-factor spike or reactive-power reading as proof of a faulty appliance. At very small currents, measurement noise and the meter’s limitations can dominate a derived ratio. For billing, protection or formal efficiency tests, use an appropriately certified instrument rather than consumer smart-plug telemetry.

Add a reliable daily kWh sensor

The raw CSE7766 energy output is in Wh. Before selecting it as a lifetime energy source, test what happens after a device reboot and an actual loss of supply: the value may not behave like a permanent household meter. An easier daily figure is to integrate the active-power reading with ESPHome’s total_daily_energy helper and a valid time source.

Add the following item within the existing top-level sensor: list of the previous YAML, after the cse7766 block. Do not create a second top-level sensor: key in the same YAML file.

- platform: total_daily_energy
    name: "POW R2 Daily Energy"
    power_id: pow_active_power
    method: trapezoid
    restore: true
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing
    accuracy_decimals: 3
    filters:
      # Integrating W gives Wh; divide by 1000 for kWh.
      - multiply: 0.001

The existing time: - platform: homeassistant block supplies the clock required to reset the daily total at midnight. If the device operates without a Home Assistant connection, select another documented time source, such as SNTP, rather than assuming a valid clock appears automatically. The restore: true option helps preserve the intermediate total over an ordinary reboot, but a short interruption can still create gaps if the appliance continues to draw power while the meter is offline.

Why use throttle_average on instantaneous power but only throttle on the raw accumulated energy? The former averages several changing measurements over an interval. The latter sends the latest running counter once per interval. Averaging successive total-counter values makes the reported total lag the actual count and can obscure reset behaviour. This distinction follows the ESPHome CSE7766 reference example.

For a persistent long-term total, either let Home Assistant accumulate the daily/increasing readings through its statistics pipeline or configure an appropriate energy integration and test its restore behaviour. ESPHome’s integration sensor can produce a running total, but frequent persistence to flash is a trade-off; the documentation explicitly cautions about flash wear when enabling restore. Avoid presenting an on-device counter that resets unexpectedly as a definitive lifetime total.

Set up the device in Home Assistant

Once firmware is running, open Settings → Devices & services in Home Assistant and add or adopt the ESPHome device. Verify that voltage, current, power and energy entities appear under one device and that the measurement units match the expected physical quantities. The native API uses the device’s network connection; you do not need MQTT just to display the readings.

Create a simple dashboard with the current active-power card, a one-day energy card, and a 24-hour power-history graph. For everyday diagnosis, place the relay state beside the power reading: a zero-watt measurement while the relay is OFF is normal, but an implausible zero when a known load is ON deserves investigation. When mapping an individual appliance to the Home Assistant Energy dashboard, select an eligible energy entity under the individual-device consumption section—not a power entity under the household grid meter.

If your energy sensor is missing from the selection list, check its attributes in Developer Tools → States and the statistical diagnostics in Developer Tools → Statistics. The Home Assistant energy FAQ specifies an energy device class, supported energy unit and appropriate total-state class. The sample daily sensor explicitly uses device_class: energy, state_class: total_increasing and kWh. A number with a “kWh” label alone is insufficient.

Avoid double-counting. If the same appliance is already included in a whole-house grid meter, its individual figure is a breakdown of that total, not an additional amount of electricity imported from the grid. Check consumption after a complete day and compare it with a trusted meter under a load profile that both instruments can measure.

Calibration and sanity checks

CSE7766 readings should be checked against an independent, suitable instrument before you rely on absolute figures. First observe the reported voltage at a normal operating point. Then use a stable, known load and compare watts and amps after the sensors have been publishing for several intervals. Real appliances with switched power supplies, motors or thermostatic control are poor calibration references because their power draw may change while you are watching.

With a mostly resistive load, voltage × current should be reasonably close to active power and the power factor should be near one. With a motor or electronic power supply, apparent power may be higher than active power. This is not necessarily a meter fault. A reading of 230 V × 0.5 A = 115 VA, for instance, could correspond to less than 115 W of real power when the power factor is below one.

If the device consistently under- or over-reports by a small factor, ESPHome supports calibrate_linear and multiplication filters on individual sensor outputs. Record MEASURED → REFERENCE calibration points at more than one load level. Never copy another user’s correction coefficient into your own device without checking it: resistor tolerances, revisions and wear differ. Correcting a display reading does not increase the device’s actual safe current rating.

# Illustration only: replace both reference pairs with YOUR readings.
# Under a CSE7766 "power:" sensor, ahead of throttle_average:
filters:
  - calibrate_linear:
      method: least_squares
      datapoints:
        - 0.0 -> 0.0
        - 97.0 -> 100.0
        - 485.0 -> 500.0
  - throttle_average: 60s

These power numbers are illustrative, not factory coefficients. If you calibrate only the instantaneous power entity, compare the raw meter energy counter and the computed daily energy afterward; different signal paths may no longer agree precisely. Calibration should be a measured correction, not a way to conceal intermittent UART faults.

Troubleshooting missing values and unstable readings

The device is online but voltage and power are unavailable

Confirm the meter really is a CSE7766/CSE7759B-compatible part and that you chose the correct device profile. Check rx_pin: RX, baud_rate: 4800, parity: EVEN and disabled hardware-serial logging. Incorrect parity or baud can leave the Wi-Fi and relay working while no valid metering frames reach ESPHome. Use wireless ESPHome logs to check for component or UART warnings; never attach a grounded serial monitor to a live board.

The readings are very noisy or Home Assistant shows too many updates

The IC sends several measurements per second. Use throttle_average: 60s for live values and throttle: 60s for its accumulated energy. Start with the official filtering pattern before adding more smoothing. Large averaging windows make dashboards calmer but also hide short bursts: if your purpose is to detect a brief motor start, design a separate verified fast telemetry path rather than expecting a one-minute average to preserve the peak.

Power looks correct but daily kWh is zero or incorrect

Check that pow_active_power is the ID of the actual W sensor and that the daily-energy component is a separate item inside the same sensor list. Check that Home Assistant time has synchronised, that the unit conversion of 0.001 was applied only once, and that you have observed the device over a meaningful interval. A small idle load may take time to show more than 0.000 kWh when displayed to three decimal places.

Energy jumps backward or the dashboard shows implausible consumption

Review the raw meter counter across reboots and after the device is disconnected from the mains. Do not combine a counter that may reset with a template that assumes its value is a permanent lifetime total without checking how Home Assistant interprets decreases. Inspect the entity’s long-term-statistics issues and preserve existing historical data before replacing an established entity with a differently calculated one. A reconnecting sensor can also make an unavailability value appear as zero if the template is written carelessly.

The relay works, but the power is always near zero

Verify with a known appropriate load and consider whether the metered circuit actually routes through the current measurement path in that hardware revision. Do not assume a relay command proves that the appliance is energised: the breaker, circuit, load, relay contact or metering path may be different. Investigate electrical faults only with suitable training, isolation and test equipment.

The device disappears from Wi-Fi or fails to recover after firmware changes

Treat network connectivity, firmware size and meter UART problems separately. Keep a backup of the known-good YAML, avoid enabling unnecessary web features on limited ESP8266 flash and RAM, and test one change at a time. If it is unreachable over the network, an over-the-air fix may not be possible; consult a professional for de-energised recovery, or replace the unit rather than improvising a live serial connection.

CSE7766 versus BL0942, CSE7761 and external CT meters

The CSE7766 is most useful when you already own a compatible enclosed POW R2 and want local telemetry plus the original relay. The BL0942 is another UART meter used in certain smart plugs, but the firmware component and protocol are different. The CSE7761 is used in documented dual-channel devices, with a different configuration and serial interface. A clamp-style external CT monitor can be preferable when you want to measure a circuit without routing all its load current through a smart-plug relay; choose a system with a safe, properly rated voltage reference and enclosure.

For our other approaches, see the site’s guides to BL0942 smart-plug metering, PZEM-016 RS485 AC energy monitoring and ATM90E32 multi-circuit metering. These are not drop-in replacements for the original POW R2 hardware; they address different circuit-count, integration and installation needs.

Frequently asked questions

Can I use the CSE7766 ESPHome component on any ESP32?

The software component can operate on a supported microcontroller with an appropriately configured UART, but that says nothing about the electrical isolation of a particular mains metering board. The internal POW R2 example uses ESP8266 pins; it does not provide a safe generic ESP32-to-mains wiring diagram. Identify both ends of any connection before designing a new device.

Why is there no UART TX pin in the example?

The documented CSE7766 application streams metering frames to the microcontroller. ESPHome needs the receiving pin and the expected serial parameters; it does not require a transmit connection in the shown POW R2 example.

Can this replace my electricity supplier’s meter?

No. It is useful for appliance monitoring and automation, subject to the finished product’s rating, but its telemetry should not be presented as revenue-grade metering or an electrical-safety diagnostic.

Why not simply publish every UART frame to Home Assistant?

Multiple frames per second add network and recorder churn without improving the usefulness of a minute-scale energy dashboard. Average rapidly varying instantaneous measurements and report cumulative quantities at a suitable interval. If you need short-duration peaks, choose and validate a more appropriate sampling and recording design.

Will the POW R2 automatically restore the previous relay state after a blackout?

Not with the sample configuration: it uses restore_mode: ALWAYS_OFF deliberately. Other restore modes exist, but changing that policy can restart a heater, pump or appliance unexpectedly. Decide the failure behaviour from the load’s actual risks, not merely convenience.

Official references

With the correct chip and device revision identified, a closed, safely installed POW R2 can report useful local AC power and energy measurements through ESPHome. The reliable route is to use the documented 4,800-baud even-parity UART configuration, keep normal serial logging off, verify the measurements against a trusted reference, and distinguish instantaneous watts from accumulated watt-hours. Treat the mains isolation of the physical device as a separate, non-negotiable requirement that no YAML setting can solve.

Share your love