Sunday, 26 June 2016

MEASUREMENT OF DIRECT CURRENT IN BATTERY USING ACS712 CURRENT SENSOR CIRCUIT


CODE ::::


void setup()
{
Serial.begin(9600);
}
void loop()
{
float average = 0; //SET initially average value or dc value of current to zero
for(int i = 0; i < 1000; i++)
{
        average = average + (.0264 * analogRead(A0) -13.51);
        delay(1);
        }


Serial.println("Direct Current Value = ");
Serial.print(average);
Serial.println(" mA");
}






Keep Watching my YouTube Channel.
MEASUREMENT OF CURRENT IN BATTERY USING ACS712 
CURRENT SENSOR CIRCUIT



Wednesday, 22 June 2016

                     Project 7 How to make a ammeter using Arduino UNO and ACS712 current sensor .
                                                               For 3-Phase Line

                                 The code for making this project is given below,,,

const int sensorIn1 = A0;                       /*FOR Current measurement Sensor 1*/
const int sensorIn2 = A1;                       /*FOR Current measurement Sensor 2*/
const int sensorIn3 = A2;                      /*FOR Current measurement Sensor 3*/

int mVperAmp = 66;                          // use 100 for 20A Module and 66 for 30A Module & 185 for 10A module
 
double Voltage1 = 0;
double VRMS1 = 0;
double AmpsRMS1 = 0;

double Voltage2 = 0;
double VRMS2 = 0;
double AmpsRMS2 = 0;

double Voltage3 = 0;
double VRMS3 = 0;
double AmpsRMS3 = 0;

void setup(){

  Serial.begin(9600);                   // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
}

void loop(){

 Voltage1 = getVPP1();
 VRMS1 = (Voltage1/2.0) *0.707;
 AmpsRMS1 = (VRMS1 * 1000)/mVperAmp;
 Serial.print(AmpsRMS1);
 Serial.println(" Amps RMS1");

  Voltage2 = getVPP2();
 VRMS2 = (Voltage2/2.0) *0.707;
 AmpsRMS2 = (VRMS2 * 1000)/mVperAmp;
 Serial.print(AmpsRMS2);
 Serial.println(" Amps RMS2");

  Voltage3 = getVPP3();
 VRMS3 = (Voltage3/2.0) *0.707;
 AmpsRMS3 = (VRMS3 * 1000)/mVperAmp;
 Serial.print(AmpsRMS3);
 Serial.println(" Amps RMS3");

}

float getVPP1()
{
  float result1;
  int readValue1;                         //value read from the sensor
  int maxValue1 = 0;                 // store max value here
  int minValue1 = 1024;           // store min value here
 
   uint32_t start_time = millis();
   while((millis()-start_time) < 1000)            //sample for 1 Sec
   {
       readValue1 = analogRead(sensorIn1);
       // see if you have a new maxValue
       if (readValue1 > maxValue1)
       {
           /*record the maximum sensor value*/
           maxValue1 = readValue1;
       }
       if (readValue1 < minValue1)
       {
           /*record the maximum sensor value*/
           minValue1 = readValue1;
       }
   }
  
   result1 = ((maxValue1 - minValue1) * 5.0)/1024.0;      // Subtract min from max
   return result1;
 }

 float getVPP2()
{
  float result2;
  int readValue2;                         //value read from the sensor
  int maxValue2 = 0;                 // store max value here
  int minValue2 = 1024;           // store min value here
 
   uint32_t start_time = millis();
   while((millis()-start_time) < 1000)              //sample for 1 Sec
   {
       readValue2 = analogRead(sensorIn2);
       // see if you have a new maxValue
       if (readValue2 > maxValue2)
       {
           /*record the maximum sensor value*/
           maxValue2 = readValue2;
       }
       if (readValue2 < minValue2)
       {
           /*record the maximum sensor value*/
           minValue2 = readValue2;
       }
   }
   result2 = ((maxValue2 - minValue2) * 5.0)/1024.0;   // Subtract min from max
   return result2;
 }

 float getVPP3()
{
  float result3;
  int readValue3;                           //value read from the sensor
  int maxValue3 = 0;                   // store max value here
  int minValue3 = 1024;              // store min value here
 
   uint32_t start_time = millis();
   while((millis()-start_time) < 1000)              //sample for 1 Sec
   {
       readValue3 = analogRead(sensorIn3);
       // see if you have a new maxValue
       if (readValue3 > maxValue3)
       {
           /*record the maximum sensor value*/
           maxValue3 = readValue3;
       }
       if (readValue3 < minValue3)
       {
           /*record the maximum sensor value*/
           minValue3 = readValue3;
       }
   }
   result3 = ((maxValue3 - minValue3) * 5.0)/1024.0;         // Subtract min from max
   return result3;
 }


If you have any query please comment below & keep watching.