Currentsensorbase project
1.AC cureentmeasure bycurrentsensormodiul
Links>>>>>>>>>>http://circuits4you.com/2016/05/13/ac-current-measurement-acs712/
Circuit>>>>>>>>>>>>
Program>>>>>>>
/*
Measuring AC Current Using ACS712
www.circuits4you.com
*/
const int sensorIn = A0;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
Voltage = getVPP();
VRMS = (Voltage/2.0) *0.707; //root 2 is 0.707
AmpsRMS = (VRMS * 1000)/mVperAmp;
Serial.print(AmpsRMS);
Serial.println(" Amps RMS");
}
float getVPP()
{
float result;
int readValue; //value read from the sensor
int maxValue = 0; // store max value here
int minValue = 1024; // store min value here
uint32_t start_time = millis();
while((millis()-start_time) < 1000) //sample for 1 Sec
{
readValue = analogRead(sensorIn);
// see if you have a new maxValue
if (readValue > maxValue)
{
/*record the maximum sensor value*/
maxValue = readValue;
}
if (readValue < minValue)
{
/*record the minimum sensor value*/
minValue = readValue;
}
}
// Subtract min from max
result = ((maxValue - minValue) * 5.0)/1024.0;
return result;
}
DC Current Measurement using ASC712-05A
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
Measuring Current Using ACS712
www.circuits4you.com
*/
const int analogIn = A0;
double mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
double RawValue= 0;
double 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("Amps = "); // shows the voltage measured
Serial.println(Amps,2); // the '2' after voltage allows you to display 2 digits after decimal
point
delay(1000);
}

Current sensor base project

  • 1.
    Currentsensorbase project 1.AC cureentmeasurebycurrentsensormodiul Links>>>>>>>>>>http://circuits4you.com/2016/05/13/ac-current-measurement-acs712/ Circuit>>>>>>>>>>>> Program>>>>>>> /* Measuring AC Current Using ACS712 www.circuits4you.com */ const int sensorIn = A0; int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module double Voltage = 0; double VRMS = 0; double AmpsRMS = 0; void setup(){ Serial.begin(9600);
  • 2.
    } void loop(){ Voltage =getVPP(); VRMS = (Voltage/2.0) *0.707; //root 2 is 0.707 AmpsRMS = (VRMS * 1000)/mVperAmp; Serial.print(AmpsRMS); Serial.println(" Amps RMS"); } float getVPP() { float result; int readValue; //value read from the sensor int maxValue = 0; // store max value here int minValue = 1024; // store min value here uint32_t start_time = millis(); while((millis()-start_time) < 1000) //sample for 1 Sec { readValue = analogRead(sensorIn); // see if you have a new maxValue if (readValue > maxValue) { /*record the maximum sensor value*/ maxValue = readValue; } if (readValue < minValue) { /*record the minimum sensor value*/ minValue = readValue; } } // Subtract min from max result = ((maxValue - minValue) * 5.0)/1024.0; return result; } DC Current Measurement using ASC712-05A
  • 3.
    4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /* Measuring Current UsingACS712 www.circuits4you.com */ const int analogIn = A0; double mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module double RawValue= 0; double 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("Amps = "); // shows the voltage measured Serial.println(Amps,2); // the '2' after voltage allows you to display 2 digits after decimal
  • 4.