Freesteel Blog » IOT current sensor needs

IOT current sensor needs

Thursday, May 18th, 2017 at 4:25 pm Written by:

We’ve had fun in the past updating the software on the Sonoff S20 mains adapter plug which has a relay switch and an ESP8266 with enough power to run MicroPython and connect to your WiFi, but I realized that we had to go further.

Not only is the software on these mains plugs inevitably out of date for your latest networked IOT needs, requiring you to immediately replace itin order to make it do clever things, but the microcontroller itself won’t be any good. What if you want to use a Raspberrypi, an Arduino or an ESP32?

iotcurrentcircuit

So I got Tom to design a cheap componentwise mains switch with four wires: Ground, 5V power (good for most microcontrollers), Switch-Pin (to throw the relay, which works with 3V), and Current Flow (an analog pin).

Don’t worry about the voltage, I said. We know what the voltage is, on a cycle between 0 and 240V which we can sample and add up.

Turns out it’s not quite so simple.

iotccomputer

The ACS712 current sensor reads 2.5V with zero current and goes towards 0V and 5V depending on the direction and magnitude of flow.

I tried it with the fan and the desk lamp.

iotfan

Fortunately we have an oscilloscope in the hackspace.

iotfanscope
At first I didn’t think it was working, but then it turned out that these devices don’t draw much current. You can see the shallow A/C signal.

You get a proper big sine wave when you plug in the kettle.

And then you get lots of spare hot water and brew yourself a cup of tea.

I found an electric drill on the proxxon mini mill

iotcdrill

And its trace involved these little humps in either direction.

iotdrillscope

It’s almost as if it’s only bothering to draw current when the mains power goes above 150V.

Here is the trace from the computer power supply and the LCD monitor.

iotccomputer

This seems to pick up current only when it goes below 20V on the return to zero part of the cycle, like it trims off just the tail of the A/C cycle and blocks the rest of the flow. I guess if it was in a 110V power supply it would take a bigger chunk of it.

So that shows I was completely wrong. We need to know the voltage, or at least have an interrupt pin the fires when it crosses the zero threshold, wherein we can recreate the cycle using a sine wave.

Annoyingly an ESP8266 has only one analog input pin, so we’d need an additional analog to digital converter, but the interrupt pin idea, or one that is up or down above a certain voltage would do the job at the minimum.

It does mean we can form an interesting signature of each of your devices.

Most electronic devices with switch mode transformers are going to have a fairly consistent pattern of chopping out the waveforms (I wonder what the consequences of this are on the grid), but something more complex like the washing machine will have heating, pumps and spin cycles which ought to be distinguishable.

We can put the whole thing into a single package with a modern ESP8266 microcontroller with its 4Mbs of flash memory to keep records in order to find out what’s going on. Smart meters should mean you don’t need to write anything down.

Just plug it in, say what it is, and it will build up a table of what it is. Even saying what things are is a pain, so put a disposable RFID onto your appliances and wave the smart socket at it before you plug it in. This product does all the thinking for you and builds up a dashboard of your energy consumption portfolio rather like your pension investment plan — except in this case the numbers are real and you can do something about them. It’s not some fictional investments that are going to be stripped from you at the next engineered crisis in order to cover up for the fact that the whole system is bankrupt.

I mean, goddamnit, why is it easier to find out the stock trading price of General Motors Series Z shares in Chicago than the total electricity use of my washing machine on a full cycle? What kind of a misplaced set of priorities do we have here. Let’s get this thing working.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>