# how to measure battery voltage

Hi

i am working on a pcb that uses atmega 328p DIP to send using lora , this desgin is battery powered .
now i want to measure the battery level.

the issue is that avcc and aref pins are directly tied to vcc.

and vcc is directly connected to battery + , (battery+ is directly connected to avcc and aref , vcc ). there is no voltage regulator between anything . the board is directly being run by battery .

So how can i measure battery voltage ?
i have acess to all the pin, jumpers and soldering iron.

So how can i reliably measure the battery voltage

lion battery 1 cell 4.2- 3.7 v mAh

Drop battery voltage with a voltage divider to ~1volt.
10k+33k would do.
And switch the Aref to INTERNAL (1.1volt Aref).

or

Measure it internally, with code.

I assume you know a 328 should not be clocked at 16Mhz below ~3.85volt.
Leo..

Wawa:
I assume you know a 328 should not be clocked at 16Mhz below ~3.85volt.

yes i do know that , but i dont know will happen if it does go below that, i am using an generic oscillator 16 mhz one .

so

Will my arduino automatiicly lower its speed to 8 mhz when it get below 3.7 v?

manveen_singh:
Will my arduino automatiicly lower its speed to 8 mhz when it get below 3.7 v?

No.

Imagine what would happen if programs started changing speed all on thier own.....

But if its still running at 16Mhz, it might not operate correctly, its down to how lucky you feel .........

Wawa:
And switch the Aref to INTERNAL (1.1volt Aref).

or

Measure it internally, with code.

will it change ref voltage for 1 channel or all the channels ?

can i use adc1 with ref v of 1V and adc2 with original ref v ?

manveen_singh:
will it change ref voltage for 1 channel or all the channels ?

Yes, the 328 has only ONE A/D.
A multiplexer (switches) in front of the A/D creates the multiple channels.

manveen_singh:
can i use adc1 with ref v of 1V and adc2 with original ref v ?

You could switch between DEFAULT and INTERNAL in loop() when needed.
There will be some settling time.
Never done this, so maybe others could chime in.
Leo..

Read the datasheet about changing reference, I seem to recall there are caveats you have to observe.