imranahmed
Advanced Member level 3
- Joined
- Dec 4, 2011
- Messages
- 817
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- Karachi,Pakistan
- Activity points
- 6,492
Please let me know that I want to interface ACS712-30A with arduino to measure
DC current in mA.
I have break light bulb of 2 filaments one is 18W and other is 5W.
for 18W @ 12VDC:
I=P/V = 18/12 = 1.5 A
for 5W @ 12VDC:
I=P/V = 5/12 = 0.416 A
But it cannot measure properly.
I used the code below from internet,
DC current in mA.
I have break light bulb of 2 filaments one is 18W and other is 5W.
for 18W @ 12VDC:
I=P/V = 18/12 = 1.5 A
for 5W @ 12VDC:
I=P/V = 5/12 = 0.416 A
But it cannot measure properly.
I used the code below from internet,
Code:
/*
Measuring Current Using ACS712
*/
const int analogIn = A0;
int mVperAmp = 66; // 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 / 1024.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);
}