 • Worldwide Shipping

• FAQ
• Worldwide Shipping

• FAQ

# HUM: split-core ammeter

You are a beginner with Croduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by e-radionica where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Croduino and the basic code. Everything else is left to your imagination.

## INTRODUCTION

If you have ever had the need to measure alternating current, you have been using the ammeter for measuring. But, what if we must measure current for a longer period of time and save the data at certain moments or if we simply want to print the values on some display or calculate something with them? For all of this we can use the split-core ammeter which can measure alternating current of up to 30A(SCT-013-030) or 100 A(SCT-013-000) depending on the model we are using. Characteristics for the SCT-013-030:
•Max. current: 30A
•Output voltage: 1V
•Maximum voltage applied: 660 V
•Gear ratio: 1:1800
•Frequency: 50 Hz – 1 kHz
•Wire opening dimensions: 13 x 13 mm
•Cable lenght: 1m

Characteristics for the SCT-013-000:
•Max. current: 100A
•Output current: 0-50mA
•Maximum voltage applied: 660 V
•Gear ratio: 1:2000
•Frequency: 50 Hz – 1 kHz
•Wire opening dimensions: 13 x 13 mm
•Cable lenght: 1m

## HOW DOES IT WORK?

The split-core ammeter is actually an open transformer (that is why it only works with AC) which has a winding on its primary (the lead through which we measure current), and on the secondary a much larger number of windings in order to get low current from the higher one which we, using the resistor, convert into voltage and measure using Croduino.

## A SENSOR THAT OUTPUTS CURRENT/VOLTAGE

If we have a sensor that outputs current like SCT-013-00 then we must convert current to voltage because we know that Croduino can measure only the voltage. In order to convert current of the secondary to the voltage, we have to connect the resistor parallel to the secondary output, and we will get a voltage drop that can be measured by Croduino.
Resistor value can be calculated according to the formula: R=(Aref*N)/(2*sqrt(2)*I) where Aref= reference voltage of the Croduino( 5 V ili 3.3V), N stands for number of secondary's windings, and I is the maximum current we can measure.
In our case for the sensor that measures 100A we have 2000 windings, and Croduino's reference voltage is 5V, and when we put all of this to the formula we get a resistor of 35,4Ω, but since it is not the standard value we always take a lower value which is standard, so in this case we will take a 33Ω resistor. Higher resistor value would, by maximum current, provide voltage that is higher than Aref, and we could burn our Croduino. When this resistor is connected in parallel to the current output, we get a voltage output. If we have a sensor that outputs voltage like e.g. SCT-013-030 then we can skip the step with determining the resistor, because this type of sensor has a built-in resistor.In order to determine which sensor we have, all we have to do is read if some current ratio is written on it (something like this 100 A:50 mA), or current and voltage (30A/1V), if the ratio is current, then we have the one that outputs current and we must add a resistor, and if the current and voltage ratio is written, then we do not have to add this resistor.

## HOW TO CONNECT IT?

NOTE: It is necessary to work with an AC voltage which is very dangerous, that is why you must shut down all the power supply sources while connecting the sensor!
Now that we have learned how to get the sensor that outputs voltage, let's connect it to Croduino so that we could measure current. As we measure only the AC with this sensor and we get the alternating voltage on the output, while Croduino works at DC voltage we have to adjust AC voltage in order to measure with Croduino. If we were to put one output of the sensor to GND, and measure voltage on the other one we would get positive and then negative values because the voltage is alternating and its values vary from maximum positive to maximum negative values. In order for all the changes to be in the positive part, we must add a DC component to our AC voltage, which is seen in the picture. When we add a DC component the voltage changes from 0V to some maximum value, and in our case it is 5V. In order to add a DC component to the alternating voltage, on one output of the sensor we connect the DC voltage, which should have a value of about a half of the output voltage of Croduino. To get a half-output voltage value of the Croduino, we will simply use a voltage divider with two equal resistors. When we connect a voltage divider we need to connect a capacitor of 10 uF between the GND and the output voltage of the voltage divider. In order to understand how to connect the sensor, a scheme that shows how to connect everything is provided. The scheme also shows a resistor of 33 Ω, but if you have a sensor that outputs voltage, just ignore this resistor and do not connect it. When measuring, it is necessary to have only one wire put through the transformer (if we put two wires, that is, the phase and the zero conductor, we will not be able to measure). The sensor comes with a 3.5 mm female connector and we need a 3.5 mm male connector for connecting. ## ARDUINO CODE

To work with this sensor you must download the library EmonLib which allows measuring and getting current values. If you do not know how to install the library check our tutorial.
The first example of the code for measuring is simple and there are not many functions we use, and we measure effective values of current with it and print them out on Serial monitor.

```#include "EmonLib.h" // including the EmonLib library to our code
EnergyMonitor emon1; //initialization of the EmonLib library
void setup()
{
Serial.begin(9600); //starting serial communication
emon1.current(0, 111.1); // Current: input pin(A0), calibration.
}
void loop()
{
double Irms = emon1.calcIrms(1480); // calculating the effective value of current and saving it to the Irms variable using the calcIrms function
Serial.print(Irms*230.0); // Printing the power which we calculate so to multiply the measured current by 230 which
//responds to the voltage value of the city network (not the exact power because the voltage changes, but it approximately fits)
Serial.print(" "); // printing the space as between values of current and power
Serial.println(Irms);// printing the measured current
}
```

The second example allows measuring current and saving data to the SD card in the .csv format which can later be opened in Excel and shown in the table or as a graph. How does the SD module work, check in the SD modul tutorial.

```#include "SPI.h" //including the SPI library that allows SPI communication
#include "SD.h" //including the SD library that serves to work with an SD card
#include "EmonLib.h" // including the EmonLib library to our code
EnergyMonitor emon1; //initialization of the EmonLib library
const int CS = 10; //defining the CS pin
int ocitanje=1; //defining variable ocitanje and setting its value to 1
void setup() {
Serial.begin(9600); //starting serial communication
emon1.current(1, 111.1); // Current: input pin(A0), calibration,
pinMode(CS,OUTPUT); //setting the CS as an output pin
//initializing the SD card and immediately checking if the initialization was successful
if (!SD.begin(CS)) {
Serial.println("Kartica nije ispravno spojena.");
return;
}
Serial.println("Kartica je ispravno spojena i spremna je za rad.");
String prvi= "Ocitanje,Struja,Snaga"; //To String prvi we save the words Ocitanje, Struja and Snaga which are comma separated
File ocitanja = SD.open("Podaci.csv", FILE_WRITE); // opening the file Podaci.csv for writing and reading from the file
// which is done through the ocitanja object using which we access the file
if (ocitanja) { //checking whether the file is open and if it is, the code in the braces is executed; if not, then it goes to the else function
ocitanja.println(prvi); //saving String prvi to the file using the ocitanja object with println function
ocitanja.close(); //closing the ocitanja object, i.e. through this object we close the file Podaci.csv
Serial.println(prvi); //printing out String prvi on the Serial Monitor
}
//if opening the file is not successful, a message about the error is displayed
else{
Serial.println("Nisam uspio otvoriti Podaci.csv");
}
}
void loop() {
double Irms = emon1.calcIrms(1480); // calculating the effective value of current and saving it to the Irms variable
String podaci = String(ocitanje)+','+String(Irms)+','+String(Irms*230); //current and power values are saved to the String podaci
File ocitanja = SD.open("Podaci.csv", FILE_WRITE); //opening the file podaci.csv
//the following code is the same as when we save String prvi, only now we save String podaci and we print it out on the Serial monitor
if (ocitanja) {
ocitanja.println(podaci);
ocitanja.close();
Serial.println(podaci);
}
```