ArduinoGeneral

Question regarding the ACS758 Current Sensor

userHead Account cancelled 2015-12-07 22:57:24 2121 Views2 Replies

So I bought this sensor to measure DC current using my 5v Trinket Pro. I followed the wiring setup and code samples from the website. Everything seems to be working fine once connected, but I'm wondering why is it that once I disconnect the lines from the IN and OUT connections, I still would get a reading? My understanding is that I should be getting a value of 0A once I disconnect them. Am I doing something wrong? 

NOTE: I'm still a beginner, so please bear with me.

Attaching the images of my setup:

Below is the code i used for the Trinket

 

Code: Select all// include the library code:
#include <LiquidCrystal.h>

int RS = 3;
int EN = 4;
int D4 = 9;
int D5 = 10;
int D6 = 11;
int D7 = 12;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7);

const int numReadings = 30;
float readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
float total = 0;                  // the running total
float average = 0;                // the average
float currentValue = 0;

// the setup function runs once when you press reset or power the board
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
    for (int thisReading = 0; thisReading < numReadings; thisReading++)
      readings[thisReading] = 0; 
}

// the loop function runs over and over again forever
void loop() {
    total= total - readings[index];          
    readings[index] = analogRead(0); //Raw data reading

    lcd.setCursor(0, 1);
    lcd.print("Orig: ");
    lcd.print(readings[index]);

    //Data processing:510-raw data from analogRead when the input is 0;
    // 5-5v; the first 0.04-0.04V/A(sensitivity); the second 0.04-offset val;
    readings[index] = (readings[index]-512)*5/1024/0.04-0.04;                    
    total= total + readings[index];       
    index = index + 1;                    
    if (index >= numReadings)              
      index = 0;                           
    average = total/numReadings;   //Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing)    
    currentValue= average;

    lcd.setCursor(0, 0);
    lcd.print("A0: ");
    lcd.print(currentValue);
    delay(10);
}

2015-12-09 20:14:19 Hello Raffy,

Welcome!

I remember this sensor detect current range is 0-50A, is it possible that the current in your test was too small, and after you removed the connected wires from the sensor, it will read some random which might be the noise?
userHeadPic Leff
2015-12-09 02:18:56 Hi Raffy, welcome to the forum.

Thanks for your detailed images of the problem, they are very helpful! Our team is investigating and will we will reply in this thread asap.
userHeadPic Maht