ACS714 Current Sensor Carrier -30 to +30A

I am attempting to read the current consumption (kWh) with the ACS714
Current Sensor Carrier -30 to +30A module.
My load is at 220VAC.
The module output is connected to Arduino MiniPro with ATMEGA328P micro.
The supply voltage to the ACS714 module is 5.175V DC.

I have modified the following Sketch:

int analogInPin = A0;  // Analog input pin that the carrier board OUT
is connected to
int sensorValue = 0;        // value read from the carrier board
int outputValue = 0;        // output in milliamps

void setup() {
  // initialize serial communications at 9600 bps:

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // convert to milli amps
  outputValue = ( ((long)sensorValue * 5000 / 1024) - 500 ) * 1000 /
66; // modified for ACS714 - 66mV / A

  // print the results to the serial monitor:
  Serial.print("sensor = " );
  Serial.print("\t Current (ma) = ");

  // wait 10 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:

Output with NO load:

Output with load:

Why am I getting negative readings?
What am I possibly doing wrong?

Best Regards

Hello, Rovin.

I have edited my original response because I feel it did not convey enough of a warning. Working with such high voltages is very dangerous, and it does not look like you know what you are doing well enough to do it safely. We recommend that if you want to proceed with your project, you do it under the supervision of someone qualified to work on such designs.

For reference, here is the explanation I originally wrote about the issue with your code:

[quote]The ACS714 sensor’s output voltage is centered around 2.5V. In order to represent this in your conversion, you can replace the value you subtract from your Arduino’s analog voltage reading from “500” to “2500” like this:

outputValue = ( ((long)sensorValue * 5000 / 1024) - 2500 ) * 1000 / 66 

This should give you an outputValue in mA.

Please keep in mind that since you are measuring alternating current, whose magnitude varies sinusoidally, you should also expect the output voltage of the sensor to vary sinusoidally above and below 2.5V.[/quote]