Will Low Cost ESP8266 4 Channel Power Monitor Work With ESPHome?

Anybody find a way to get the blue board to work? Also curious if this will work as I just ordered the blue board.

1 Like

The board maker sent me this link to a Github thread but I have not had time to try it yet:

I have mine already working on ESPHOME. The support is already there for the chip on the board.
I only have one channel. At first I was going to move to a different home , and didn’t install it in the fuse panel , but the way things are going looks like I will be here for another year. So may install it into the fuse panel. I have it only right now on my laptop on my desk. I used for testing.

here is a copy of my testing esphome.



esphome:
  name: home-power
  platform: ESP8266
  board: d1_mini

wifi:
  networks:
  - ssid: !secret wifi_ssidiot
    password: !secret wifi_password
    priority: 0
  - ssid: !secret wifi_ssid
    password: !secret wifi_password
    priority: 1

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Home-Power Fallback Hotspot"
    password: "9iwxxxxxxXpBc"


  manual_ip:
    static_ip: 192.168.1.153
    gateway: 192.168.1.1
    subnet: 255.255.255.0      


  reboot_timeout: 2min
#  fast_connect: true


# Enable logging
logger:
  level: DEBUG
  baud_rate: 0
  logs:
    ads1115: ERROR  
# Enable Home Assistant API
api:
  reboot_timeout: 5min

ota:
  password: "dxxxxxxxxxxxxxxxxx"
  
  
web_server:
  port: 80
  
captive_portal:



substitutions:
  esp_id: "esp-energymon"
# Common ADS1115 Sensor Setting
  ads_gain: "2.048"
  ads_update_interval: "850ms"
  #ads_update_interval: "250ms"
  ads_delta: "0.2"
  ads_heartbeat: "120s"
  ads_voltage: "120"
  
i2c:
  sda: GPIO04
  scl: GPIO05
  scan: False

ads1115:
# 1st ADS1115 (ADDR -> Grnd)
  - address: 0x48
    id: ads1115_1
    continuous_mode: on


# Example configuration entry
switch:
  - platform: gpio
    pin: GPIO013
    name: "Buzzer"
    #restore_mode: ALWAYS_OFF 
    inverted: true

  - platform: restart
    name: "ESP Home Power Restart"    

sensor:
# Channel 1
  - platform: ct_clamp
    sensor: ads1115_1_a0
    id: current_ch1
    name: "${esp_id} Current Ch 1"
    update_interval: 5s
## New Start    
    #sample_duration: 5s
    accuracy_decimals: 3
## New End    
    
    # Needs adjusting for individual Deployment
    filters:
      - calibrate_polynomial:
           degree: 2
           datapoints:
            - 0.00 -> 0
            - 0.00090 -> 0.11774325429
            - 0.003 -> 0.1885245901639344
            - 0.029 -> 4.10655737704918
            - 0.055 -> 7.516393442622951
            
        


      - sliding_window_moving_average:
          window_size: 5
          send_every: 1
      - lambda: if ( (x * ${ads_voltage}) < 10 ) { return 0; } else { return x ; }



    # When Current updates, update Watts
    on_value:
      then:
        - sensor.template.publish:
            id: watts_ch1
            # Local Voltage is 240V - adjust as required. 
            state: !lambda 'if ( (id(current_ch1).state * ${ads_voltage}) < 10 ) { return 0; } else { return id(current_ch1).state * ${ads_voltage}; }'
         
            
  - platform: ads1115
    ads1115_id: ads1115_1
    multiplexer: 'A0_GND'
    gain: ${ads_gain}
    name: "ADS1115-1-A0"
    id: ads1115_1_a0
    accuracy_decimals: 3
    update_interval: ${ads_update_interval}
    internal: true
    filters:
      # Samples every 250ms...Average over 10 Secs, Send every 5 Secs
    - sliding_window_moving_average:
          window_size: 40
          send_every: 20
    - delta: ${ads_delta}



# Template Sensors for Watts
  - platform: template
    id: watts_ch1
    name: "${esp_id} Watts Ch 1"
    lambda: return id(current_ch1).state * ${ads_voltage} ;
    unit_of_measurement: W
    accuracy_decimals: 3
    device_class: power


# Energy Sensors (kWh) for HA Dashboard
  - platform: total_daily_energy
    name: ${esp_id} Total kWh Ch1
    power_id: watts_ch1
    filters:
      - multiply: 0.001
    unit_of_measurement: kWh



# Voltage from HA
  - platform: homeassistant
    name: "Voltage"
    #ESPHome ID
    id: average_voltage
    entity_id: switch.1000c00249_voltage
    internal: true
  - platform: wifi_signal
    name: "${esp_id} WiFi Signal Sensor"
    update_interval: 60s    




# Total Energy sensor requires Times - could be SNTP or Home Assistant
time:
  - platform: homeassistant
    id: homeassistant_time  
    
    

2 Likes

Thanks, I will give that a go.

Hi @digiital , I gave this a go over the week and it seems to work great. I do however have a couple of follow-up questions …

  1. The switch you have added for the buzzer just lets out a faint crackle when I activate it, does yours produce a beep or other sounds?
  2. You set the substitution “ads_voltage” to “120” and I have changed this to “240” in my case. I see that you have also included a “Voltage” reading from a Home Assistant entity this has this - should this be used in the calcs instead of “ads_voltage” for greater accuracy?

Thanks!

  1. you can ignore that, I was playing around trying to get the buzzer to work, never did, didn’t remove the code.
  2. Yes its fine to change to 240. The code hasn’t been touched in a few months so I’m not sure which part you were referring too on the VOLTAGE.

Make sure you adjust the following numbers. I used a know power, like a lightbulb, tried heaters as well a few items to get a average to place down below . I don’t recall if I used a youtube video at first to see how it was done. Or just applying a 60w bulb and heater and looked at the logs to see the output.

   filters:
      - calibrate_polynomial:
           degree: 2
           datapoints:
            - 0.00 -> 0
            - 0.00090 -> 0.11774325429
            - 0.003 -> 0.1885245901639344
            - 0.029 -> 4.10655737704918
            - 0.055 -> 7.516393442622951

OK thanks, I did re-calibrate the polynomial.

Regarding the voltage question, you have the following:

image

image

And the calculations all use “ads_voltage” (i.e. 120 or 240) instead of “voltage” from a Home Assistant entity e.g.:

image

Why not use “voltage” instead of “ads_voltage”?

“Voltage” is just a label/name…
I’m pretty sure you could just remove that section. I was experimenting to see if I could figure out the voltages. But I stopped working on it

I’m trying the blue board with this:

4-Channel-Mains-Current-Sensor-ESP8266/mainspower.yaml at patch-2 · Darthmonkey/4-Channel-Mains-Current-Sensor-ESP8266 (github.com)

And seems to work fine.

Would anyone have an update on whether one of these is worth getting and essentially:

  • Whats the difference in performance between the green and the blue board?
  • How accurate is each board?
  • Does it work with ESPHome (and a recent sample code for 4 channels?)
  • Does it require calibration and how is that performed?

Appreciate any feedback :blush:

The headline “Will Low Cost ESP8266 4 Channel Power Monitor Work With ESPHome?” is actually misleading.

The website states that the product shown in the picture from @Jonah1970 is actually a “ESP8266 - 4 Channel Mains Current Sensor

Accurate power measuring will be impossible with that type of device :exploding_head:

The blue uses the internal ADC from the esp while the green board uses a (better) ads1115 - still both only measure current and not power :warning:

Does it matter at all? What does it help to know the AC current?

:point_up:

No idea. Low cost power monitoring can be achieved with pzem004t v3’s which not only comes factory calibrated with coil or clamp but are also cheap as hell :ok_hand:

3 Likes

I calibrated with different bulbs and a plug power meter to check bulbs real and precise power.
Then I calibrated high power with a current clamp.

I verified precise voltage to set it in the code and I think it is enough accurate for me. In future I will test the difference with a PZem

1 Like

Did you only use the good old incandescent “heat” bulbs with a power factor of 1 or also other types like CFL or LED? :twisted_rightwards_arrows:

“real” in terms of real/true power which is typically measured in Watts? :zap:

Also any information/specifications about the plug power meter you used? :page_facing_up:

The “high power” source wasn’t by accident a pure restive load (so again pf=1) :question:

So you are actually calculating (or “guessing”) the apparent power (kVA) actually and not the real power (W) :warning:

image

As a hint: Power companies usually only bill private individuals for the “useful work” = real/true power :beers:

2 Likes

Thanks @orange-assistant for comprehensive feedback… really useful to know. So would you be enclined to say that the most accurate and cost effective way is to get, say, 3 or 4 of these to hook up to your consumer unit (mains and the optional circuits you want to monitor)? How many can you run of a single ESP32 such as a D1 mini?

1 Like

Good question. I think there is no “hard” limit but by the looks of it 10 are already somewhat troublesome:

I run 4 pzem004t v3’s on a esp32 with ethernet (in the past I used a esp8266 d1 mini for it) and they just work :tm:

Yes, just hook the coils/clamps up to the circuits/machines you want to monitor - no rocket science :man_scientist::rocket:

The most cost effective way I think yes - the most accurate probably not. But in my opinion it certainly features the (by far) best accuracy per buck :money_mouth_face:

2 Likes

Thanks again for your suggestions @orange-assistant, parts are on order!

Did you only use the good old incandescent “heat” bulbs with a power factor of 1 or also other types like CFL or LED ?

yes both

Any information/specifications about the plug power meter you used?

Chacon power meter

The “high power” source wasn’t by accident a pure restive load (so again pf=1)

was mixed, I turned on several things at home up to 2A@240v

So you are actually calculating (or “guessing”) the apparent power (kVA) actually and not the real power (W)

Well I do not need to verify if my energy seller is cheating me. I need to turn off high power equipment when solar production is <less then consumed.

As a hint: Power companies usually only bill private individuals for the “useful work ” = real/true power

thanks for the accurate tip, I will check in future with a pzem how much is that difference

Actually the power factor is often printed on products and depending on the country you are living there is even regulations “forcing” a minimum power factor :chart_with_upwards_trend:

For example if you have a led light with a power factor of 0.5 your apparent power readings will actually show double (:x::two::warning:) of the real power :zap:

Companies with high consumption often get billed for the apparent power consumption btw. :slot_machine:

2 Likes

I love to read the discussion and the progress but I still feel a bit lost how to build such a PZEM-004T based one.
I am also wondering, if you can replace such coil with that clamp used here cause getting such coils into the cabinet is a lot more challenging considering that I would have to remove every measured line from the board inside.

Thanks for any further hints to find such esp based product to buy or build.