CB2S + BL0937 => current measurement remains in dashboard without a load

Apologies, just read that this should have been in the Configuration category.

Hi all,

Hardware: Mercator Ikuu SPLUG02 series 2. Single relay switched plug with current,power, voltage measurement.
Internal hardware: Beken CB2S, Measurement chip: BL0937 (HLW8012 equivalent).

I am confused on the issue of seeing a Current measurement even when there is no load connected. and the relay is OFF.

Relevant portion of the code:

# Board: Generic - BK7231N (Tuya QFN32)
# Definition: definitions/boards/generic-bk7231n-qfn32-tuya/manifest.yaml

esphome:
  name: mainsswitch2
  friendly_name: MainsSwitch#2

bk72xx:
  board: cb2s

logger:

api:
  encryption:
    key: "mzAZmQ6OHX2CDwKzLu9zoNgf02G7KJJIRotabxieFf8="

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: MainsSwitch#2 Fallback Hotspot
    password: "lhMzHy6jefiD"

captive_portal:
text_sensor:
  - platform: libretiny
    version:
      name: LibreTiny Version

output:
  - platform: libretiny_pwm
    id: output_led_1
    pin: P26


What am I missing, or should I do differently?

Cheers,
DutchTuatara
light:
  - platform: monochromatic
    id: light_switch_1
    output: output_led_1

binary_sensor:
  - platform: gpio
    id: binary_switch_1
    pin:
      number: P11
      inverted: true
      mode: INPUT_PULLUP
    on_press:
      then:
        - switch.toggle: switch_1

switch:
  - platform: gpio
    id: switch_1
    name: Relay 1
    pin: P8
    on_turn_on:
      - light.turn_on: light_switch_1
    on_turn_off:
      - light.turn_off: light_switch_1

status_led:
  pin: P10

substitutions:
  voltage_divider: "767.4905739421869"
  current_resistor: "0.0010422723965338564"
  current_multiply: "1802.2626856731272"

sensor:
  - platform: hlw8012
    model: BL0937
    cf_pin:
      number: P7
      inverted: true
    cf1_pin:
      number: P6
      inverted: true
    sel_pin:
      number: P24
      inverted: true
    current:
      name: BL0937 Current
      filters:
       - multiply: ${current_multiply}
    voltage:
      name: BL0937 Voltage
    power:
      name: BL0937 Power
    energy:
      name: BL0937 Energy
    voltage_divider: ${voltage_divider}
    current_resistor: ${current_resistor}
    update_interval: 60s

What do I need to change to stop this?
Any ideas gratefully accepted.

Cheers,
DutchTuatara

what’s the point here?
what readings do you get for known resistive load while on/off?

This is after calibration, as initially the indicated current was only 40mA, when using a 2kW resistive load, fan heater.
After that, current read out is okay when using, but remove the load, current value should be 0A, but still shows ~8A.
That’s what is wrong.

Unplug the device altogether. After 2 hours, plus back in, still incorrect value shown.

Is there a way to reset to zero, before the next measurement cycle?

I’m not familiar with your device but doesn’t sound correct to me.
What are you getting on esphome logs?
Ps. fan heater is mainly resistive load but not purely.

Not home right now, at work.
Will check logs later.
Yeah, I’m aware not 100% resistive. The fan motor itself causes issues. I’m not after 100% accuracy, but the indication should be close
Initial voltage was something like 480V, although at outlet it is 230V.