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

header

Needed Hardware.

ArduinoUno_r2_front450px

Arduino Uno

Price: less than $30 (Amazon)

current100a
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

step1

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.

step2

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

step3

 

 

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)

We add

  • 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.

step4

 

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

Once downloaded and placed in your arduino librairies folder you can start the code

#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.

test1 test2

 

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

http://openenergymonitor.org/emon/buildingblocks/ct-and-ac-power-adaptor-installation-and-calibration-theory

51 Comments

  1. 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).

    Reply
  2. 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

    Reply
    • 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?

      Reply
    • 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

      Reply
  3. 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?

    Reply
  4. 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.

    Reply
    • 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.

      Reply
  5. 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…

    Reply
  6. 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

    Reply
    • 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,

      Reply
  7. 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

    Reply
  8. 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Ω

    Reply
  9. 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?

    Reply
    • 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,

      Reply
  10. 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

    Reply
  11. 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

    Reply
    • 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

      Reply
      • 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 🙁

        Reply
  12. 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.

    Reply
  13. 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?

    Reply
  14. 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.
    Thanks for your assistance,
    beeper

    Reply
  15. 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

    Reply
  16. 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?

    Reply
  17. 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?

    Reply
    • 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…

      Reply
  18. 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

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

    Reply
  20. 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?

    Reply

Leave a Comment.