Battery monitor for April board

Hi all, I’m a complete newbie with the imp. I have followed an instructable and built the imp tempbug using the april dev board and so far so good, i.e. it is logging the temp data to Xively and sending alert emails via Zapier.

I would like to add a battery monitor, but it needs to be able to handle a range of battery voltages exceeding 3.3V, so I need a voltage divider. To conserve battery I want to gate the voltage divider. Now for less that 3.3V, I know I can just use a GPIO pin to gate the bottom of the divider to low when I want to measure, which is how the tempbug is currently measuring the thermistor voltage divider. But if I want to read a higher voltage, say a 9V battery, when the GPIO pin goes high, the divider will still be drawing current and/or, the ADC input will be over the 3.3V limit. So I guess I need an active voltage divider? I saw a post on the forums about measuring battery voltage on the Hannah board using the motor driver enable gating function to actively gate an FET switch (part of Hannah board) to gate the battery measurement. I can try to implement a similar switch, but I’m hoping there is something more clever and clean to implement on the April board. I have even thought about repurposing the battery reversal FET on the April board, but that is probably a bad idea. So if anyone has a sweet way to add this function to the April board I would love to hear about it.

Another question I have is about the possibility of a simple rig to use dual power supply for an April board, i.e. the USB 5V when the mains power is on, and a battery when the mains power fails. I am thinking that a forward diode from the USB 5V header pin to the Vin header pin, combined with using a 3xAA (4.5V) battery supply should be enough to do this very simply, if the existing reverse voltage protection on the battery supply line will block the higher USB 5V from the lower battery voltage. Does anyone know if the reverse voltage protection FET on the battery supply line would be adequate to keep the USB input from trying to charge the batteries?

What kind of batteries are you monitoring?
Lead-acid, Lithium, rechargeable, or not?
What might be the maximum battery voltage you are monitoring?

The easiest solution for your dual power supply would probably be to just add something like PowerCell charger from Sparkfun and a LiPo, or one of those from Adafruit, and just tie your load directly to VIN. I like the PowerCell charger… it is small, has 5V boost, and undervoltage protection, but some of the Adafruit versions have nice IC’s that will do top off charging, that should be nice on the LiPo.

There are a number of charger designs in the hardware sections as well. I’ve been working on building one in eagle.

Thanks for responding!

mlseim- I was planning to use disposable alkaline batteries, probably 3 cells in series, but ideally I would like the battery monitor to work for any battery supply that is compatible with the 17V limit on the April board Vin. I don’t plan on implementing a charging system.

jwehr- I will have a look at the Powercell charger. For this project I would like to maintain smoke detector like battery life in the absence of mains power, which probably precludes the use of rechargeables.

Are you looking for an analog value, 0-17, or a single trip-point (when it gets to a certain point).

Just having a trip-point would only use a digital input pin on the imp. The electronics aside would be a divider, comparator and transistor.

That would be more like a smoke detector.

I want an analog value so that I can graph the discharge curve of the battery. Thanks.

Yeah, you need to use a high-side switch for this to remove the battery input from the top of the divider. You need an N-fet and a P-fet, and can copy the circuit from the Hannah board’s servo power switch.

Thanks. I had pretty much come to that conclusion, but I appreciate the confirmation. I have found that adafruit sells a tiny dual SOT23 adapter board that should allow a neat and compact implementation. I will post some photos when I get it built and installed.