# Current monitoring with non-invasive sensor and arduino

In this post we will see you to measure energy consumption with a non-invasive sensor: YHDC SCT-013-000 CT and an Arduino.

Disclaimer: Be careful even if the sensor is a non-invasive one, you are playing around high voltage

Total Price: less than \$52

### Needed Hardware.

Arduino Uno

Price: less than \$30 (Amazon)

A Non-invasive AC Current Sensor

Price: \$12 (Amazon)

Mine is a YHDC SCT-013-000 CT 100A max

And some electronics components for less than \$10:

• a 33 Ohm Resistor
• Two 10kOhm resistors
• A 10uF Capacitor

### Understanding the sensor.

Understanding the way the sensor is working is the main difficulty. OpenenergyMonitor website has a real nice article about this sensor:  Yhdc SCT-013-000 Current Transformer.

“Current transformers (CTs) are sensors that are used for measuring alternating current. They are particularly useful for measuring whole building electricity consumption (or generation for that matter).

The split core type such as the CT in the picture above, is particularly suitable for DIY use it can be clipped straight on to either the live or neutral wire coming into the building without having to do any high voltage electrical work.

Like any other transformer, a current transformer has a primary winding, a magnetic core, and a secondary winding.

In the case of whole building monitoring the primary is the live or the neutral wire (not both) coming into the building itself and goes through the hole in the CT. The secondary winding comprises many turns of fine wire housed within the casing of the transformer.”

OpenEnergyMonitor

### Some Physical computing to build the circuit.

#### Current generated by the sensor

The measured current is alternative, and the sensor is calibrated to measure a max of 100A AC. 100A is the RMS value of the maximum current the sensor can handle.

So First of all we need to know the measurable max peak-current

`i(measured) = √2 * i(rms_current) = 1.414 * 100A = 141.4 A`

The current at the output of the sensor is defined by its number of turns (here is 2000)

`i(sensor) = i(measured) / nb_turns = 141.1A / 2000 = 0.0707A`

#### Convert current to voltage

Arduino can only handle voltage (between 0V and 5V) so we need to convert this current into an acceptable voltage. so let add a burden resistor in the circuit.

As the current is alternative around 0 and to maximize measurement resolution, the max voltage at burden resistance should be Max_accepted_voltage / 2 = 2.5V.

Now we are going to compute the better Burden resistor value

`R(burden) = U(sensor)/I(sensor) = 2.5V / 0.0707A = 35.4Ω`

The ideal Burden resistor is 35.4Ω, it is not a current resistor, let use a 33Ω Resistor

Arduino can not measure negative voltage, so we need to add 2.5V to U(sensor) to make the voltage measurable. (between 0V and 5V)

• 2 resistors (10kΩ is good to avoid too many energy consumption)
• The capacitor C1 (10uF) has a low reactance – a few hundred ohms – and provides an alternative path for the alternating current to bypass the resistor.

### Building Arduino Shield.

We are using Analog input 5 from the Arduino to connect the circuit

### Arduino Code.

If you take a look at openenergymonitor.org you can get an Arduino lib allowing to convert the raw data from analog input into a nice useful values.

EmonLib

```#include "EmonLib.h" // Include Emon Library EnergyMonitor emon1; // Create an instance   void setup() { Serial.begin(9600);   emon1.current(5, 60); // Current: input pin, calibration. //calibration is explained bellow }   void loop() { double Irms = emon1.calcIrms(1480); // Calculate Irms only   Serial.print(Irms*230.0); // Apparent power Serial.print(" "); Serial.println(Irms); // Irms }```

To well understand how to calibrate emon1 take a look at openenergymonito.org section Current sensor – calibration theory.

```calibration_value = ( i(measured) / i(sensor) ) / R(burden)
calibration_value = (141.4 A /  0.0707A) / 33Ω
calibration_value = 2000/33Ω = 60```

1480 is the number of sample used to compute a value. More info on openenergymonitor.org

### And the result.

I checked Arduino returned value with a amperemeter.

And Last pictures from where it is placed into the board

### Next.

Next step is to connect the Arduino to wifi network in order expose a Web Service to monitor current consumption.

### Sources.

http://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface

http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor-measuring-current-only

1. There’s a mistake in I(sensor) formula as 141.1A / 2000 = 0.0707A (missing zero). The same applies to 2.5V * 0.0707A = 35.4Ω.

• Vincent Demay

Thanks for the review

2. Damien

Thanks for this article, which is the best I found on the subject. I was looking for a true understanding of how this works and I could clearly understand the clockworks with my basic general knowledge in electronics.

It would be wonderful if you could add a brief explaination on how to choose the capacitor value (capacitance).

3. thieuduc2011

Hello Vincent Demay,
I’m making Project like your project using SCt-013-030 sensor,
This sensor already has a burden resistor (62 ohm) inside, and the voltage output is 0-1V,

I ‘ve connected and made sketch similar to your code (with some different values suitable for my sensor), and i think it’s noway wrong but my arduino uno still get values 0 from A0.

I don’t know why and want to ask you that should i use an op amp circuit to amplify the voltage (ex: 100 times). and if i do that, which functions should i add to emonlib???

Hope you answer my question soon… Thanks

• Vincent Demay

Hi Thieuduc2011,
Did you try to mesure current with another device such as a multimeter to be sure there is current througout the wire? Or you can try to measure output of your sensor to check if there is a voltage. If so, your A0 pin should not stay a 0.
Measuring voltage between 0 and 1V on the A0 pin should be ok. One last question : do your sensor output voltage as a sinusoid between -1V and 1V or it is already rectified?

• Shiu Kumar

Hi

I am trying this but the EmonLib seems to be not for Arduino. Could you please provide the correct library which is working.

Thanks
Shiu

• Aniruddha

Hii Vincent..
will u please guide me that how should I measure a varying AC voltage from 0V to 230V using Arduino… max current is 5A

4. thieuduc2011

Hi Vincent Demay,
Thanks for replying me soon, I ‘ve used a digital multimeter to measure output of my sensor and I got the value very very small: 0.04 A althougth I use my sensor to measure the current throughout the wire connected to supply power to my desktop when it’ve already been running… it can be small like that.

I also use a Oscilloscope to measure the voltage output to A0 pin. it was very small that it seem to be a noise.

And it hasnt change the value when I disconnected the power supply.

I think the output voltage as a sinusoid -1 to 1V

Can you give me some advices now?

• Vincent Demay

Sorry, I wrote down a new comment instead of replying, My response below.

5. Vincent Demay

Hi Thieuduc2011,

if your sensor is this one http://garden.seeedstudio.com/images/b/bc/SCT013-030V.pdf, it means it is a 0A to 30A sensor with 1800 turns and an integrated burden of 62 ohm. Your desktop should consume something like 1A or less. So:
i(measured) = √2 * i(rms_current) = 1.414 * 1A = 1.41 A
i(sensor) = i(measured) / nb_turns = 1.41A / 1800 = 0.8mA
v(sensor) = 0.8mA * 62ohm = 0,05 Volt (sinusoidal around 0V)
It is really small. Maybe to test you should try it on a bigger circuit ( sensor only around the phase cable — red).
I did my first test on an electrical oven circuit measuring the output voltage after the burden resistor (integrated in your case)

Anyway, you should add 2.5V to your output before connecting it to your Arduino A0 Pin. To transform it as a positive voltage (sinusoid around 2.5 V – You can use the same resistors as mine)

To calibrate emolib:
calibration_value = ( i(measured) / i(sensor) ) / R(burden)
calibration_value = (nb_turn) / R(burden)
calibration_value = 1800 / 62 = 29

Let me know if you succeed or not in getting some values.

• Vishal

Hi,

Is this calibration value, actually a multiplying constant (factor) internally in code for calculation of the Current and Voltage? Does do — (# of ticks x calibration constant)x((3.3V)/2^(#bit resolution of ADC)).

I think that is what it is doing, but just want to double check.

• Vincent Demay

Hi Vishal,

You’re right, It is the way current is computed.
Best.

• jacekf

You could roll up the wire 10 times and shove it in the CT so you get 10x the current to calibrate the circuit

6. thieuduc2011

dear Vincent Demay,
Sr for replying to you for a long time. ^^. I ‘ve tried all the way you suggested but nothing changed even I’ve test with fridge and a cooker . I’m very worry about my project…

7. Joan

Thanks for the post! 😀
As Damien asked…how do you choose the capacitor?

8. Joan

Thanks Vincent !! 😀

9. Stuart

Thanks for this, I may give it a go.

Just wondering, how do you power your Arduino? I dont have a socket nearby and dont want to have a cable training outside.

Sorry if its a silly question.

Stuart

• Vincent Demay

Hello Stuart,

The Arduino is powered with a socket into the electrical panel, so no cable outside of the panel. If you want to power it via batteries, you can follow this tutorial

It is not a silly question,
Best,

Hello Vincent 🙂

I have project that display current value of my electricity load on xively.com, i use SCT 013-030 and emonlib library, on local measuring, my arduino send an accurately value from this sensor (i use serial monitor), but when i connect it to xively, it sent wrong value, can you give me some advice abaout it?

regards

11. engineer

R(burden) = U(SENSOR)/I(sensor) = 2.5V * 0.0707A = 35.4Ω

Correct formula is

R(burden) = U(SENSOR)/I(sensor) = 2.5V / 0.0707A = 35.4Ω

• Vincent Demay

Thanks. Was a typo. Fixed it
Thanks again. Best.

12. Eduardo

Hi,

Congratulation for the article.
I can to meter the power factor? I f yes, how to?

Thank you!

13. Dorothy

I was just wondering, the current sensor has a jack in the end, how do you connect it to the shield that you made. Did you just cut the jack then connect the wires to the resistors?

• Vincent Demay

Hi Dorothy;

Yes exactly I cut the wire to remove the jack, but if you want to keep it you can buy a simple connector.

Best,

14. Antonio

What happens if the value of the burden resistor is high?
you can have a high voltage output and therefore dangerous?
Or the sensor is unable to provide the necessary power so that the probe YHDC SCT-013-000 CT is not likely to have a dangerous situation?

Thanks

15. Tom

I´m having an issue that the arduino measures current around 50 Watts while nothing is connected and power consumption is = 0. Any idea how I could fix that? I set up the arduino just as described at openenergymonitor and I use a calibration of 89, what delivers good results using power over 100 watts up to 2600 watts. But it is very bad that it measures 50 Watts when nothing is connected. I appreciate any help, thank you!!!

PS. I´m using 5V and a 33 Ohms burden resistor

• Vincent Demay

Hi Tom,

You can try to change the value of the burden resistor to be more precise with low consumption. If you do so you have to compute every parameter according to this new burden.

Hope this help

• Tom

Hi Vincent,

unfortunately changing the burden resistor seems to have no effect on the output. I tried a 1.8k resistor and also no resistor, the output while nothing with power is connected is always around 40-50 watts, 0,16-0,18 Irms 🙁

• Antoine

I have exactly the same issue.

16. Charl

Hi,

Lets say at 100% load the signal will dance from 0 to 5V. How do you read the peak values ? I mean the read could happen just as the wave its 2.5V.

17. Tinamore

Hello Vincent
How much mA the resolution of the circuit above?
Can measure resolution about mA ?
Thanks

18. johnnypeste

In this code isn’t Irms always positive? And I agree that it should be… But then, how can I distinguish importing from exporting energy? I have a grid-tie solar inverter and when the sun is shining I’m exporting to the grid. How can I modify the code or the electronic setup to know if I’m consuming or producing electricity?

• Thomas TS

Today i started to monitor my solar system with a grid-tie inverter. The idea is just to see how much energy is been injected in my home electrical grid. To see if we are importing of exporting energy outside we would need to measure the direction of the flow before the meter at the “border” of our domestic grid.

19. beeper

Hi Vincent,
i have a short question. I want to use your introductions to measure a circuit with a max of 16A. I have done the following calculations:
i(measured max) = 1,414 * 16A = 22,627A
i(sensor) = 22,68A / 2000 = 0,01131A
R(burden) = 2,5V / 0,011314 = 220,9708 Ohm
I want to use a 220 Ohm resistor. Are my calculations correct? I am 100% sure or i fail to see something.
beeper

20. Arif Indra

Hi Vincent
I work with SCT-013-000 30A, and my circuit is same with you except the burden resistor I use 110ohm. The problem is If I measure the output with osciloscope I still have negatif voltage. I already used GND arduino to become the osciloscope reference. Do you have any idea? what am I miss? Thanks for helping me

21. Lucas

Thank you very much!

22. aranganathan

how to measure 3 phase AC current and voltage ???

23. MIKE

Hi, I don´t understand the value I recieve. I am not getting any value aside from 0,18. It should have nothing to do with the wat I connected it, because I attached it to only one way of the cable. Has anybody experienced this before?

24. Albert

Could you double the resolution by rectifying the input voltage (instead of adding the DC bias)? That would also remove R1 & R2 (adding the diodes for the rectifier)? Am I missing something that makes this a bad idea?

• Ludovic

Just thinking quickly about the rectifier : The point is that you’ll loose the VDiode*2 part of the signal : each diode of the diode bridge will “eat” about 0.7V.
I don’t have the brain enought awaken to compute correctly, but you will loose at least 0.7V of the signal part. When the signal is already lower than 0.7V (small power consumption), you then will not be able to measure anything !

Not sure that my theory is perfect, but I think it’s the main line…

25. Very good post on CTs, I also have an article regarding types of CTs on my page if anyone is interested in learning more about Current Transformer Theory. Cheers!

26. santosh gairhe

Can you please tell me how to interface arduino to 5A Current transformer module with LM358 OPAMP on board. Four pins are available on board VCC, Vout, GND, GND. It will be a great help. Thanks in advance

Sir, can we connect this thing with ESP8266 module and can monitor data from Blynk app.

• eli

hi did you found out if it can go with esp8266 ? (the module with adc pin )

Hello!
Do you know how could I implement the usage of this sensor with a Raspberry Pi?

• joseph

im also interested in this. any help would be appreciated

• Srinivasan

Hello,
It would be nice if someone could answer this question. And the codes involved if possible. Thanks a ton.

• dabo02

You would need the ADC add-on for it… after that you just open the arduino library copy and paste the measuring part of the code and after that you are free to go

29. manohar

hello,
i want to measure three coils current for three phase motor.
in example he used only one coil how to change.
can anyone help me.

30. Cameron

Just picked up my SCT-013-000 CT today.
Also have plans to implement it in a Raspberry Pi project.
Has anyone done this yet?

• Srinivasan

yeap done. check emonlib open energy monitor. You would need a IC chip which can convert analog input to digital output so that the pi can read it

31. Rudi

Can this sensor be used to measure DC current as well?

32. djalltra

I think if you use a 5v reference to calculate the burden resistor and use a diode to rectify it and then get the peak value it would give acceptable results

33. sarath kc

• Chriss

anybody?

34. Marius

Hi Vincent

Could you perhaps send me the diageam on how to put it all together and can I calculate the kw/hour on this? If so could you point me in the right direction pls

Thanks again great article

35. victor

Hi Vincent,

Thanks for that article very interesting!

I’m trying to do the same, and I think I got it but I have a doubt. I built the circuit without burden resistor as I measured the impedance between the sleeve and tip output from the jack connector and its 104.6ohms. So I guessed there is a built-in burden resistor.

The input/output factor printed on the blue case is 100A:50mA, so I guessed the number of turns 2000.

I set the calibration value like this : 2000 / 104.6

And the results are find but just 10 times bigger than the real, so I have to change the calibration value to something like this 200 / 104.6

It works but I’m no happy as I don’t know why this numbers or I’m cheeting somehow.

I’m trying to find the actual datasheet of this device ( SCT013 100A:50mA)

Any clue about the actual values or calculations?

Thanks!!

• victor

I was wrong as I thought. I realized that there is no actual burden resistor. The impedance calculated was from the same inductor, but was working somehow and it confused me.

I’ve added a 100ohms resistor instead of 33ohms, so I guess the maximum allowed income current will be 50A instead of 100A.

So I think I can get more resolution.

I don’t think the system is going to get more than 50*230 = 11500W.

Thanks!

36. Aniruddha

hii Vincent
can you please guide me how do I measure a varying voltage of 0-230V using arduino… max current is 5A.

37. Anders

Hi,

Thanks for this great article! It explains some things better than the “official” OEM articles.

Never the less, I am having some problems getting this to work. I am trying out a very simple setup with an Arduino UNO (thus using 5v), a CT1030-0000 current sensor and a 40w incandecent light bulb.

As I do not have a suitable burden resistor I have combined a number of resisors in series to get 33Ohm.

I am using the EmonLib library and the “standard” sketch as suggested in your post.

I see several suggested calibration constants around the web – EOM uses 111.1 and 60 is used in this article. I have tried both without significant difference in the output in the serial monitor.

Regarding the output in the serial monitor, I have very unreliable values. There seems to be no difference whether current is drawn or not (i.e. plugging/unplugging the light bulb) and the values vary greatly for each output, going between ~70 (apparent power) to more than 200.

I have tried a lot of things in order to get proper readings (including various loads on the measured wire), but nothing seems to make any difference. I have also checked the circuit setup over and over again.

If I measure the voltage at the divider it is 2.35v with the light bulb unplugged.

Does anyone here have had similar experience or could someone help me out with what could be the problem?

I suspect that the CT sensor could be faulty (it shows no physical signs of stress), but I have no means of testing it (I also only have a single CT sensor).

I really hope that someone can help me out.

Regards

– Anders

• Paolo

Hi, I have the same problem, measuring voltage between GND and the output pin get always the same value, around 2,74v… no matter if a load is present or not.
I use a 33 Ohm burden resistor, 2x 10k voltage divider and a 10uf capacitor as described in the tutorial and also on openenergymonitor
Someone can give any suggestions ?

38. Robert

The sensor SCT013100mA have 2 wires, but they are IN and OUT or dosent matter? If not why the sensor have arrow on “the case” to see in witch direction current must flow, or I am wrong? Please help!

Thank you!

• jacekf

if you have only one phase direction makes no difference but if you have 2 or more it does.
In US we have 120/240 some loads are single phase some dual. if you wire CT’s “reverse” voltages(current) will subtract so the 240 loads will measure zero A!
Same goes with wires; single phase no problem; it’s just a coil… makes AC! Dual phase; pay attention! 😉

39. David Esteves

Hello Vincent,

I have been trying to replicate this circuit using all the same exact materials you have with the exact coding and burden resistor, capacitor, and additional 10k ohm resistors.

I have just been trying to test it on a laptop charger to see what the current value is before it hits the transformer and I am getting no change from when the sensor is on the cord to when it is off the cord (the plug is indeed plugged in).

I was wondering if you could give me any insight on what might be the problem. I also have asked quite a few friends to double check my circuit to make sure I didn’t wire anything incorrectly.

It seems that the burden resistors keeps it at the same current value. But when I removed the burden resistor thats when I actually start to see changes in the current. However, I do not think that it is giving me precise values. I will be testing it later on with another method but again was wondering if you could provide any insight.

Would greatly appreciate it.

Warm Regards,

David

40. shenouda

what is the minimum current that it can mager

41. Gasha

Sensor has to be ON WIRE, not on laptop CABLE.
There is significant difference.

Hi Vincent,
Lets say at 100% load the signal will dance from 0 to 5V. How do you read the peak values ? I mean the read could happen just as the wave its 2.5V.
This is my question too, my analog in will see the power at the moment of sample, could be any value with in the sine wave, so how the Arduino will be determine the correct value, will that be done in by the EmonLib library ???

43. Sindi Oktaviani

could someone here explain what’s the exactly meaning of apparent power?does it mean the power that going through the wire when you plug your device from the electric source in our house?

p.s sorry for this kind of silly question

• jacekf

CT measures the current…. power=current x voltage so you can assume voltage (120, 220 240) and end up with lower accuracy… or you can get a step down transformer and measure the voltage and current and get more accurate result.
you heave to separate the wires and only have one wire in the CT… hot or neutral but not both! or you will get 0 no mater the load!! hot=black/brown, neutral=white/blue (ground=green)

44. Seaklim Lay

Dear Vincent Demay;
I really no way to make it accuracy, I used calibration 44.4 to measure current 0v until 5v. The result of current is right compared to a multimeter, but power is wrong because I give a fixed value of voltage. So, I try to used AC-AC adapter to measure the voltage, the result of voltage is right but the result of current is wrong. Can you please give me an advice as soon as possible? I really worry about my project so much. Thank you in advance !!!

45. Crovip

Hi can I integrate arduino with nodemcu (esp8266) to send data to domoticz ? If yes , then how do I change the code to match esp.?
Thank you