Open Source Current Meter Project for Home Assistant (ESPHome) Modular Open Hardware with schematics and gerber files. Up to 38 current sensors per board for full electrical panel monitoring.
Thank you all the fine folks at ESPHome, Home Assistant, OpenEnergyMonitor, ESP32EnergyMonitor Project, and everyone else who contributed to making this possible!
I wanted to measure the current of every branch from my main panel, and display the info in Home Assistant. In North America where I live, it is common to have a 200a split phase circuit coming in from the grid. a 120v line a neutral and an inverted 120v line. You get 240v by using the two hots, and you get 120v by using either one of the hots and the neutral. I looked up commercial whole panel energy monitoring kits, but they are $200-$250 for 16 sensors. For my panel I need around 24 seperate sensors to monitor everything. So, I decided to go the diy route. I wanted a lego-like dev board aproach. Using off the shelf development circuit boards, custom PCBs, and 3D printed cases.
I decided to go with the ESP32 for the microcontroller since it supports up to 8 analog inputs, (only 6 are exposed with the common dev board: NodeMCU-32s). It's cheap and available on Aliexpress or Amazon. It also has to I2C channels that can connect to other ADC devices like the ADC1115. The ADC1115 dev barod support 4 anaolog input pins, and 4 different I2c addresses per channel. So you can connect up to 8 of them per esp32 dev board. which supplies up to 32 analog inputs pins in addition to the 6 available on the dev board. https://medium.com/@cedricdiego0/esp32-with-an-external-adc-ads1115-a86d3b51bb8 I found this screw terminal carrier board: https://s.click.aliexpress.com/e/_mtEjbfw With this 3D model from @IOTHARMONIC at https://cults3d.com/en/3d-model/tool/esp32-terminal-case-iotharmonic. I printed a case. I used grey PLA to match most of the othe electrical boxes in my cabinet.
CT sensors seem to be pretty expenseive, but I found this sensor on AliExpress: https://s.click.aliexpress.com/e/_DeVVdyx. For $1.29ea. 1pc AC Current transformer CT for Mini ammeter Current meter 0-100A ratio : 1000:1 , XH2.54
###Schematic for sensor board. I found this schematic in the home assistant forums. from https://community.home-assistant.io/t/esphome-ct-clamp-30a-1v/284423 @audacity363
I found this project: https://github.com/danpeig/ESP32EnergyMonitor, based on this one: https://github.com/openenergymonitor/EmonLib This is almost what I want, but the prototype is using prototype board. I wanted printed circuit boards.
https://github.com/danpeig/ESP32EnergyMonitor/blob/main/images/electronic_parts.png
I started with my own prototype to test the ct sensor, and the esphome's native ctsensor component. I used the first schematic. the one in the forum post, and it seemed to work. Here is the ESPHome configuration for a simple one sensor test. I just used a static 120v to calculate watts, since I have not hooked up any high voltage sensor yet. Or, I can import it from a different sensor like this fine fellow: https://youtu.be/fvCqXjey8lI?si=_bgAWkstAmH1iarE
#ctmini.yaml
esphome:
name: current-sensors
friendly_name: current sensors
esp32:
board: nodemcu-32s
framework:
type: arduino
# Enable logging
logger:
# then remember to add time, you need this for daily consumption sensors
# add the following:
time:
- platform: sntp
id: my_time
sensor:
- platform: adc
pin: A0
id: adc_sensor0
update_interval: 6s
attenuation: auto
- platform: ct_clamp
sensor: adc_sensor0
name: "Sensor0 Current"
update_interval: 10s
filters:
- calibrate_linear:
- 0.00773 -> 0
- 0.09481 -> 0.04
- 1.07216 -> 0.80
id: sensor0
internal: True
- platform: template # this will be the final current reading visible in the front end
name: "Sensor0 Current"
id: current0
lambda: |-
if (id(sensor0).state > 0.01){
return (id(sensor0).state);
} else {
return 0.0;
}
device_class: current
update_interval: 5s
accuracy_decimals: 2
unit_of_measurement: A
- platform: total_daily_energy #this will calculate the total current used for the day (AmpHour)
name: "Sensor0 Daily Current"
power_id: current0
accuracy_decimals: 2
unit_of_measurement: Ah
- platform: template #this sensor will measure your power0 consumption (Watt)
name: "Sensor0 Measured Power"
id: power0
lambda: |-
return id(current0).state * 120;
accuracy_decimals: 2
update_interval: 5s
device_class: power
unit_of_measurement: W
- platform: total_daily_energy #this will keep track of power0 consumed daily (kwh)
name: "Sensor0 Total Daily Power Consumption"
unit_of_measurement: kWh
power_id: power0
accuracy_decimals: 2
filters:
- multiply: 0.001
device_class: energy
Now it's on to designing some simple PCBs.
Then I made some little buscards:
I decided to use these little screw down terminals for all the connectors. They seem sturdy enough if you use solid copper, or add solder or ferrules to stranded copper. https://s.click.aliexpress.com/e/_mrACAIc
Now to design the ADS1115 carrier board, with jumpers to change the address. I chose this one: $1.55 | 1PCS~10PCS EGBO 12 Bit/16 Bit I2C ADS1115 ADS1015 Module ADC 4 channel with Pro Gain Amplifier for Arduino RPi Purple Blue https://a.aliexpress.com/_mNYfWdK
This board be seeed looks almost perfect, but not quite since I want to daisy chain the I2c bus. https://wiki.seeedstudio.com/Grove-16-bit-ADC-ADS1115/status