is it possible to change the resolution of the power reading of ESP8266 / HLW8012?
Ich have a “Shelly Plug” EU version (I assume technically it is called “Shelly Plug 2”). ESPHome is running fine. I use the device for switching and energy metering of the connected coffee machine that draws 2400 W at maximum and about 2 W at idle.
The issue is, that I want to be able to detect if the connected device is switched on by reading the power signal and a threshold of about 3 W. With ESPHome and HLW8012 I get a signal resolution of about 10 W what is too much to measure around 3 W. With the original Shelly software, I was able to do so with this device.
Is there any parameter for the HLW8012 platform or an alternative way for reading the values at higher resolution in ESPHome?
My issue is not precision. My issue is resolution.
The calibration I did by using a power meter and different electrical devices with different power draw. The calibration in my first post are these readings at 5 points. I verified after calibration be measuring and it fits.
Ignoring the offset and my limited possibility to generate precise power draws I get a resolution of about 15.3 W in the low power range.
You might keep this sensor internal only for your productive system to don’t flood HA and have another copy sensor with some filter like throttle or some average that is exposed to HA
In Tasmota all is running as expected. I flashed to Tasmota and did the calibration. All power readings are matching to the power meter and I get power values in the low range. 5 W, 9 W and 17W is what I could test with available devices connected.
Back to ESPHome it was not working as before.
I did the calibration again in a different way using urrent_resistor and voltage_divider. All OK for the high power values. But I do not get the wanted resolution in the low power range. 32 W is the first value I get after 0 W.
substitutions:
voltage_divider: "2351"
current_resistor: "0.0006735057983942908"
current_multiply: "1.0"
[...]
- platform: hlw8012
sel_pin: GPIO1 # not connected, but required for compiling.
cf_pin: GPIO5
cf1_pin: GPIO3 # not connected, but required for compiling.
current_resistor: ${current_resistor}
voltage_divider: ${voltage_divider}
# Current sensor: Not existing in Shelly Plug EU!
current:
name: "${channel_1} current"
filters:
- multiply: ${current_multiply}
internal: true
# Voltage sensor: Not existing in Shelly Plug EU!
voltage:
name: "${channel_1} voltage"
internal: true
power:
name: "${channel_1} power"
id: power
unit_of_measurement: "W"
accuracy_decimals: 1
device_class: power
state_class: measurement
update_interval: 1s
Just deployed a hlw8012 based plug in a HA free enviroment and I don’t had any problems at all (detecting “standby” of an appliance when power is less than 4W and turn it off).
Only thing I spot is that your calibration seems to be very far of mine
# Higher value gives lower watt readout
current_res: "0.00290"
# Lower value gives lower voltage readout
voltage_div: "940"
As starting values before calibration I used the standard values. Not having set a value will end up in a voltage devider of 2351 and a current resistor of 1.0 Ohm. Acc. ESPHome manual these are standard values of Sonoff devices. Id did not found values for my specific device. So I used these ones. The config above are the values after calibration.
Similar comments to @orange-assistant. My resolution looks to be 0.1W on graphs and no issue detecting small power differences. Also only single value multipliers.
May not make a difference but you could try and add bl0937. I searched on Shelley teardown and it did mention this was used. The esphome docs are often generic and manufacturers are changing devices all the time.
If your device is that old then maybe a limitation of the power sensor chip? Doubt it is the esp side. I have athom plugs using esp8266 but power chip cse7766. Again, this has good sensitivity & resolution.
Please have a look in my previous posts. It is working with the original Shelly software and it is working with Tasmota software. It is not working with ESPHome. So it cannot be a hardware limitation.
This either is a limitation of ESPHome in combiombination with this hardware or a misconfiguration by me. This is what I want to figure out.
It’s probably one of the more common devices - I can’t imagen esphome not working properly on that one, specially that it has an device entry an no marks whatsoever