0
\$\begingroup\$

I'm using ESP8266 interfaced with ACS712 current sensor to measure current and voltage.

However it displays some values without any load being applied, and after applying the load, the changes are not that much (about 0.06).

Below is the code:

//Measuring Current Using ACS712


//#include <Filters.h>            //This library does a huge work check its .cpp file
#include <Adafruit_GFX.h>       //OLED libraries
#include <Adafruit_SSD1306.h>



#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET    -1 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); 

const int sensorIn = A0;
int sensitivity = 66; //  66 for 30A Module
int adcvalue= 0;
int offsetvoltage = 2500; 
double Voltage = 0; //voltage measuring
double current = 0;// Current measuring

void setup() {

 Serial.begin(9600);//baud rate at which arduino communicates with Laptop/PC
 display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //Start the OLED display
 display.clearDisplay();
 display.display();

}

void loop()
{

 adcvalue = analogRead(sensorIn);//reading the value from the analog pin
 Voltage = (adcvalue / 1024.0) * 5000; // Gets you mV
 current = ((Voltage - offsetvoltage) / sensitivity);


 Serial.print(adcvalue); //prints the results on the serial monitor

 delay(2500);
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0, 20);
  display.println("Voltage");
  display.setCursor(50, 20);
  display.println(Voltage);
  //display.setCursor(75, 20);
  display.setCursor(85, 20);
  display.println("V");
  display.setCursor(0, 30);
  display.println("Current");
  display.setCursor(50, 30);
  display.println(current);
  display.setCursor(75, 30);
  display.println("mA");
  display.display();

 Serial.print("\t mV = "); // shows the voltage measured 
 Serial.print(Voltage,3); // the '3' after voltage allows you to display 3 digits after decimal point


 Serial.print("\t current = "); // shows the voltage measured 
 Serial.println(current,3);
}
\$\endgroup\$
3
  • 3
    \$\begingroup\$ With the information provided the question is more suited to psychics.stackexchange.com. We're missing the schematic and the commented code. There are buttons for both on the editor toolbar. Provide links to the datasheets. \$\endgroup\$
    – Transistor
    Mar 21, 2020 at 13:12
  • \$\begingroup\$ I have provided the code am using \$\endgroup\$
    – Zara
    Mar 21, 2020 at 17:25
  • \$\begingroup\$ @Zara, you should add the information to this question, not start a new one. \$\endgroup\$
    – StarCat
    Mar 21, 2020 at 20:33

1 Answer 1

2
\$\begingroup\$

ACS712 is a family of parts, if you bought the 30A version instead of a 5A one you will not see only 66mV/A change in the output (vs 185mV/A for 5A version). That entire line of parts suffers from offset voltage issues and I believe they just use 1/2 Vin as the ref voltage, so if you have any variance in your power supply it will directly affect your offset voltage.
Bottom line: expect to perform a gain & offset cal on every serial number if you want good data. Once you adopt that strategy those parts offer very good performance at a very good price point.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the response. Am using 30A module and the sensitivity is 66mv \$\endgroup\$
    – Zara
    Mar 21, 2020 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.