DIY Whole Home Energy Monitoring with Home Assistant

Posted by Colin on Mon, Mar 25, 2024

Why energy monitoring?

I recently decided I wanted more data on our home energy usage. Unfortunately our meter box is over 20 years old and our energy supplier wont replace it until it is 30 years old. It is an old spinning disk style meter with analog display.

Analog Meter

I had considered using a camera and some machine learning to read the digits from the display, but I think monitoring the actual power usage will be much better. Doing this is dangerous however so I needed a way to do it without my wife cashing in the life insurance.

CT Clamps measure the magnetic field coming from an electrical cable. My measuring the strength of the field via the induced current into a coil, you can get a measurement of the current flowing through the wire without being electrically connected to it. Split core CT Clamps make this even safer, by allowing you to “clamp” the sensor around the wire without having to disconnect anything.

Important warning

DISCLAIMER: I am not a qualified electrician. Using even these “safe” CT clamps does have a risk associated with it, and being in and around your electricity meter is obviously risky business. Please consult a suitably certified expert before attempting any of this! YOU HAVE BEEN WARNED!


The Plan

My plan is to build a small system using some pre-made circuit boards for this purpose. Then install ESPHome onto an ESP8266 chip to allow easy programming and connection with Home Assistant. Once it is all installed, I should be able to have a nice simple gauge on my Home Assistant dashboard showing the live energy usage in the house. Home Assistant will also graph this data historically to allow us to see patterns of use and perhaps adjust our behaviour to help reduce our energy costs.

The parts should cost less that £20 ($25 USD).

The Parts

Prepare the sensor

The first thing to do was to assemble the parts. This was pretty straightforward once I had the header pins soldered onto the Wemos D1 Mini. Just snap the two parts together and then connected it to my Mac via USB cable.

Then I navigated to the ESPHome web installer. I had to do this using Google Chrome as Safari on Mac does not currently support WebSerial.

Just click Connect and then choose the serial port from the menu that pops up. Add in your home WiFi details and that is your ESPHome device created and it should appear in Home Assistant ready for adoption.

Once I had the device connected to Home Assistant it was time to program it. ESPHome allows you to use YAML files to configure the devices. Simply change the YAML, hit Save and Install and then choose WiFi. This will send your new device configuration over to the ESPHome device and reboot it, displaying logs to show how it went.

Here is the code I used for my sensor:

 2name: esphome-web-6eb49e
 3friendly_name: CT Clamp
 6name: ${name}
 7friendly_name: ${friendly_name}
 8name_add_mac_suffix: false
10name: esphome.web
11version: '1.0'
14board: esp01_1m
16# Enable logging
19# Enable Home Assistant API
22# Allow Over-The-Air updates
25# Allow provisioning Wi-Fi via serial
29# Set up a wifi access point
30ap: {}
32# In combination with the `ap` this allows the user
33# to provision wifi credentials to the device via WiFi AP.
37package_import_url: github://esphome/example-configs/esphome-web/esp8266.yaml@main
38import_full_config: true
40# To have a "next url" for improv serial
43# Example configuration entry
45- platform: ct_clamp
46sensor: adc_sensor
47name: "Measured Current"
48id: home_current
49update_interval: 15s
51- calibrate_linear:
52# Measured value of 0 maps to 0A
53- 0 -> 0
54- 0.028 -> 8.8
56# Example source sensor
57- platform: adc
58pin: A0
59id: adc_sensor
61- platform: template
62id: my_power
63name: "Home Power"
64lambda: return id(home_current).state * 230;
65device_class: power
66unit_of_measurement: 'W'
67update_interval: 15s

You have to calibrate the sensor using a known load. How I did this was to strip back the out sheath from an extension cable, allowing me to access the live wire separately. I could then clamp the CT over the live wire, and then plug in a known load to the extension cable. I also used a plug in energy monitoring plug to verify results.

Do not make a cable like this

I ran a hairdryer on its medium setting and saw that it produced 4.4 amps on the digital meter, while the ESPHome chip was reporting 0.014A. I then ran it on max, and saw the digital meter showing 8.8 amps of draw, and the ESPHome showing 0.028.

So in the YAML file under the calibrate linear section I add 0 -> 0 and 0.028 -> 8.8. This will then allow the sensor to work out what to convert when taking reading. I should probably have put in more readings to help make it more accurate but for my needs this will suffice.

Install the sensor

Happy that I had reasonably accurate readings it was now time to install the sensor. Luckily for me my power meter has the output cables easily accessible. It was simply a matter of installing the CT Clamp around one of the cables and then powering on the sensor.

I also 3D printed the case for the Wemos and adaptor board to keep everything neat and safe.

CT installed Sensor in 3d printed case

Within minutes I had data flowing to Home Assistant. All that was left to do is add it to the dashboard.

Home Assistant Dashboard Widget

I chose to use the Gauge type widget for this and will adjust the markings of the green, yellow and red areas as I monitor our usage.


This was a really fun little project. For under £20 I now have a gauge of how much energy we are using despite having an incredibly old analog power meter.

This project hit a lot of areas: soldering, 3d printing, software, hardware and a little bit of potentially dangerous electricity. Perfect mix for tinkering!

I hope to make a few more dashboard widgets translating the power usage into monetary value to give us a better sense of how much things cost to run. This will hopefully help us as a family adjust our behaviours a little to save some money (and perhaps the planet!).

If you give this a go be sure to heed the warnings and let me know in the comments how you get on!

Happy tinkering!

comments powered by Disqus