1

I want to check battery level using Arduino. Arduino is powered by 3.7v Li-Ion Battery. using the same Arduino, I want to check check level of battery. Is it possible with Arduino's ADC?

I am using following code :-

void setup()
{ 
  Serial.begin(9600);
  pinMode(12, OUTPUT);
  digitalWrite(12, LOW);
}

void loop()
{
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  float voltage = sensorValue * (3.7 / 1023.0);
  Serial.println(voltage);
  Serial.println("V");
  delay(500);
  
  if (voltage < 3.0)
  {
    digitalWrite(12, HIGH);
  }
}

Circuit Diagram :- enter image description here

Serial Monitor of Arduino IDE :-

2.98
824
2.98
824
2.98
824
2.98
824
2.98
824
2.98

Can anyone suggest me to how to read exact live voltage of 3.7V 600mah battery using Arduino?

I have tried one more thing you can see the picture below :-

enter image description here

By using above circuit output is :-

1023
3.70
1023
3.70
1023
3.70
1023
3.70
1023
3.70
1023
3.70
1023

If I connected a 470ohm resistance between analog(A0) and Vcc(+) of battery, there is no output.

  • maybe this helps: https://github.com/RalphBacon/Arduino-Battery-Monitor – Vagaus May 12 '21 at 14:41
  • 1) VIN must be 7V above (and less than 12V). 2) ATMega328 is a 5V MCU. If you want to use VIN, you need two batteries in serial to make it 7.4V. – hcheung May 13 '21 at 10:43
  • The voltage divider however need to connect to 5V as the ATmega328 MCU ADC is in the range of 0-5V. – hcheung May 13 '21 at 10:45

0 Answers0