Wemos D1 mini and power clamp sensor

Hi all
I wanted to add the power draw of my newly installed heat pump into Home Assistant and I got inspiration from sources like

and

Seemed pretty basic I thought and I just got delivery of ESP8266 Mains Current Sensor - Wemos - Current transformer - SCT013 - 100A/50mA | eBay and SCT-013 15/20/30/50/100A Non-invasive AC Current Sensor Split Core Transformer | eBay but after putting the hardware into place I cannot understand what I’m seeing.
The A0 (analogue) reading never changes in Home Assistant. It stays at 0.521 regardless if I put the clamp around a cable with a steady 150W draw (as read by a Shelly plug on the wall outlet) or if I remove the clamp and put it on the floor. The LED on the Mottramlabs sensor board is lit when the Wemos has power and I have removed the 22K resistor as instructed by Mottramlabs since my clamp is the 50A/1V “voltage sensor” and not the current one.
My sensor code is below and is copied from esphome.io

sensor:

  • platform: ct_clamp
    sensor: adc_sensor
    name: “Measured Current”
    update_interval: 10s

  • platform: adc
    pin: A0
    name: A0
    accuracy_decimals: 3
    id: adc_sensor

I’ve had some bad luck with my recent orders into my IoT world and I would really hate if this was another one. Can anyone shed any light on what I’m missing here?

Regards
Fredrik

Lets start with the easiest mistake to make with current clamps.

You said “It stays at 0.521 regardless if I put the clamp around a cable with a steady 150W draw”.

Is your current clamp over the whole cable, or just one wire from it? If you have the whole cable through the clamp, currents cancel each other out and you can’t see any difference to “empty” clamp.

So, you need to split the cable to have only phase or neutral go through your clamp. Be careful with it.

Oh. Dear Lord, I have the whole cable with load, neutral and ground in the clamp. Is this even possible to measure a 3-phase cable with a single clamp?

/Fredrik

“Shelly plug on the wall outlet” and “the whole cable with load, neutral and ground in the clamp” says you are in a 1-phase environment. So no 3-phase in this case, that would be 5 wires.

1-phase measurement is easy with one clamp, either line or neutral through the clamp and your setup is done. I made short extension cord with phase separated from neutral and earth wires to be used with clamp meters for use as a tool, but similar setup might be safest and least destructive for long time use too. Or you could get a ~junction box big enough for the whole measuring setup, cut short extension cord to length and connect it back together in the box with one wire through the clamp. If the maximum current ends up being under half of what your clamp/microcontroller/other bottleneck is, you could loop that same wire second time through the clamp to double the current “seen” by the clamp and then divide the result with the amount of times the wire goes through. That way you can maximize the resolution and see smaller differences in the load.

3-phase would be a different story. First you need to find out if the load is symmetrical enough to just measure one phase and multiply that result by three. There are a lot of fully or nearly symmetrical loads where that would give good enough result, but for example 3-phase kitchen stoves are basically multiple 1-phase heaters stuck in a single frame and therefore to get even close to measuring those you would need three clamps.

Hi Ville
You are correct. My initial testing and attempts at calibration was done with a 1-phase outlet, but my end goal was to monitor a 3-phase cable to my heat pump. Since my lst post I have opened the front panel of my heat pump and I’ve put the clamp around the three lead cables before they connect to the heatpump and so far I have a raw input from the clamp which I can use for calibration.

/Fredrik

To my knowledge there is no "power clamp sensor" like the title from @TheHoff states.

What does exist are current clamp/coils - that they are not sufficient for any serious power metering stuff (AC, when PF≠1) should be widely known.

And didn’t search the forum to see what mileage people have trying this sources of inspiration?

Or long story short :point_down:

Might want to take a shortcut and use a quite accurate but still very affordable solution which does real power monitoring mentioned here: :raised_hands:

Power factor isn’t that bad for the clamp measurement by itself. When measuring just one device, you should be able to calibrate your setup to show meaningful results, if you know what the current or power levels should be.

But. If you try to make one clamp to rule them all, different loads will behave very differently and the results might be anything. Power factor is just a small part of it, harmonic distortion is what really screws you.

I should have all the parts for that esp+clamp setup at hand, I’ll need to try it some time to see myself how bad it gets. I do measure a lot of things with clamps at work and often there’s no need for precise power values, so I did not even thought that it would be relevant to others. You’re not billing anything with these results anyway, it should be more at the “nice to know” level. Matthias Wandel (on youtube) “measured” current by attaching temperature probe to a power cord and was happy for the results, so just lowering your expectations might get you the data you actually wanted…

Biggest problem with plain esp8266 as a analog data collector is its 10 bit adc. 1024 different values should be used very wisely and that might be hard to match to different loads.

At the same time? If the load is symmetrical, those cancel each other out, it should be only one phase through the clamp.

So, I had to try that esp+clamp home made setup from the op:s first link (schematic at step 3).

That schematic has a bug though. That voltage divider works like it should, but the wire from it to the current clamp is in wrong place. It should be in between those resistors, not at the top.

I did not know that esp8266 analog input is that fast. Had to add delays (semirandomly selected 35 us) between samples to fit couple mains waveforms in 500 value array, so it would show nicely on arduino ide:s serial plotter.

Now I could just get the difference of max and min values from that array and calculate some ratio to get rough amperage values out of it. Its not power, but like I said earlier, its good enough for many situations. Actually that array is not needed for this at all, just read that analog input and save min/max for a while, send difference out and start again. My coding skills run out way before waveform analysis, that wave just looked nice while testing.

As this kind of homebrew setup needs calibrating against better measuring devices or known loads anyway, it is possible to remove internal resistors from those chinesium voltage output clamps (or you could just buy ones with current output) and use your own resistors to match your load and maximize measured resolution. I said earlier that looping that measured wire through the clamp several times helps, but changing to larger resistor values might be easier. We do that multi-loop thing a lot with commercial current transformers in electrical cabinets, so it was my first choice.

Now that i have tested this with one clamp, my old and crazier ideas start to rise again. I already have analog multiplexer (16->1) chips and about 10 of those same clamps, so i could build a tool to measure ~10 wires at once for troubleshooting purposes. It might even be possible to time several sample arrays together to get power values, but again, I don’t know how to code.

I was going to apologize for my ot-rant, but then I saw that thread topic again and it seems that I’m still quite literally on right tracks. That rarely happens to me.