# Computing stuff tied to the physical world

## Sensing power consumption

In Hardware on Sep 11, 2011 at 00:01

A small exploration of a circuit which went nowhere…

I’ve been looking for a low-cost way to detect whether an electrical appliance is drawing current. There would be several uses for that, from power-saving master/slave power strips, to helping figuring out what’s going on in the house by measuring the central meter, as I’m doing already.

Here’s my original (naïve) line of thought:

• optocouplers are a great way to stay out of AC mains electrical trouble
• many units will still work with currents down to well under 1 mA
• all I want is detection – is a device ON or OFF?
• the rest can be done with JeeNodes, wirelessly, as usual

Here’s the (pretty silly) first step, in series between power outlet and appliance:

A resistor to limit the current, and the opto-coupler to “light up” and produce a signal in a galvanically isolated manner. But don’t get your hopes up, this setup definitely won’t work!

• First of all, the appliance will stop working, if the resistor is in the 100 kΩ range.
• With resistance values much lower, the resistor will become a heater and self-destruct.
• Besides, even a 100 W load will draw 0.5 A or so… way too much for the LED.
• There’s also a small problem with the voltage being AC, not DC, but that’s easily solved with a diode.

It’s a pretty useful mental exercise to work through this and understand how voltage, current, and power interact. If you’re totally lost, you could check out this series of posts and this link.

Sooo… could this approach be made to work?

In this case, an indirect demonstration that it can’t possibly work is actually easier to argue: suppose there were a circuit with the opto-coupler’s LED in series between outlet and load. It only needs to cause a voltage drop of about 1.5V to get the IR led inside to light up. Now suppose the load draws 1000 W, i.e. nearly 5 A. Big problem: (due to P = E x I) the power consumed by the opto-coupler would be 7.5 W … an excessive amount of heat for such a tiny device (apart from the sheer waste!).

Even some form of magical “power reduction” would be tricky, since I do need to detect the power-OFF case, i.e. power levels down to perhaps 0.5 W of standby power consumption for modern appliances (some even less). For 220V, 0.5 W corresponds to an average current of only 2.2 mA.

Maybe there’s a clever way to do this, but I haven’t found it. Something with a MOSFET, mostly conducting, but opening up just a little perhaps 1000x per second, to very briefly allow the LED in an opto-coupler to detect the current (with an inductor to throttle it). Heck, an ATtiny could be programmed to drive that MOSFET, but now it’s all becoming an active circuit, which needs power, several components, etc.

The trouble with AC mains is those extremes – on the one hand you need decent sensitivity, on the other you need to deal with peak loads of perhaps 2000 W, with their hefty currents, and where heat can become a major issue. We’re talking about power levels ranging over more than three orders of magnitude!

Of course there is the current transformer. But those are a bit too expensive to use all over the place.

Another option would be to use a regular transformer in reverse, as in this article. With a little 220 => 6.3V transformer, the ratio would be 35:1. With 5A max, a 0.1 Ω resistor would have 0.5 W of heat loss and create a 0.5V difference, amplified up to 17.5 V. For a 2.2 mA “off” current (0.5 W standby), that voltage would drop to 7.7 mV, which is probably too low to measure reliably with the ATmega ADC. Still.. might be worth a try.

An interesting low-cost sensor is based on the Hall-effect to detect magnetic fields. Because wherever there is alternating current, there is a magnetic field.

With hall-effect sensors, the problem is again at the low end. Keep in mind that the goal is reliable detection of current, not measurement. Now, you could increase the sensitivity by increasing the intensity of the magnetic field – i.e. by creating a coil around the sensor, for example. Trouble is: since those wires need to also handle large power consumption levels, they are by necessity fairly thick. Thick wires make lousy coils, and are impossible to get close to the sensor.

There are other ways. Such as measuring light levels, in case of a lamp. Or heat in case of a TV (would be a bit sluggish). Or vibration in case of a fridge.

Maybe a hand-made 100-turn current transformer would work? That’s a matter of winding some thin enameled wire around a single mains-carrying insulated copper wire.

Hm… might give that a try.

The challenge is to find something reasonably universal, which does not require a direct galvanic connection to AC mains. It seems so silly: an ATmega can detect nanowatt levels of energy, yet somehow there is no practical path from AC power ON/OFF detection to that ATmega?

PS. A related (and more difficult) problem is “stealing” some ambient magnetic energy to power a JeeNode. You don’t need much while it’s asleep, but transmitting even just one tiny packet is another story.

1. I have a vague idea that might work, but don’t have enough expertise to follow it through. How does this sound:

You have a series of optoisolators; the first of them needs approx. 5A to trigger it; the 2nd 1A, the 3rd 0.2A …

If optoisolator 1 is triggered, then optoisolators 2, 3… get bypassed, so you only “waste” the power to trigger Optoisolator 1.

If the current is too low to trigger optoisolator 1, then it runs through optoisolator 2; again if the current’s high enough to trigger this you bypass optoisolator 3.

Does that make sense? I’m not sure if it’s actually feasible or not, but maybe it gives you an idea.

• I’m not convinced that this is practical. Anything with a voltage drop (V) and a current (I) through it is going to consume energy (P = I * V), i.e. generate heat. With passive solutions, a 5 A load will consume at least 7.5 W if it needs to produce the 1.5 V or so needed for an opto-isolator LED to light up.

2. Very interesting views. I think your idea of building your own current transformer makes sense. I had tried to measure currents using the information provided in http://www.instructables.com/id/2-Carabiner-split-core-AC-transducer/ as reference before. Since here we just want to sense the presence of current and not measure it, it should definitely suffice. I got more reliable results by using a Toroid core inductor (I took it off an old SMPS.). eBay has few for a dollar each http://www.ebay.com/itm/5-pcs-Toroid-Core-Inductor-Wire-Wind-Wound-47uH-47-uH-/120620647049?pt=LH_DefaultDomain_0&hash=item1c158d0289#ht_3920wt_952.

3. The little toroid inductors look like a neat trick… After reading this I was toying with the idea of mounting a pipe cleaner in the lathe, wrapping it with some fine gauge coated copper wire (I have a reel or two laying about thanks to my father) and then wrapping the finished construction round the conductor to be measured/tested.

I’m just not quite sure how I’m going to spin the pipe cleaner without wrapping it up into a knot. I do have a free spinning centre, but I don’t think it’s going to be free enough for the thin bit of steel wire in a pipe cleaner. I think I need a lathe with both ends driven… Damn… I shall have to keep my eye open with a slightly thicker, but not too stiff, source of steel/iron… Or I guess I could just try it without any attempt at a ferrous core and just wrap it round a bit of 1.5mm copper cable.

Why does the field have to be so awkward and go round the conductor in concentric circles, it would be so much easier if we could just wrap a coil round the conductor without having to twist everything 90 degrees to cut the field!

4. Contactless solution is the best way … you do not have to modify your installation, more safe and easy maintenance.

arduino-ready hall effect sensor :-) http://www.pololu.com/catalog/product/1185

http://www.arduino.cc/playground/Main/CurrentSensing

5. How about using the approach of OpenEnergyMonitor? The sensing circuit uses an Efergy commercial clip-on CT sensor. The sensors can be bought separately and cost around 10 euros.

http://openenergymonitor.org/emon/node/58

• Cost…

6. just an idea : how about just sensing the heat ? you said you just wanted on/off detection…

• Definitely an option. It’s slow, though – correlating it with changes in total current consumption at home will be a bit more difficult.

7. How about having strings of forward-biased power diodes in series with the mains to get a small, more-or-less constant, voltage drop whenever there’s any reasonable amount of current flowing then sensing that voltage drop with an opto-isolator? One string in each direction for AC. Something like:

http://twitpic.com/6jc014

Might need another diode or two in each string to get enough voltage that the current-limit resistor in series with the opto-isolator LED can be meaningful. Schottky diodes would have the advantage of less power to dissipate in each individual component but you’d need more, of course.

Not sure if there are opt-isolators sensitive enough to detect 2 mA though I wouldn’t be surprised if there are, LEDs don’t need much current to produce some light.

8. The Rogowski coil might be an interesting alternative which has lower costs than the CT:

http://en.wikipedia.org/wiki/Rogowski_coil

The wikipedia article even mentions a low cost planar variant that could be achieved on a PCB.

William Koon wrote an interesting paper comparing different current detection techniques:

http://application.emcelettronica.com/analog/16174506155607IIC_Paper

The low cost shunt method which is also mentioned seems to be popular in consumer plug consumption meter appliances.

• Thanks – will look into it!

9. and what about a modified simple AM radio. it is easy to pick up 50hz hum. This idea, with the coil wrapped around the AC wires : http://sci-toys.com/scitoys/scitoys/radio/meters.gif might even help you harvesting energy. try google BEAM robotics for simple energy harvesting circuits.

10. Mailed you before on how your thoughts seem to march just days ahead of mine. I’ve been wondering about the same problem last weeks. Thought about having a piece of 220V “montage draad” in the drill, covering it with a few layers of very thin wire and link that very bare bones transformer to any pin of the JeeNode. Then see at what current level there is an interrupt generated (ie. an appliance plugged in). The JeeNode can then switch to actively do some sensing. As long as the appliance uses no power, there is no magnetic field, so no interrupt. Once there is an interrupt, JeeNode could do some ADC or other energy wasting job. Only then, rectifying migh require wasting a volt or 1.2 over a diode… Heck, even parasitically charge a supercap to keep JeeNode going. There must be some way to switch off the electric tooth brush after charging :-)

11. Hello,

I know this is in french, but this link explain how to have a led on 230 AC with only a few components (no big resistors) http://www.sonelec-musique.com/electronique_realisations_alim_led.html

• Thanks for the link (French is fine). But unless I’m missing something, this only shows a transformer-less power supply (which, to drive an LED at 10 mA, consumes over 2W). I don’t think it helps with the task of finding out whether an appliance is on or off, since there will always be power applied to it. I have to measure current by placing the detection circuit in series with the appliance.

12. I’m testing something similar. The way I do it now is to use “signature recognition”. I found out that most electric devices have not only a recognizable electric power consumption, but for many of them, a certain pattern can be identified when they turn on. So I want to rely on a home energy monitor (based on http://openenergymonitor.org/emon/) and programs to recognize the patterns. I use 5 energy sensors. 2 on the mains entry and 3 on different breakers for precise monitoring/pattern study. It would be, of course, more precise to have one sensor per breaker, but much too expensive. The problem, again, is for very low power devices. I decided to not monitor them because they are too hard to identify on the mains sensor. But if they could be made to send a recognizable “pulse” on the wire to the breaker, that could be analyzed. I’m thinking of having a coil wrapped around the wire going to the breaker, either on a Kill-A-Watt type of interface or directly on a power wire. I think that it would be easy to have a simple tune-able circuit that used a transistor (or a 555 oscillator) to induce a recognizable signal on the coil, to be picked up by the monitor. After all, isn’t it the way cheap “mains network” systems work?

• Sounds like you’re on to something. Would love to hear how that pulse idea works out. I’m still hoping to find a way to detect power draw at a low cost. Main ones I’m after are those intermittent users: fridges and boilers. They should be easiest, since they do draw a fair amount of current.

• This Site http://ubicomplab.cs.washington.edu/wiki/ElectriSense and the refferences there in will give you a lot of information on that topic.

• I just made some tests. The resolution for the entire home monitor (mains sensors) is about 5 watts. I am still testing the resolution for the mains sensor, but it seems to be about 1%. I can detect a little 13w lamp turning on and off on my desk while the system senses about 1000 watts for the whole house. The problem then is to have an “inventory” of devices power signatures to be able to differentiate them. I haven’t been able to find a circuit using a 555 timer to inject the FM signal into the house wiring yet. Any idea?

• @timm: Very interesting reads. This is in line with was I’m trying to do. The last paper states that it is virtually impossible to detect loads of less than .25 amps. For those, we might need a simple circuit to “create” a detectable transient. A “noisy” switch…

13. Here is a blog of a dutch guy building a setup to check if a 220v device is on or off. It for a arduino board but should be to hard to change it from 5v to 3v.

http://www.dannyvanmaanen.nl/?p=242

Oh here is the overal project together with 220v relais switch and an/off check. http://www.dannyvanmaanen.nl/?p=482

• Thanks for the link, Barry – I’m not able to track everything going on out there, so I really appreciate tips like these.

But again – this doesn’t sense current but voltage. With an appliance plugged into mains, I don’t want to know whether it gets power (it always does), but whether it draws power.

14. This unfortunately is a difficult problem and a simple (or even not so simple) optocoupler circuit will not work.

Doing your own transformers is problematic since the magnetizing inductance of the primary winding ruins the sensitivity of the transformer. This means you want: lots if secondary loops and (more then one primary loop and/or a nice toroidal core).