[HELP] How can I measure an external battery voltage using Arduino ?

Hello everyone!

Please... I need to measure the voltage of a 12 V battery via analog input 1 of the Arduino Nano board. My Arduino board is powered by a 5V ( the range is from 3.3 V to 6 V ). I found inside the forum, ways to measure Vcc voltage level but not for external batteries...

Anyone can help me how can I measure this ?

Thank you all so much..

Have a greatest hollidays!

esantos

Google for "voltage divider". This will show you the circuit you need to convert 12v into the 0-5v range the Arduino analog input requires.

As MorganS has said, use a voltage divider to limit the upper voltage to 5v. Remember that a 12v battery can go to above 14v when charging unless your charger limits it to less.

Calculate your divider on the upper voltage your battery will reach.

Remember to join the earths.

Weedpharma

Hi,
For your divider use something like 10K and 20K, this will give you 1/3 of the voltage or 4V.
5.000V / 1023 = 0.00488V. Which is 4.88mV x 820 (the analogue reading)=4.00V.

So 4v input = 12v battery output.

Here's a bit of my code: but I start with 2/3 not 1/3 as I only have to deal with 6V

void battCheck()
{
	unit=0.00488;                    //4.88mV per analoge step
	val=analogRead(A1);          //Analogue value
	val=val/2;                          //div by 2 = 1/3
	bv=(unit*val)*3;                // x 3 = 100%
	lcd.clear();
	lcd.setCursor(1,0);
	lcd.print("Battery Status");
	val=bv;
	if(val>4.80)
	{
	lcd.setCursor(1,1);
		lcd.print(val);
		lcd.print(" V+ -Full");
		delay(2000);
	}

So I use 20K to Pos and 10K to GND, you need it the other way around...

Hope it helps, Regards

Mel.