Close

acs715 sketch

A project log for Web based solar panel monitoring/managment

Arduino enable web server to monitor a small solar array and power management systems.

garyGary 03/19/2014 at 00:420 Comments

Here is a sketch to read the acs715 module and print the current going through the module. NOTE: the module is directional in nature. If your getting odd readings flip the connections on the acs715 module. I am not trying to lab grade current measurements, just get a  reasonable look at current being used.  If you need more  accurate reading you might consider looping through the current read several times and averaging your results.

/*

Read http://www.pololu.com/ acs715 30amp 30v current modules

and serial print the value.

Gary (N8EMR)

ohgary@gmail.com

*/

float current_input_pin = A4;            // Analog input pin that the carrier board OUT is connected to

float current_input_value = 0;          // value read from the carrier boar

float amps = 0;

void setup() {

Serial.begin(9600); // initialize serial communications for debugging.

}

void loop() {

current_input_value = analogRead(current_input_pin);

amps = float ((((long)current_input_value * 5000 / 1024) - 500 ) * 1000 / 133)/1000;

if (amps < 0 )

amps = 0 ; // Get rid of sensor noise when current is at/near zero.

Serial.print(amps);

Serial.print("A ");

Serial.println("");

delay(1000);

}

Discussions