Incorrect dc current values with ACS758, DFRobot 50 Amp current sensor.

Hello and thanks for reading this post. I have picked up a DFRobot 50 amp current sensor and then started playing with it. I was trying to see what current value I got when using the code that came with it. I downloaded the code from DFRobot website and the current chip is a ACS758.
I started running into issues when I looked at my serial monitor and saw this.

0.18
0.35
0.52
0.69
0.87
1.05
1.22
1.39
1.56
1.74
1.91
2.08
2.25
2.41
2.58
2.75
2.92
3.09
3.26
3.43
3.59
3.76
3.93
4.10
4.26
4.43
4.59
4.76
4.93
5.10
5.09
5.08
5.08

while viewing this data I didn’t have any load flowing into the current sensor. these value go up and down by .6 or so by them self and a load has a little affect on these numbers.

also I should say that I put in the code "Serial.println(analogRead(0));” to view the analog number in the serial monitor. every time I start a new serial monitor session analogRead value would change between from 510 to 550. I didn’t have any load on it as well.

my question is why cant I get the right current value? is there a problem with the current sensor or a cap required? or just code?

any question please ask. i know my spelling is not the best but I am patient when explaining what i mean.

here is the code.

/*
50A Current Sensor(AC/DC)(SKU:SEN0098) Sample Code
This code shows you how to get raw datas from the sensor through Arduino and convert the raw datas to the value of the current according to the datasheet;
Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing) is used to make the outputting current value more reliable;
Created 27 December 2011
By Barry Machine
www.dfrobot.com
Version:0.2
*/

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;

void setup()
{
Serial.begin(9600);
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
}
void loop()
{
total= total - readings[index];
readings[index] = analogRead(0); //Raw data reading
readings[index] = (readings[index]-510)*5/1024/0.04-0.04;//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;
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;
Serial.println(currentValue);
delay(30);
}

You forgot the code tags around the code and the link to the hardware you're using. If it's not a shield, you should also tell us how you wired the hardware to the Arduino and if you don't use an UNO, what type of Arduino you're using.

Sorry about that. I have tge arduino uno v3, the current sensor link is here.
the unit takes 5v and use analog pin 0.

http://www.dfrobot.com/index.php?route=product/product&product_id=580&search=50+amp+current+sensor&description=true&category_id=48

/*

50A Current Sensor(AC/DC)(SKU:SEN0098) Sample Code
This code shows you how to get raw datas from the sensor through Arduino and convert the raw datas to the value of the current according to the datasheet;
Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing) is used to make the outputting current value more reliable;
Created 27 December 2011
By Barry Machine 
www.dfrobot.com
Version:0.2
*/


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;

void setup()
{
  Serial.begin(9600);
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;       
}
void loop()
{   
    total= total - readings[index];          
    readings[index] = analogRead(0); //Raw data reading
    readings[index] = (readings[index]-510)*5/1024/0.04-0.04;//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;
    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;
    Serial.println(currentValue);
    delay(30);
}

also I should say that I put in the code "Serial.println(analogRead(0));" to view the analog number in the serial monitor. every time I start a new serial monitor session analogRead value would change between from 510 to 550. I didn't have any load on it as well.

This seems to be a floating pin (no connection at all). Not having load on it is not the same as "not connected". If the pin is not connected to GND, it will electrical noise from the environment and get some voltage from it. Even the noise in the chip itself may be enough to get results other than zero.

The same may be true for your current measuring chip. If you connect both ends of the current line to GND you should get 0, if you leave the unconnected the result may be undefined, although from the functional block diagram in the datasheet I would expect an other result.