From the bench

HLW8110 programming: startup sequence for single-phase AC energy metering

September 13, 2026 · AI-generated from the datasheet, fact-checked by two independent LLM critics

HLW8110: the target use case

Single-phase AC energy metering from the datasheet's typical-application circuit: the load current is sensed through a low-value shunt on the IAP/IAN inputs, the mains voltage through a resistor divider into VP, and the HLW8110 computes VRMS, IRMS, active power, active energy, power factor and line frequency in hardware, reporting results over UART (or SPI) to a host MCU. Stated accuracy: <0.1% active-energy error over a 5000:1 dynamic range — but only after you load calibration coefficients, which the part forgets on every reset.

Next step
Start building with HLW8110 → This guide comes from the same grounded, cited datasheet answers — ask the assistant your own HLW8110 questions.

HLW8110: numbers that actually constrain the design

Before the register sequence, these are the figures engineers most often misread:

HLW8110: startup sequence

The only ordering the datasheet enforces is unlock → select channel → write calibration → relock, with an optional software reset first. Register reads/writes use UART frames of the form 0xA5 | command | data... | checksum; the special commands (0xEA 0x96 reset, 0xEA 0xE5 write-enable, 0xEA 0xDC relock, 0xEA 0x5A/0xEA 0xA5 channel select) are a distinct two-byte opcode form — they are not 0xA5-framed and carry no checksum.

Required steps

  1. (Optional but recommended) Software reset — send 0xEA 0x96. The chip resets within ~2 system clocks and all registers return to initial values; the RST flag in SysStatus (0x43H) is set. This guarantees a known state on a re-boot of the host.

    Wait: reset completes after 2 system clocks. The built-in clock MCLK is typ 3.579 MHz (3.507–3.65 MHz per Table 5); the datasheet's frequency-register text uses 3.579545 MHz nominal, so 2 clocks ≈ 0.56 µs (0.55–0.57 µs across the clock tolerance band). This is the only between-writes wait the datasheet states.

  2. Read SysStatus (0x43H) and confirm RST=1. The RST flag is cleared by reading it. This both verifies you are talking to the part and marks that a fresh calibration load is required.

  3. Open write-enable — send 0xEA 0xE5. Register writes are refused until this is issued.

  4. Select the metering current channel — send 0xEA 0x5A for Channel A (the built-in current-sense path; the typical design's choice) or 0xEA 0xA5 for Channel B (external amplifier). This command selects which current signal feeds apparent power, power factor, phase angle, instantaneous apparent power, and active-power overload. If you never issue it, or pick the channel your transducer isn't wired to, those results report the wrong channel.

  5. Write the system control register SYSICON @ 0x00H (default 0x0A04H) to set the PGA gains: PGAIA[2:0] bits 2–0 (current channel A), PGAU[2:0] bits 5–3 (voltage), PGAIB[2:0] bits 8–6 (current channel B). Gain decode for all three: 000=1, 001=2, 010=4, 011=8, 1XX=16. The default 0x0A04H decodes to PGAIA=16, PGAU=1, PGAIB=1.

  6. Write EMUCON @ 0x01H (default 0000H) if you need to change comparator mode (comp_off, bit 12: 0 = comparator active, 1 = comparator closed) or the temperature sensor (tensor_en, bit 13, plus Tsensor_Step[1:0], bits 15–14). For basic single-phase metering with the comparator kept, leave at default. Honest caveat: the middle of the EMUCON/EMUCON2 (0x13H, default 0001H) bitfield tables were not fully readable from the datasheet text available, so I cannot cite a complete canned word for every EMUCON configuration — verify the remaining bit offsets against Table 11 in your copy of the datasheet before writing a non-default value.

  7. Load calibration coefficients. This is the step that makes the measurement accurate. Confirmed registers:

    Register Addr Default Format
    PAGain (active-power gain, ch A + voltage) 0x05H 0x0000H 16-bit two's complement, bit15 = sign; calibration range ±100%
    RmsIAOS (current-A RMS offset) 0x0EH 0x0000H 16-bit two's complement, bit15 = sign

    The datasheet's register survey also lists PBGain (0x06H), PSGain (0x07H), PAOS (0x0AH), PBOS (0x0BH), RmsIBOS (0x0FH) in the same calibration block. There is no fixed working value: PAGain is computed as INT[2^16 + PAGain·2^15] from your measured gain error. For the RMS offset: with the current input zeroed, read RmsIA repeatedly (~3.4 Hz update rate), average, then negate (bitwise-invert + 1) to get the offset code. Note there is no on-chip RMS gain register — RMS gain scaling (KiA = Ib / RmsIA_reg, Ku = Ub / RmsU_reg) is done on the host MCU after reading the raw RMS registers.

  8. (If using interrupts) Configure IE @ 0x40H — still inside the write-enable window. The datasheet states write-enable must be opened before configuring IE. Setting an enable bit and having that event occur drives the IRQ_N (INT1/INT2) pin low.

  9. Close write-enable — send 0xEA 0xDC. All further writes are refused until the next 0xEA 0xE5. If you lock before writing calibration, no coefficient lands — this is a common failure.

Design choices and their stated trade-offs

HLW8110: required waits and timing

HLW8110: reading results back

The metering results live in the metrological parameter registers. Representative: RmsIA (0x24H), RmsIB (0x25H), RmsU (0x26H) — each 24-bit signed, MSB 0 = valid data, MSB 1 = treat as zero. Active power, apparent power, energy and power factor are the same register class, read over the UART read frame (0xA5, command byte with bit7=0, then receive data high byte first, then check byte).

Two runtime patterns:

Read-to-clear discipline: flags such as RST are cleared by being read. The standard loop is read IF/status → act → the read itself clears the pending state → poll again next interval.

HLW8110: verifying the configuration took

  1. Boot state: read SysStatus (0x43H) right after power-up; expect RST=1, which the read clears. This confirms you are talking to a freshly-booted, uncalibrated part.
  2. Every write: read the SPI Write Check Register WDATA @ 0x45H (read-only, default 0000H) and confirm it equals the 2-byte value you wrote. A mismatch means the write was refused — usually write-enable was closed, or IE was written before unlock.
  3. Every read: the RDATA register holds the last read 4 bytes and can be used to verify the read data returned over the bus.
  4. Metering config committed: read the Meter Status register (EMUStatus). Reading it is one of the triggers that restarts the check-and-calculation, and the datasheet notes two system clock cycles are required for the checksum calculation — so wait ≥2 system clocks (~0.56 µs) after reading EMUStatus before reading the result registers. Then confirm the RMS register MSBs are 0 (valid data).

HLW8110: troubleshooting

Part page: HLW8110.