Overview

The CSE7766 is a single-phase electricity metering IC manufactured by China Silergy (CSE). Embedded inside popular commercial Wi-Fi smart plugs—most notably the Sonoff S31 and Sonoff POW R2—it measures RMS AC voltage, RMS AC current, active power (W), and cumulative energy consumption.

Selected by manufacturers as the successor to pulse-counting ICs like the HLW8012, the CSE7766 offloads pulse-timing calculations from the microcontroller. It streams pre-calculated 24-byte telemetry data frames continuously over a 4,800 baud TTL UART interface. It is natively supported in Tasmota, ESPHome, and Home Assistant.

Quick reference

Operating voltage (VDD)4.5 V to 5.5 V DC (5.0 V nominal)
InterfaceTTL UART (4,800 bps, 8-E-1: 8 data bits, Even parity, 1 stop bit)
Baud rateFixed 4,800 bps
Measurement parametersVRMSV_{RMS}, IRMSI_{RMS}, Active Power (PP), Energy Accumulator (EE)
Telemetry frame frequencyAutomatically streams 1 frame every ~1.0 second
Measurement accuracyClass 0.5 (±0.5%\pm 0.5\%)
Operating current3.5 mA3.5\text{ mA} typical

Pinout (SOP-8 Package)

text
             ┌───┴───┐
          VDD ─┤ 1    8├─ GND
          V1P ─┤ 2    7├─ NC
          V1N ─┤ 3    6├─ RX
           V2P ─┤ 4    5├─ TX
             └───────┘
PinNameTypeDescription
1VDDPowerCore supply (+4.5 V to +5.5 V DC)
2V1PAnalog InputPositive current sense input (from 1 mΩ1\ \text{m}\Omega shunt)
3V1NAnalog InputNegative current sense input
4V2PAnalog InputVoltage sense input (from resistor divider; V2NV_{2N} connected to GND)
5TXDigital OutputUART Transmit output pin (4,800 bps)
6RXDigital InputUART Receive input pin
8GNDPowerGround reference (0 V)

Specifications

ParameterSymbolMinTypMaxUnitConditions
Supply VoltageVDDV_{DD}4.55.05.5VDC
Supply CurrentIDDI_{DD}3.55.0mAActive operation
Current Channel Input RangeVV1PV1NV_{V1P-V1N}-43.7+43.7mV PeakDifferential shunt voltage
Voltage Channel Input RangeVV2PV_{V2P}-43.7+43.7mV PeakSingle-ended voltage
Measurement AccuracyEmeterE_{meter}-0.5%±0.1%\pm 0.1\%+0.5%Active power range 1000:1
Internal Voltage RefVREFV_{REF}1.201.251.30VLow temperature coefficient

Telemetry Frame Structure

The CSE7766 streams 24-byte binary frames every second over 4,800 baud serial (8-E-1):

  • Header Bytes (0–1): 0x55 0x5A (or 0x5A 0x5A).
  • Voltage Coefficients & Data (Bytes 2–7): 24-bit Voltage coefficient (KVK_V) and 24-bit Voltage cycle count (TVT_V).
  • Current Coefficients & Data (Bytes 8–13): 24-bit Current coefficient (KIK_I) and 24-bit Current cycle count (TIT_I).
  • Power Coefficients & Data (Bytes 14–19): 24-bit Power coefficient (KPK_P) and 24-bit Power cycle count (TPT_P).
  • Status & Pulse Count (Bytes 20–22): Error flags and cumulative energy pulse counter.
  • Checksum Byte (23): 8-bit sum of bytes 2 through 22.

VRMS (V)=KVTVVoltsV_{RMS}\text{ (V)} = \frac{K_V}{T_V} \quad \text{Volts}

IRMS (A)=KITIAmperesI_{RMS}\text{ (A)} = \frac{K_I}{T_I} \quad \text{Amperes}

P (W)=KPTPWattsP\text{ (W)} = \frac{K_P}{T_P} \quad \text{Watts}

Wiring (Sonoff S31 / POW R2 Internal PCB)

CSE7766 PinESP8266 / ESP32 GPIONotes
VDD3.3V / 5VPower rail
GNDGNDCommon ground (tied to Neutral AC mains)
TXMCU RX Pin (GPIO 3 or 13)4800 baud 8-E-1
RXMCU TX Pin (GPIO 1)Command input
Warning

High Voltage Safety Warning:

  • The CSE7766 GND pin is connected directly to AC Neutral. Connecting a serial programmer to the UART pins while the smart plug is plugged into mains power will blow computer USB ports and cause electric shock. Program/debug smart plugs ONLY while unplugged from 120V/230V AC wall outlets.

Example (ESPHome Configuration)

yaml
uart:
  rx_pin: GPIO13
  baud_rate: 4800
  parity: EVEN

sensor:
  - platform: cse7766
    voltage:
      name: "Sonoff S31 Voltage"
    current:
      name: "Sonoff S31 Current"
    power:
      name: "Sonoff S31 Power"
    energy:
      name: "Sonoff S31 Energy"

Common mistakes

  • Setting incorrect serial parity: The CSE7766 uses Even parity (8-E-1), not standard No-parity (8-N-1). Setting NONE parity results in frame checksum validation failures.
  • Using 9600 or 115200 baud: The CSE7766 UART clock is fixed at 4800 baud.

Notes

  • CSE7766 vs HLW8012: CSE7766 sends pre-calculated telemetry over UART (8-E-1); HLW8012 outputs variable frequency pulse trains (CF/CF1).

Assets & downloads