Hi, I’m planning to build an energy meter to calculate the power consumption of my home (16A maximum at 230V) using an ESP32 connected to Home Assistant with ESPhome. For measuring current, I wanted to use a CT clamp, like the SCT-013, connected to my ESP32 following this schematic (or something similar):
When it comes to calculating the power consumption in Watts, reading online I found out that there are two different approaches to this:
Configure the the CT clamp in ESPhome following the example (CT Clamp Current Sensor — ESPHome) and using another power meter and a load calculate the linear calibration values for getting an amps reading from the CT clamp; then multiply the amps by the voltage (230V) to get Watts
Other than the CT clamp, connect to the ESP32 a small transformer to measure the grid voltage as explained in the guides by Open Energy Meter (Measuring AC Voltage with an AC to AC power adapter — OpenEnergyMonitor 0.0.1 documentation); then, using Emonlib integrated in ESPhome, calculate the real power taking into account the power factor, that this library is able to calculate
The first method seems to be way simpler to make than the second one, both for the software side and for the electronics, because the circuit is not connected to the mains voltage; due to this, the first option would also be a lot safer, which is not bad for something that runs 24/7.
My question is: as I don’t need a super precise measurement, but only a rough estimate of the home power consumption, is the first method “good enough” in terms of accuracy? Or do I need to use the second method to get some usable data?
If you have any other suggestion from your experience regarding this kind of project, let me know.
If you don’t have the electronics knowledge and don’t want to build a test bed with dummy loads (resistive, capacitive, inductive), just buy something like a Shelly EM.
Seriously - it’s not worth the risk, nor the hassle. I say that with an advanced degree in microelectronics and software engineering - and a Shelly EM in the distribution board.
And yes, I know a CT clamp should be galvanicaly isolated, but then there’s powering the ESP, and clamping transients in kit that could be mounted inside switchgear.
If you must buid you own, use a dedicated power measurement chip. These are cheap as they are made in thousands for your energy supplier’s meters and include many clever calibration and linearisation tricks. Look at firmware like Tasmota and the devices they support for suggestions.
Another vote to shelly Em. Reliable and precise. No hassle, no calibration…
Nominal 230 voltage might be anything between 200 and 250, without measuring it together with current, you have very rough estimate of consumption.
I think I will abandon the idea of making the whole circuit on my own, as it seems to be quite difficult. So I have found online the quite common PZEM-016 module, that includes a chip that measures both voltage and current (with a CT clamp) and calculates real power on its own. It seems like it can be interfaced with the ESP32 and with ESPhome using a RS485 to TTL converter. All of this would cost around 1/3 compared to the Shelly EM, as I have a single phase circuit (and so I need only one PZEM module). Do you think this would work better? More importantly, in your experience are these modules safe? Consider that I would add both a fuse and a thermal fuse to the mains voltage input of the PZEM module.
Watch BigClive on YouTube and his adventures in reverse engineering to see the very mixed bag of cheap modular PCBs. Some of the USB chargers scare the hell out of me!
The quality of pre-made PCB modules varies dramatically from “can be made to work” to “likely to explode”.
Some modules are reference designs from a datasheet, some are copies of copies of copies - the latter can be missing rather important parts as the final designer had no idea of the original circuit.
My most hated example was a 12V 4x relay board - ESP12F looked good, but some moron copied the design with an I/O expander chip, and didn’t bother to program the I/O expander creating £10 eWaste that never ever could work (no, not the ESP firmware - the unobtainable ST uP used as an expander to save $0.01).
I’ve bought many cheap PCBs as they can be easier than making something yourself (240V mains example - made safer with battery isolation), but consider the time needed to get them working - the only available datasheet might be from a design three copies ago, so doesn’t line up and you waste half a day.
So, for a quick test rig, with additional safety precautions - proceed with caution.
For a device which is hard-wired and running 24x7 - save yourself the heartache and buy a Shelly EM!
It’s not just the risk, it’s the time you’ll waste.
(And I say that just after replacing a Tuya CB3S with an ESP8266MOD on an IR Blaster and spending half a day messing about with strapping pin 10k resistors to get the new micro to boot reliably. Sometimes it’s fun; sometimes it isn’t!)
I will consider buying the Shelly EM. After searching a bit online, the PZEM module seems to be not perfectly safe to use, especially as it would work 24/7.
Ah, yes - anti-tracking PCB slots and MANDATORY seperation distances.
“We’ve heard of them!”
Y1 and Y2 capacitors are another regular “value engineering” short-cut that works for a while, until it doesn’t (and the output ground floats up to 240V with the case of the charging phone attached to it…)
There are plenty of threads in the pzem devices on this forum, although I haven’t seen any for a while. Possibly because devices like the Shelly EM have come on the market.
There may be other (cheaper) Shelly devices for single phase.
I wandered here looking to make my own meter, not because there is not enough of meters available on the market, but just because I need to use smaller coils (small space). They don’t even need to be openable, I can use solid coil like chinese 5A/30A ones, and unscrew the wire to put them on.
As you seem to know your stuff - would it be possible with i.e. this shelly module, or zigbee meters that come with (way) bigger CTs, to use them with small coil, and re-calibrate? Is the math on this part complicated any way, or is that linear?
…unless with changing the coil I’d need to change the “burden resistor”… this would complicate the thing.
Be clear about your requirements and you will likely get a better response.
There are MANY choices that meet different price points, accuracy, voltages, currents, size, etc.
What problem are you trying to solve and what data do you need to solve it?
I started my journey of measuring power almost 30 years ago with a full-size 200A meter. It actually provided actionable information about very small loads. You generally don’t need very high absolute accuracy. Making a decision about something that uses 20W is likely going to be the same if it shows up as 5W to 40W. Finding out which thing is drawing power is easier when you have more data points, but it is possible, but harder to figure out with a single meter.
I currently have about 35 channels of information and plan on adding more. I don’t really need more, but I am curious enough to want to do something eventually.
Hi @neel-m I’m a bit of a data junkie with a pinch of control freak, so an intuitive response to “What do I want to meansure” was “EVERYTHING!” which is unreasonable of course
In general, I’d like to have a “telemetry” on each socket or direct grid attachment point in home 230V 3 phase installation. This has to be scratched as unachievable, and, for a sane person, really unnecessary/overkill.
Conclusion of the fantasy above is to get down to earth, take a look at breakers/switchboard and decide what to measure. Some devices, particularly those which pull most current I have already connected with zigbee smartplugs so got that checked out. Good candidate for measurement with CT in breaker cabinet would be high draw devices connected directly to the grid (no socket) - induction stove and AC units. The latter would be particularly nice, as this would give me the state of the compressor which is not available in my AC integration.
This can be easily solved with currently available 2 channel CT meters, however my problem is tight space in the breaker cabinet [pic.1]
I do like how to wires are run, and as 2.5sq mm they are not that easily bendable, so I’d like to avoid squishing in there the 80A CT that come with most of these meters. I wasn’t able to find meters with smaller rated clamps… that’s why I thought about making own or replacing the CTs in a market available one.
I agree with that conclusion, but if you are here you are not most people. The article is still worth reading, since the reality of it is the data is generally very boring and the novelty of it wears off very quickly.
I still have the tube of power meter ICs that I bought more than a decade ago with the plan to make my one multi-channel power meter. That project is likely never going to happen.
Generally the big loads are the major contributors to your energy bill. But don’t underestimate the contribution of your “vampire”/always on loads. These are the things that are on 24 hours a day. I have 200-300W of them. Finding all of them is challenging, but can be done by only measuring the mains. More channels makes it easier and makes the math for ongoing usage easier.
So start with measuring the mains and give it a week/month to see if you really want to spend so much time/money on learning more.
Almost 30 years ago I was part of a project that was one of the first demand-side management programs and involved measuring power in people’s homes. I remember the thrill of seeing the real time data streaming in and seeing the difference between homes the first time we got it working, one cold Sunday morning. There are still some exciting moments now, but they are rare. Mostly it is just boring data that I don’t even review, but it is there if I ever want to see it.