HLW8032 Power Sensor

The hlw8032 sensor platform allows you to use your HLW8032 voltage/current and power sensors (datasheet) with ESPHome. This sensor is commonly found in M5Stack modules.

HLW8032 board

⚠️ Warning

SAFETY HAZARD: Some devices 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. UART TX pin is usually connected to the MCU via optocoupler.

The HLW8032 IC measures a single phase’s voltage (using a voltage divider) and current (using a shunt) and additionally provides active and apparent power and power factor measurements.

As the communication with the HLW8032 is done using UART, you need to have a UART bus in your configuration with the rx_pin connected to the HLW8032. Additionally, you need to set the baud rate to 4800 and the EVEN parity. The device sends multiple updates per second, so you will probably want some sort of averaging or throttle filter on the sensors.

# Example configuration entry
uart:
  rx_pin: GPIOXX
  baud_rate: 4800
  parity: EVEN

sensor:
  - platform: hlw8032
    voltage:
      name: HLW8032 Voltage
      id: hlw8032_voltage
    current:
      name: HLW8032 Current
      id: hlw8032_current
    power:
      name: HLW8032 Power
      id: hlw8032_power
    apparent_power:
      name: HLW8032 Apparent Power
      id: hlw8032_apparent_power
    power_factor:
      name: HLW8032 Power Factor
      id: hlw8032_power_factor

Configuration variables

  • current (Optional): Use the current value of the sensor in amperes. All options from Sensor.
  • power (Optional): Use the (active) power value of the sensor in watts. All options from Sensor.
  • voltage (Optional): Use the voltage value of the sensor in V (RMS). All options from Sensor.
  • apparent_power (Optional): Use the apparent power value of the sensor in volt amps. All options from Sensor.
  • power_factor (Optional): Use the power factor value of the sensor. All options from Sensor.
  • uart_id (Optional, ID): Manually specify the ID of the UART Component if you want to use multiple UART buses.

Advanced Options

  • current_resistor (Optional, float): The value of the shunt resistor for current measurement. Default value is 0.001 ohm.
  • voltage_divider (Optional, float): The value of the voltage divider on the board as R_upstream / (R_downstream * 1000). Default value is 1.72.

Energy Measurement

The HLW8032 has a PF (Pulse Frequency) output pin that generates pulses proportional to active energy consumption. This could be used with the Pulse Meter component for energy tracking.

Alternatively, you can use software integration with the power sensor:

sensor:
  - platform: hlw8032
    power:
      name: HLW8032 Power
      id: hlw8032_power
  - platform: total_daily_energy
    name: "Daily Energy"
    power_id: hlw8032_power

See Also