esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 36 forks source link

Discrepancy with config of HLW8012 component (BL0937) between ESP82xx and BK27xx platforms #5812

Open jordan875 opened 6 months ago

jordan875 commented 6 months ago

The problem

When using the HLW8012 component with model BL0937 on Beken BK2731N, the "voltage_divider" value must be half of what it is with the same config on ESP82xx to achieve the same voltage reading.

The power (wattage) output reads the same (and correctly) with the same "current_resistor" value between platforms.

Background: I have multiple smart plugs that were delivered with CB2S modules containing BK2731N chips. In one smart plug I transplanted an ESP-02S module with ESPHome installed. I flashed ESPHome to the CB2S module in another identical smart plug. Using the same config (accounting for pin naming differences) is not possible between the two platforms, all sensors from BL0937 read zero. If the "cf" and "cf1" pins are inverted for the BK2731, values are generated but they are not correct. (On ESP only the "sel" pin is inverted.) If all BL0937 pins are inverted for the BK2731, the sensors show values, but the voltage shown is double the true voltage. This can be reduced to what seems to be the correct voltage by halving the "voltage_divider" value.

Which version of ESPHome has the issue?

2024.5.0

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.4.3

What platform are you using?

BK72XX

Board

CB2S

Component causing the issue

hlw8012

Example YAML snippet

Config on BK2731N:

sensor:
  - platform: hlw8012
    model: BL0937
    cf_pin:
      number: P6
      inverted: true
    cf1_pin: 
      number: P7
      inverted: true
    sel_pin:
      number: P26
      inverted: true
    current_resistor: "0.001"
    voltage_divider: "1560"
    current:
      name: "${name} Current"
      unit_of_measurement: A
      accuracy_decimals: 3
      state_class: measurement
      device_class: current
    voltage:
      name: "${name} Voltage"
      unit_of_measurement: V
      state_class: measurement
      device_class: voltage
    power:
      name: "${name} Wattage"
      unit_of_measurement: W
      id: wattage
      state_class: measurement
      device_class: power
    change_mode_every: 4
    update_interval: 10s

Config on ESP:

  - platform: hlw8012
    model: BL0937
    cf_pin: GPIO5
    cf1_pin: GPIO4
    sel_pin:
      number: GPIO14
      inverted: true
    current_resistor: "0.001"
    voltage_divider: "780"
    current:
      name: "${name} Current"
      unit_of_measurement: A
      accuracy_decimals: 3
      state_class: measurement
      device_class: current
    voltage:
      name: "${name} Voltage"
      unit_of_measurement: V
      state_class: measurement
      device_class: voltage
    power:
      name: "${name} Wattage"
      unit_of_measurement: W
      id: wattage
      state_class: measurement
      device_class: power
    change_mode_every: 4
    update_interval: 10s


### Anything in the logs that might be useful for us?

_No response_

### Additional information

_No response_
github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jordan875 commented 1 month ago

Adding a comment to remove the stale marker as this remains an issue