Friday, 16 January 2015

Battery Voltage measurement/High voltage measurement using arduino

Voltage is a parameter that has to be monitored for any kind of application.In this tutorial we are going to find the voltage across a battery pack of  3*12V lead acid batteries by using a voltage divider circuit using two precision resistors.The two resistors are chosen such a way that the voltage across R2 is maximum of 5V(because he maximum voltage rad by arduino is 5V)when a voltage source is connected across the voltage divider circuit.Here we are choosing R1 as 1MOhm and R2 as 100KOhm and choosing of resistors should be such a way that the current passing to this circuit should be as minimum of possible.






Here if i connect a 36V battery the current through these resistors would be (48/1.1Mohm=current flowing) 43 microamps which is very small and wouldn't affect the Power source.Now we are using arduino analog input to read the voltage across  R2 and write a code to find voltage across battery.Here we are reading the divided voltage and scaling it back to get the original battery voltage.The scaling factor can be found by measuring the battery voltage using multimeter and dividing with the voltage measured across resistance R2.The precision of the measurement is affected by the resolution of the ADC that is being used in the microcontroller.


float rawvalue;
float inputvoltage;
float batteryvoltage;
void setup()
{
  Serial.begin(9600);
  pinMode(A0,INPUT);
}

void loop()
{
  rawvalue=analogRead(A0);
  inputvoltage=((rawvalue)/1024)*5;
  batteryvoltage=inputvoltage*10.6;
  Serial.println(batteryvoltage);
  delay(1000);
}



The code is simple where we initialize the pin A0 as input where we read the voltage across R2,here rawvalue is defined to measure the value that is read across the resistor and input voltage is defined o convert the digital value to analog value and multiplying with scaling value to get the battery voltage 

No comments:

Post a Comment