DIY Home Energy Monitor & CT sensors explained

DIY Home Energy Monitor & CT sensors explained


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!

21 Replies to “DIY Home Energy Monitor & CT sensors explained”

  1. Yes! More videos like this! I love tinkering with IoT projects, and am constantly looking for inspiration. Keep up the good work!

  2. 3:18 But it's AC and the voltage is fluctuating between +325V and -325V. Do you assume that it will average out in the long run?

  3. Hi! You are awesome!! Can you pls make a video explaining sql injection?! Ty! 🙏🏻👍🏻💪🏻

  4. Really wish there was a way to use a clip style sensor on an individual appliance cord to determine if it is on or not. From my readings a CT would require cutting the cord to clamp one of the conductors, is there another way?

  5. Very cool project!
    You might also check out IOTAwatt. It’s an open source 14 channel energy monitor using the ESP which does real power with a cube transformer for a voltage waveform reference and also works bidirectionally for solar generation.
    I like the one I have, and keep meaning to make a smaller version in KiCad adding temperature sensors to guard against freezing in my solar pump house.

  6. Hey nice work! Im planning on doing a similar project on my channel soon. You bet I'll take a look at your code!

    A small correction though at 5:22 I think you meant apparent power. You cant reliably measure true power without taking into account the voltage, it should be fairly easy for you to implement this using a voltage transformer.

  7. 4:08 hand went out of frame! Low quality content! Not subscribing!

    Just messing! Great project! Congrats on your new subscriber! (me.)

  8. I've built my own on a solder board using an arduino nano. Problem is I have to poll it using python/serial and inject into influxdb. My next version is going to be the esp32 as well. But I am going to use the ADC1115 to get better resolution, 16-bit vs 12-bit.

    Nice project build. I love the idea of the usage over time in the way you store the data and figure out the "Always On" devices and account for them.

    To get real voltage, you could add AC circuit that reads the voltage directly, then rectifies and outputs to power the esp. But you'd need to have an AC power brick, as the DC ones have been smoothed and/or are done digitally with no transformer. On my line, over the course of a day, my voltage can swing from 125VAC to 116VAC (US power), which can make big difference on power consumption. Right now I'm actually using 2 power bricks as it's still in prototype form.

  9. Very cool project!
    Can I use it on a power bar (which has 3 wires insulated) for example? or only on the hot wire of the entire house?

  10. What should we do if we have a 3 phase system? We can add 3 CTs but how do we calculate the total power used? Do we just add the power of individual phase? And what is the value of resistors you have used?

Leave a Reply

Your email address will not be published. Required fields are marked *