Page 1 of 1

PiCheckVoltage : monitor battery voltage

Posted: Fri Apr 26, 2013 9:44 am
by aboudou
Hi all,

I've made a small project intended to provide a mean to check battery voltage from Raspberry Pi, and run scripts when some voltage levels are reached (no battery plugged, dangerously low, low battery voltage and good battery voltage).

It could be used to avoid emptying too much batteries when their are used to power motors or other electric / electronic assemblies, or safely shutdown Raspberry Pi when voltage becomes to low.

The code and schematics are available here : https://github.com/aboudou/picheckvoltage

I hope it may be useful to somebody other than me :-)

Re: PiCheckVoltage : monitor battery voltage

Posted: Fri Apr 26, 2013 8:15 pm
by eried
Cool stuff, how many hours you get from these batteries with the pi idle?

It seems a little complex just to check the batteries anyway :D but it is good to learn stuff. I think for an easier solution you can use http://www.ebay.com/itm/NEW-7-4V-11-1V- ... 460d6581d1 one of these and wire the warning led to 1 pin in the arduino (or the digital version of that one for up to 8 cells and configurable alarm)

Re: PiCheckVoltage : monitor battery voltage

Posted: Fri Apr 26, 2013 8:25 pm
by aboudou
I didn't tried yet a full charge with Pi plugged to the battery. I'm testing now with one of my robotic assembly (idle mode, only things powered are : MCP3008, voltage regulator, and MCP23008 + LD293D, not the motors) : with eight NiMH 2000 mAh, batteries are now 68% full and were plugged 23 hours ago.

When they'are depleted, I'll charge then again and run my Pi on it (web server, two apt-get update / dist-upgrade a day, WIFI USB stick).

Re: PiCheckVoltage : monitor battery voltage

Posted: Sun Apr 28, 2013 11:25 am
by aboudou
I've just finished tests of battery life. With eight 2200 NiMH batteries, I can get :
  • 41 hours powering my idle robotic assembly, without Raspberry Pi
  • 3 hours powering my idle robotic assembly, with Rasberry Pi
Raspberry Pi was connected to network via Ethernet, as I just fried my WIFI adapter :roll:

Re: PiCheckVoltage : monitor battery voltage

Posted: Wed Feb 26, 2014 4:36 pm
by grit
Sorry for replying soooo late to this post, but I thought to mention that I'm using a LM3914 to measure the battery on the pi, using the LED output pins to trigger the appropriate GPIO port. I'm using a 12V battery though, not sure it this thing runs on 5V..

Re: PiCheckVoltage : monitor battery voltage

Posted: Tue Apr 01, 2014 2:40 pm
by wellsm89
Sorry for replying soooo late to this post, but I thought to mention that I'm using a LM3914 to measure the battery on the pi, using the LED output pins to trigger the appropriate GPIO port. I'm using a 12V battery though, not sure it this thing runs on 5V..
I am looking at using the LM3914 for monitoring my battery level, a 22.2V LiPo. Just wondering though did you straight from the output of the LM3914 to the GPIO pins? That will save me using led's and transistors.

Image

Re: PiCheckVoltage : monitor battery voltage

Posted: Wed Apr 16, 2014 5:38 am
by dramatix92
Is it necessary to have a SIGFOX module connected for the PiCheckVoltage to work.

Re: PiCheckVoltage : monitor battery voltage

Posted: Wed Apr 16, 2014 5:43 am
by aboudou
Absolutely not. Sigfox use is disabled by default (see config.py file)

Re: PiCheckVoltage : monitor battery voltage

Posted: Wed Apr 16, 2014 4:46 pm
by dramatix92
Sweet! That means I don't need any sort of internet connection for this, right?
I'm currently working on a project for school using the Raspberry Pi, and I need to monitor the level by percentage. I know in your configuration, you used 8 Lithium Ion batteries. I'm planning to use this:

http://www.amazon.com/OXA-10000mAh-Port ... B00FVS2AXQ

Please forgive me as I'm fairly basic with Java code and circuitry. I was planning to cut the wire, and connect it to a breadboard. From there, I was going to connect it to a cut micro B USB cable. Will I be able to monitor the voltage with this battery and PiCheckVoltage?

Re: PiCheckVoltage : monitor battery voltage

Posted: Wed Apr 16, 2014 5:49 pm
by aboudou
dramatix92 wrote:Sweet! That means I don't need any sort of internet connection for this, right?
No, I can be use purely in offline mode.
dramatix92 wrote:http://www.amazon.com/OXA-10000mAh-Port ... B00FVS2AXQ

Please forgive me as I'm fairly basic with Java code and circuitry. I was planning to cut the wire, and connect it to a breadboard. From there, I was going to connect it to a cut micro B USB cable. Will I be able to monitor the voltage with this battery and PiCheckVoltage?
With USB power banks, you'll only get 5V ±5%, except when the battery is empty, where you get 0V :-), So my code won't be useful (a.k.a you won't know when the battery is drained).

Re: PiCheckVoltage : monitor battery voltage

Posted: Wed Apr 23, 2014 2:47 am
by dramatix92
Alright, I'll look into getting some NiMH batteries. But why did you step the voltage down to 3.14V? Is it necessary to do that?

Re: PiCheckVoltage : monitor battery voltage

Posted: Wed Apr 23, 2014 5:21 am
by aboudou
dramatix92 wrote:Alright, I'll look into getting some NiMH batteries. But why did you step the voltage down to 3.14V? Is it necessary to do that?
With MCP3008, the max voltage you can measure is equal to its VIN voltage, and the voltage used through its SPI pins is equals to its VIN voltage too.

As Raspberry Pi GPIO pins are 3.3V only, you have to power MCP3008 with 3.3V, then use a voltage divider to step down measured voltage to maximum 3.3V

The voltage divider I used steps maximum NiMH pack voltage (11.2V) to 3.14V because of chosen resistors' values.

Re: PiCheckVoltage : monitor battery voltage

Posted: Wed Apr 23, 2014 5:33 am
by dramatix92
Couldn't you use the 5V pin instead?

Re: PiCheckVoltage : monitor battery voltage

Posted: Wed Apr 23, 2014 9:15 am
by aboudou
dramatix92 wrote:Couldn't you use the 5V pin instead?
5V to power MCP3008 ? Then it will try to communicate with the RasPi on SPI pins with a 5V logic, destroying the RasPi pins (or you'll have to put a level shifter between RasPi and MCP3008. And if you do that, you'll still have to use a voltage divider to step NiMH pack max voltage to 5V max.

Remember :
- MCP3008 analog pin max voltage = MCP3008 VIN pin voltage (i.e. VIN = 3.3V means analog in 3.3V max)
- MCP3008 SPI pins voltage = MCP3008 VIN pin voltage (i.e. VIN = 5V means SPI pins at 5V)
- RaspPi max voltage on GPIO pins = 3.3V

Re: PiCheckVoltage : monitor battery voltage

Posted: Thu Jan 19, 2017 4:11 pm
by Lamirand
Good day

http://www.lediouris.net/RaspberryPI/AD ... r-12v.html

I offer this link which might be helpful to some of you.

Here is what I'm trying to do and why that link is helping.

use my RasPi to monitor RV coach batteries (12volt marine batteries) and send me an email if batteries drop below a certain level.

the RasPi will be powered by the 12v batteries in the RV.
If the solar panal on the RV roof doesn't keep the batteries charged above, say 12 volts (which will happen in the summer when I park it under a rain canopy for a week or so between camping trips) then I will get an email if the trailer camper is in my driveway and thus within wifi range, (or if it is at some location where I have signed into the wifi). Actually the scripts and work done by the gentleman at www.lediouris.net means I'll get a daily email reporting battery level.

I am now buying an ADC, pentiometer, and cobbler to get started.

possible addition:

it might be good to use the RasPi's Bluetooth to send updates directly to my phone as a reminder to check or alert to low battery if we are in a camp ground without wifi.

I am interested in anyone's help or questions. I am just beginning on this and must learn some Java programming to proceed.

rod

Re: PiCheckVoltage : monitor battery voltage

Posted: Sun Jan 29, 2017 1:51 pm
by PavanKReddi