Simple Battery Voltage Monitor Circuit

Simple Battery Voltage Monitor Circuit

 


Use the below code and optimize as per your requirement:

void setup() 

{
  Serial.begin(9600);
}

void loop() 
{
  int AnalogVolt = analogRead(A0);
  float BatteryVolt = AnalogVolt * (5.0 / 1024.0) * 10;
  Serial.print("Battery voltage is: ");
  Serial.print(BatteryVolt);
  Serial.println(" V");

  delay(500);
}

-----------------------------------------

Explanation:
  • As the input voltage should not exceed 5V, the battery voltage is divided using a resistor divider and for a maximum battery voltage of 9V, the input on the Analog pin of Arduino A0 is 4.5V.
  • The output of the resistive divider can be connected to an opamp to isolate the battery voltage and analog pin of Arduino. The opamp also can be used to apply gain when low voltage batteries are used
  • analogRead(A0) reads the analog value on the A0 pin of Arduino board. This function is part of Arduino basic library
  • Serial.begin(9600) output the data over the serial port at 9600 baud
  • Serial.print() function is used to send the data over serial port

Post a Comment

0 Comments