Posts

Showing posts with the label Current Sensor

Week 1 - Current Sensor (I): Implementing the circuit

Image
Week 1 Figure 1: Current Sensors We made some minor adjustments to the code as the sensitivity setting varies with different model. We have used the AMPloc AMP25 for testing purposes, and the code we came up with is as shown below: /* current sensor testing code */ #include LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const int analogIn = A0; int mVperAmp = 37; // ACS712 - use 100 for 20A Module and 66 for 30A Module, AMPLOC - use 37 for 25A and 23 for 50A int RawValue= 0; int ACSoffset = 2500; double Voltage = 0.0; double Amps = 0.0; void setup() { Serial.begin(9600); lcd.begin(16,2); } void loop() { RawValue = analogRead(A0); Voltage = (RawValue / 1023.0) * 5000; // Gets you mV Amps = ((Voltage - ACSoffset) / mVperAmp); if ( (Voltage > 2520) || (Voltage < amps="); lcd.print(Amps,3); delay (2000); } else { lcd.clear(); lcd.setCursor (3,0); Serial.println(" aw="" delay="" input="" lcd.pri...