Electric Imp and Non-invasive AC current sensor


did anyone already used a electric imp and a Non-invasive AC current sensor (SCT-013-000) to build a energy monitor?

would be nice to see some informations and get a good start… unfortunately i have a tri-phase power supply.


Is the sensor you mentioned the same as this?

You can purchase a non-invasive one here:

That converts the passing AC amps to mV … only $10.00

Use some RC circuits for filtering and calibration.
In the least, a resistor across output to convert to mV.
The datasheet shows a 10 ohm resistor:

There is also an Arduino example … maybe that might offer some clues?

No but I’ve used LEM split core CT’s which give a 0-10v feed to a resistor divider into an analogue in to the imp These bit.ly/XDH0r6 are professorial 2% accuracy and about 50/70 GBP . The cheaper probes have a 7/10% accuracy so on a 80/100 amp phase you can be some way out & they aren’t that linear either.

3 phase isn’t an issue you just need three probes and sum the current in the imp x your mains voltage (230v for most Europe) to give you Kilowatt reading. For better accuracy you can measure your supply voltage with a multi meter and use that as the multiplier.

Energy is expressed in kWh killo watt hours So if you sample every minuet after 60 reading you have your your kWh reading best to sample at a faster rate though.

Thanks for all the informations. I will first try the cheap YHDS SCT-013-000 because they a tested with a very good result http://bit.ly/HtKtAr.

At openenergymonitor, i see a lot of good informations to begin building a Power Meter with the eImp.

Ayone knows, how accurate the voltage of the eImp is (“hardware.voltage()”)?

I never thought about the accuracy. You’re correct … that would be important.

hardware.voltage() measures the SoC’s internal voltage reference with the ADC, then uses this reading to determine what the external VREF (supply) must be.

I’ve not done the maths on the theoretical accuracy, but looking at the 3v3 with a fluke meter and using the hardware.voltage() call returned results within ~20mV when I tried it.

i builded the following circuit:

and useed the oEM Code to get any usefull values. But i think at some point i got lost. All values i get are useless. Here are my transfered Code for testing:

function test()
local sumI = 0;
local Irms = 0;
local samples = 1480;
local lastSampleI = 0;
local sampleI = 0;
local lastFilteredI = 0;
local filteredI = 0;
local sqI;

for (local n = 0; n < samples; n++)
lastSampleI = sampleI;
sampleI = hardware.pin2.read();
lastFilteredI = filteredI;
filteredI = 0.996*(lastFilteredI+(sampleI-lastSampleI));
sqI = filteredI * filteredI;
sumI += sqI;

I_RATIO = 90.09 * (hardware.voltage() / 65535.0); // CT Sensor: 2000, Burden: 22 Ohm - 2000/22 = 90.90
Irms = I_RATIO * math.sqrt(sumI / samples); 
sumI = 0;
return Irms;


i only edited the needed parts for my CT Sensor and to work with squirrel.

Arduino Code looked like this: http://pastebin.com/DdUhfDka

Any advice on this? :-/

I have the same exact code with one difference:
This line
I_RATIO = 90.09 * (hardware.voltage() / 65535.0);
should be
local I_RATIO = 90.09 * ((hardware.voltage() / 1000.0) / 65536.0);

Hi osherl,

thx for your answer.

“1. Squirrel doesn’t like this: sumI += sqI; change to sumI = sumI + sqI;”

  1. i using this on another firmware without problems.
  2. i forgot to say that i defined the I_RATIO a little bit earlier. I see you divide the Voltage to mV, but why you are using 65536.0? I think 0 is the first step and it should be 65535.0.

I also see my calibration value is a little bit wrong. It should be 90.90 because 2000/22 = 90.909090909 but thats only fine tuning.

Does your Code work? Is it possible to show me a picture of your breadboard?


What is a “burden”?

it’s a ordinary resistor used to burden something so it becomes a burden resistor. :wink:

The pin read returns a value between 0 and 65535 (representing voltage 0-3.3) so we divide by 65535.0 to get the actual voltage.

yeah, but you said 65536 instead of 65535

so i think it was a typing error.

Yes, it should be 65536. 0 is 1, 1 is 2 … 65535 is 65536.


Did you build the circuit? Would be nice to see a picture of it. Maybe i got some wiring wrong. :-/

edit 26.03.13: i rebuilded the circuit without luck…

it still doesnt work. i think i should order a arduino uno to see what are the differences.

yesterday i tried the circuit with a arduino uno and it works like a charm. :)>-

Now i am a little bit confused what i did wrong with the eImp.

Hugo? someone else? any advise?


I had successfully tried the CT sensor with the arduino to measure main current. This time however when I try the code and the circuit with an arduino, I get strange readings. Picture here

. It seems that the voltage alternates between two values. What have I done wrong? How can I get steady readings?

It should work. I don’t see your hardware.pin2.configure statement. What did you use?


i use hardware.pin2.configuration(ANALOG_IN);a little bit above the function.