General

Amperimeter SEN0211 and SCT013

userHead Joan.Casals 2023-03-09 16:47:17 345 Views3 Replies

Good morning.
I am trying to measure the power of an electrical device. I use an SCT013 with a SEN0211 ( https://www.tme.com/us/es/details/df-sen0211/otros-sensores/dfrobot/sen0211/ )
I copied an example and tried it. It doesn't measure correctly. The truth is that I don't really know what I'm doing. Does anyone know or have an example that I can follow to correctly measure the power? I'm attaching the code I'm using and it doesn't measure correctly.
I have tried it with different Arduinos, please note:
For Arduino UNO, Leonardo and mega2560, etc. change VREF to 5
For Arduino Zero, Due, MKR Family, ESP32, etc. 3V3 controllers, change VREF to 3.3
Thanks.

 

//Potencia
const int ACPin = A3;         //set arduino signal read pin
#define ACTectionRange 20;    //set Non-invasive AC Current Sensor tection range (5A,10A,20A)

// VREF: Analog reference
// For Arduino UNO, Leonardo and mega2560, etc. change VREF to 5
// For Arduino Zero, Due, MKR Family, ESP32, etc. 3V3 controllers, change VREF to 3.3
#define VREF 3.3

void setup()
 {
 Serial.begin(9600);
 delay(1000);

 Serial.println(" ");
 Serial.println("-> Inici SETUP ");
 Serial.println("-> Ausatel Sistemes 2023 ");  

 //Potencia
 Serial.println("-> Fi SETUP");
 }

void loop()
 {
   
 float ACCurrentValue = readACCurrentValue(); //read AC Current Value
 Serial.print(ACCurrentValue/2);
 Serial.println(" A");
 Serial.print((ACCurrentValue/2) * 230);
 Serial.println(" W");
 delay(3000);
 }

// Funció llegir potencia
float readACCurrentValue()
 {
 float ACCurrtntValue = 0;
 float peakVoltage = 0;  
 float voltageVirtualValue = 0;  //Vrms
 for (int i = 0; i < 6; i++)
   {
   peakVoltage += analogRead(ACPin);   //read peak voltage
   delay(1);
   }
 peakVoltage = peakVoltage / 6;   
 
 voltageVirtualValue = peakVoltage * 0.707;    //change the peak voltage to the Virtual Value of voltage

 /*The circuit is amplified by 2 times, so it is divided by 2.*/
 voltageVirtualValue = (voltageVirtualValue / 1024 * VREF ) / 2;  

 ACCurrtntValue = voltageVirtualValue * ACTectionRange;

 Serial.print("VoltageVirtual = "); Serial.println(voltageVirtualValue);
 //Serial.print("ACTectionRange = "); Serial.println(ACTectionRange);
 Serial.print("ACCurrtntValue = "); Serial.println(ACCurrtntValue);
 Serial.println("********************************");
 
 return ACCurrtntValue;
 }
// Fi funció llegir potenies

 

 

 

2023-06-17 19:48:42

I think you need to follow Jenna's suggestions in this thread: 

 

https://www.dfrobot.com/forum/topic/321012

userHeadPic bidrohini.bidrohini
2023-06-16 05:51:33

Hi,  I am trying to do de same but with the ESP32  and de analog reading only reads 0.    I put an variable resistor and the analog read works fine, but with the blue cable of the sensor just reads 0.

 

 

userHeadPic Luis.Correa
2023-03-21 22:43:52

https://wiki.dfrobot.com/Gravity_Analog_AC_Current_Sensor__SKU_SEN0211_

 

Solved, works fine.I put everything back together again, following the example and it works fine for me now. I think I had a bad contact in the feed.

userHeadPic Joan.Casals