1
\$\begingroup\$

I'm building a IoT thing based on Arduino. The thing will be powered by a 12V battery. The reason why I want to use a 12V battery is because I will also have motors on the thing.

I would like my thing to know how much battery it has left, so it can signal with a LED or similar when it starts to run out of battery and needs to be recharged.

The Arduino has a built in power regulator which accepts 5 to 12V as input, so that part is fine.

It also has analog inputs, and my idea is to use the analog input to measure the voltage of the battery. This assumes that as a battery starts to run out it will give a lower voltage than when it is fully charged. So my first question is, is this correct? If not, how can I tell when a battery starts to run out?

Anyway, the analog input can only accept input voltages between 0 and 5V. So I can't obviously connect the battery directly to this input, this would burn the Arduino. The idea I have is to use a voltage divider like this:

Schematic

And choose R1 and R2 to be 1.5kΩ and 1kΩ. This should give an input to A0 of 4.8V if the battery gives 12V, and and input to A0 of 3.6V if the battery voltage goes down to 9V. It should be enough of a difference in voltage for the analog input to be able to measure it.

Well... That's what I thought anyway... Is this a good way of doing it? Is this the "standard" way to measure battery life, or are there other better methods?

\$\endgroup\$