HLW8012 detecting voltage as 0.00V

I’m having trouble with getting the voltage detection to work on a Etekcity Voltson (smart plug with power monitoring). I have been able to successfully flash the device and can operate the switch from HA.

I followed the following docs to get to this point:
ESPHome Device - Docs for the EU version of the plug
Tasmota Device - To compare the pinout for the US version of the plug
(And some helpful hints in a previous post to this one!)

The ESPHome docs do say that, in this implementation of the HLW8012 component, the SEL_PIN is permanently pulled high and this prevents direct current monitoring (only power and voltage). An example to calculate the current is included in the doc.

The only sensor result I get is the power (wattage). The voltage is constantly reported as 0.00 V. Without a voltage value, the calculated current sensor is invalid. Toggling the relay on does not have any effect on the sensor values.

I have confirmed the pin mapping is accurate and compared the sensor YAML syntax and formatting against the ESPHome sensor and HLW8012 docs. Everything looks to be correct.

According to the HLW8012 docs the CF_PIN reports the power (wattage) and the CF1_PIN reports the current and voltage based on selection. In this case it will only report voltage as it’s permanently pulled high. I know the CF_PIN is correct because I get values on for the power sensor.

I guess the docs could be off for the CF1_PIN but there is no indication on the device anywhere about a hardware version to further investigate.

I’m open to suggestions if anyone has one.

Many Thanks!

Here's the code:
esphome:
... <setup details> ...

status_led:
  pin:
    number: GPIO5

output:
- platform: gpio
  id: led1
  pin: GPIO16

switch:
- platform: gpio
  name: "Relay"
  id: switch1
  pin: GPIO4
  restore_mode: RESTORE_DEFAULT_OFF
  on_turn_on:
    - output.turn_on: led1
  on_turn_off:
    - output.turn_off: led1

binary_sensor:
  - platform: gpio
    id: button1
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
      inverted: true 
    on_press:
      - switch.toggle: switch1

sensor:
  - platform: hlw8012
    sel_pin: 0 #Example sets to 0.  Tried GPIO15 also with no effect on the issue.
    cf_pin: GPIO13
    cf1_pin: GPIO12
    voltage:
      id: hlw8012_voltage
      name: Voltage
    power:
      id: hlw8012_wattage
      name: Wattage
      on_value:
        then:
          - sensor.template.publish:
              id: hlw8012_current_calculated
              state: !lambda 'return id(hlw8012_wattage).state / id(hlw8012_voltage).state;'
    update_interval: 60s
    initial_mode: VOLTAGE
    change_mode_every: 4294967295 # basically never
  - platform: template 
    id: hlw8012_current_calculated
    name: "Current (calculated)"
1 Like