TroubleshootingGravity

SEN0211 AC current Sensor and ESP32

userHead Luis.Correa 2023-06-16 13:42:24 670 Views2 Replies

Hi,  I am trying to read the SEN0211 AC current sensor,  with the AC Current Sensor V1.0 board and a ESP32  ,  I am readin a fan , wich with a multimeter reads 0.645amp  , but with de ESP32 I only read 0.   even floating the Analog input gives noise but with the wire of the sensor reads 0.

 

 

2023-06-18 03:45:06

Before proceeding as per Jenna's instructions, you can test the current sensor with an Arduino UNO. You can connect and code according to this wiki page: https://wiki.dfrobot.com/Gravity_Analog_AC_Current_Sensor__SKU_SEN0211_

userHeadPic bidrohini.bidrohini
2023-06-16 17:57:08

Please use it with ADS1115 module. 

I simulate your project using ESP32-E, ADS1115, and the DAC module. (This DAC module is I2C communication, 2 channels of 0~10V or 0-5V analog voltage output with 12bit resolution and 0.5% accuracy.  )

I set the DAC module to output 1.22V. At the same time, I measured the output voltage of ESP32-E as 3.29V. #define VREF 3.29 

As can be seen from Figure 2, the voltage read using the ADS1115 code is 1226mv. Further using the formula in the code to convert, the final stable result is 2.17A. (This output has been rounded.)

Hope that helps. 

code:

 

#include <Wire.h>

 

#include <DFRobot_ADS1115.h>

 

DFRobot_ADS1115 ads(&Wire);

const int ACPin = A2;         //set arduino signal read pin

#define ACTectionRange 5;    //set Non-invasive AC Current Sensor tection range (5A,10A,20A)

#define VREF 3.29

 

float readACCurrentValue()

{

 if (ads.checkADS1115()){

        double ACCurrtntValue = 0;

 double peakVoltage = 0;  

 double voltageVirtualValue = 0;  //Vrms

 int16_t adc0;

 double temp = 0;

 double voltage = 0;

 

 for (int i = 0; i < 5; i++)

 {

   adc0 = ads.readVoltage(0);

   temp = ads.readVoltage(0);

   peakVoltage += temp;   //read peak voltage

   delay(1);

 } peakVoltage = peakVoltage / 5;   

 Serial.print("A0:");

 Serial.print(adc0);

 Serial.println("mV,  ");

 ACCurrtntValue = peakVoltage /1000 * 1.7675;

 Serial.print(ACCurrtntValue);

 /*

 voltage = peakVoltage / 1000.000;//real voltage

 Serial.print("real voltage:");

 Serial.println(voltage);

  voltageVirtualValue = voltage * 0.707;    //change the peak voltage to the Virtual

//The circuit is amplified by 2 times, so it is divided by 2.

 voltageVirtualValue = voltageVirtualValue / 2;  

 

 ACCurrtntValue = voltageVirtualValue * ACTectionRange;

*/

 return ACCurrtntValue;

   }

 

     else

   {

 

       Serial.println("ADS1115 Disconnected!");

       return 0;

   }

}

 

void setup() 

{

 Serial.begin(115200);

 pinMode(D9, OUTPUT);

   ads.setAddr_ADS1115(ADS1115_IIC_ADDRESS0);   // 0x48

   ads.setGain(eGAIN_ONE);   // 2/3x gain

   ads.setMode(eMODE_SINGLE);       // single-shot mode

   ads.setRate(eRATE_128);          // 128SPS (default)

   ads.setOSMode(eOSMODE_SINGLE);   // Set to start a single-conversion

   ads.init();

 

}

 

void loop() 

{

 float ACCurrentValue = readACCurrentValue()/1.00; //read AC Current Value

  //Serial.print("voltage: %.3fV\n", ACCurrentValue);

 Serial.println(" A");

 digitalWrite(D9, HIGH);

 delay(500);

 digitalWrite(D9, LOW);

 delay(500);

}

 

userHeadPic jenna