Giga Technology Forum

QRSS Arduino Shield => QRSS Arduino Shield => Topic started by: Anton Janovsky (ZR6AIC) on July 16, 2015, 05:07:21 PM

Title: Measuring the Current with the "20A Current Sensor Module" on Arduino
Post by: Anton Janovsky (ZR6AIC) on July 16, 2015, 05:07:21 PM
20A Current Sensor Module
(http://www.giga.co.za/ocart/image/cache/data/Sensor/20A_Current_Sensor_ACS712-228x228.png)
This module is availably from http://www.giga.co.za/ocart/index.php?route=product/product&path=86&product_id=81 (http://www.giga.co.za/ocart/index.php?route=product/product&path=86&product_id=81)
Measuring Current Using ACS712
*/
const int analogIn = A0;
int mVperAmp = 185; // use 185 for 5A Module, 100 for 20A Module and 66 for 30A Module
int RawValue= 0;
int ACSoffset = 2500;
double Voltage = 0;
double Amps = 0;

void setup(){
 Serial.begin(9600);
}

void loop(){
 
 RawValue = analogRead(analogIn);
 Voltage = (RawValue / 1023.0) * 5000; // Gets you mV
 Amps = ((Voltage - ACSoffset) / mVperAmp);
 
 
 Serial.print("Raw Value = " ); // shows pre-scaled value
 Serial.print(RawValue);
 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 Amps = "); // shows the voltage measured
 Serial.println(Amps,3); // the '3' after voltage allows you to display 3 digits after decimal point
 delay(2500);
 
}