Hi everyone!
This is a bit of a special Simply Explained video with me talking about my DIY home energy
monitor and how I built it.
You see I was interested in measuring how much electricity our whole apartment was using
and I wanted to collect that data over time.
Now, of course, I could just periodically write down the numbers on my meter.
But that’s not cool, so instead, I wanted something automated and connected to the internet.
So I bought a little microcontroller and a CT sensor to make kind of like a Fitbit for
my electricity consumption.
And yes, I do realize that there are commercial products available that do the same thing,
but these are often expensive and require a subscription.
Besides, doing it myself is a fun exercise to learn about microcontrollers, the cloud
and CT sensors.
I started by ordering all the required parts from AliExpress.
That is a microcontroller — I choose the ESP32 —, a CT sensor, a display, a few resistors,
capacitors, protoboards, and some female headphone jacks.
The total cost of all of this was a little over €20.
You might wonder why I bought headphone jacks?
Well, that’s because the sensor I bought uses a 3,5mm headphone jack and I thought
it would be nice to integrate that into a case.
More on that later!
Once everything arrived I soldered this little circuit onto a protoboard.
It basically connects the CT sensor to the microcontroller, cleans up the signal and
makes sure that we can safely read out its measurements.
The sensor is a little clip that goes around the main wire of your house.
They are called non-invasive.
You don’t have to cut any cables to insert a special sensor in between and that’s a
good thing because messing around with high voltages can be dangerous and, at least here
in Belgium, requires you to have it reviewed by a professional.
But you might wonder, if a CT sensor is not in direct contact with the cable and there
is no electricity flowing through it, how can it still sense how much current goes through
the cable?
Well, this wouldn’t be a Simply Explained video without some juicy explanations.
The first thing you need to know is that when an electrical current flows through a copper
wire, it generates a magnetic field around the wire that is proportional to the current
flowing through it.
This was first discovered in 1823 by André-Marie Ampère.
Now CT stands for “Current Transformer” and as the name suggests, it transforms the
magnetic field generated by that current into a smaller current.
This particular model goes even further and converts that second current into a small
voltage between 0 and 1 volts, which we can easily measure with a microcontroller.
And again, the output of a CT sensor is proportional.
This model can sense up to 30 amps of current, at which point it will output 1 volt.
If we measure half a volt coming out of the CT sensor, we know that 15 amps are flowing
through the main wire.
Once we know the current, we can calculate how many watts we draw by using Ohm’s law.
Just multiply the amps with the voltage on the grid, which in Europe is 230V.
And once you have that, you calculate how many watts you’ve used per hour which is
the same metric that is used by the power companies to bill you.
Although they use kWh, so you have to divide by a thousand.
So that’s how the sensor works.
Back to the DIY project!
I wanted everything to be housed in a nice enclosure.
So I fired up Fusion360 and this is what I came up with.
I designed a case with a top lid that is screwed into place and has a cutout for the display.
On the side, there are two cutouts: one for the headphone jack and one for a Micro USB
port to power the microcontroller.
And inside the case, I’ve added several standoffs to securely mount everything.
Once this was finished, I sent it to my 3D printer, assembled everything et voila!
The hardware was finished!
Next, I wrote some Arduino code for the ESP32 so that it can read out the CT sensor and
show the current energy consumption on the display.
Having a real-time display is fun, but not enough.
The ESP32, however, has built-in WiFi which means I could just as well send the readings
to the cloud.
To do that I used the AWS IoT service to set up kind of like a chat channel between my
ESP32 and AWS.
The energy consumption is then measured every second and every 30 seconds it sends those
readings to Amazon.
Once it arrives there, Amazon writes the readings into a DynamoDB table for safekeeping.
Alright, I’m almost done.
The last step towards world domination — err, I mean energy monitoring — is to make a
little app to visualize the data stored inside DynamoDB and this is where I landed on.
On the homepage, I can see how much electricity is currently being used as well as how much
we’ve used so far today.
I also try to calculate the “standby power” which is the amount of electricity that is
always being consumed by devices that are always plugged in like the fridge and TV.
On the second tab, I can see the raw readings over time and the final screen visualizes
our consumption of the last 30 days.
We’re currently consuming between 4 and 6 kWh of electricity every day.
Neat right?
Okay, but how accurate is this thing?
Well, it should be close to what your meter says but it’s not 100% accurate.
This sensor only measures current flowing through a wire, which is referred to as “true
power”.
It does not measure reactive power.
And there is also some accuracy lost from converting the magnetic field into a secondary
current.
But, in my case, it’s pretty close to the consumption on my electricity bill.
All in all, I thought this was a fun project and in the future I’d like to keep improving
it.
One feature I’d like to add is the ability to connect multiple CT sensors, so you can
keep track of the output of your solar panels for instance.
But that’s for another video!
In the meantime you can check out the link to my blog post in the video description.
It contains more technical details and the source code, should you want to build this
yourself.
And before you click away, let me know in the comments below what you thought about
this video and if you want to see more Simply Explained DIY projects.
If you liked it, hit the thumbs up button and consider getting subscribed.
Thank you so much for watching and till next time!