Measuring battery voltage to Arduino

I am busy with a project to control pumps and fans in my greenhouse based on sensor input. I am running the Arduino off a 9V rechargeable battery. Everything is working fine with this setup, but I would like to be able to measure the voltage of the battery to see when I need to charge it.

Using a voltage divider seems to be the most common way of checking a battery's voltage. See Measuring Voltage with Arduino. I understand the concept (I am a bit new to electronics), but I am not sure if the following conclusion would be correct. Won't I be drawing a large amount of power from the battery unnecessarily and constantly thus depleting the battery more quickly? Is there a relatively simple way of interrupting this circuit so that there is only current flowing through the resistors and to the analog pin when I want to take a measurement (a relay perhaps connected to a digital pin)?

Thank you!

Using a pair of 10k resistors in your divider chain gives a load of only 0.45mA which is less than 2% of what the arduino itself will draw. So no problem there !

Thanks for the reply! So it should not be a significant power drain which means I won't need to interrupt it?

You mention two 10K resistors. In the linked example, a 1M and 100k resistor is used, but they want to be able to read up to 50V. So you think two 10k resistors will be sufficient to step the 9V down to 5V for the analog pin? I am still reading up on voltage splitters and the theory behind it, so I was not planning on changing the resistor values for fear of blowing up my Arduino!

This might be a stupid question, but this planned setup won't pull down the 9v current on the main power line that goes to the Arduino's barrel jack?

CvZyl:
This might be a stupid question, but this planned setup won't pull down the 9v current on the main power line that goes to the Arduino's barrel jack?

Not unless the battery is completely dead! Batteries are good constant voltage sources.

The way to decrease the current drain is use a divider with much higher value resistors,
and a capacitor to ground. The capacitor is needed to keep the source impedance of
the divider low enough to get accurate readings from the ADC, for which 100nF is adequate.

Ideally you'd protect the Arduino from back-powering via the capacitor, so do this:

1k from analog pin to mid-point of divider. Also 100nF from mid-point to ground.

Replace 100k's with 1M for even less wasted power.

CvZyl:
This might be a stupid question, but this planned setup won't pull down the 9v current on the main power line that goes to the Arduino's barrel jack?

Yes, it will !!!

(But only by about 2% of what the Arduino will pull it down - see reply #1).

PS: If your "9V battery" is one of those square PP9 batteries then prepare to be very disappointed by how long it lasts.

MarkT:

CvZyl:
This might be a stupid question, but this planned setup won't pull down the 9v current on the main power line that goes to the Arduino's barrel jack?

Not unless the battery is completely dead! Batteries are good constant voltage sources.

The way to decrease the current drain is use a divider with much higher value resistors,
and a capacitor to ground. The capacitor is needed to keep the source impedance of
the divider low enough to get accurate readings from the ADC, for which 100nF is adequate.

Ideally you'd protect the Arduino from back-powering via the capacitor, so do this:

1k from analog pin to mid-point of divider. Also 100nF from mid-point to ground.

Replace 100k's with 1M for even less wasted power.

See the attached schematic: am I understanding this correctly?

fungus:

CvZyl:
This might be a stupid question, but this planned setup won't pull down the 9v current on the main power line that goes to the Arduino's barrel jack?

Yes, it will !!!

(But only by about 2% of what the Arduino will pull it down - see reply #1).

PS: If your "9V battery" is one of those square PP9 batteries then prepare to be very disappointed by how long it lasts.

Thanks for the heads up, fungus! I have already read this in a few places, but this setup is just a proof of concept. I am planning to expand it to include a small array of 12V PV panels so as to charge the battery.

BTW, thanks for all the helpful advice - you guys have given me a lot to google today!

HI,

When you have the 12V solar panels set up, will you switch to a 12V battery? I think you should, otherwise a 9V battery might be damaged by the panels.

Do your pumps and fans run on 12V? It would be best if they did. But if that's not an option, you could look at using a DC-DC convertor, rather than a regulator, to power them. You can buy ready made DC-DC convertor modules on eBay at reasonable prices.

Regulators inevitably waste power. To regulate 12V down to 5V, for example, if the regulator needs to supply 100mA, it will draw 100mA from the 12V supply and simply waste six twelfths of the power, turning it into waste heat.

By contrast, a DC-DC convertor would only draw around 45mA from the 12V supply to provide 100mA at 5V. But DC-DC convertors are not perfectly efficient, so the best option is to use 12V pumps & Fans.

Paul