3

I've made a portable wildlife camera which uses a 8 x AA UBEC battery pack and I am looking for a way to safely shut down the RPi when the power starts to get low. Is there currently any code that I can add on Raspbian that will detect low power on the GPIO pins and safely shut the device down?

If not do you have any further suggestions?

Thanks

Ryan

  • I'm sure there is some sort of logic circuit you could build which sets a GPIO pin to high if voltage drops below a certain level. Might be worth looking at a voltage level detector circuit. – Darth Vader Jul 19 '16 at 7:44
  • I'm sure this has been asked and answered many times before. You need to use the search button. One thing worth noting is that the Pi still consumes 100 mA or so even when powered down. – joan Jul 19 '16 at 7:47
3

MCP3008 can do that.

You can build module for mesure voltage.

Here is some links what can help you:

https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/overview

https://www.abelectronics.co.uk/p/56/ADC-Pi-Plus-Raspberry-Pi-Analogue-to-Digital-converter

What I will do is made one converter what will mesure voltage between 100 and 500mV and decide if voltage drop below 400mV or 350mV to strat shutdown sequence.

Also maby you can mesure core voltage of your PI in BASH script but I'm not shure is good way for this.

Here is code:

    #!/bin/bash    
    coreVoltage=$(vcgencmd measure_volts core)
    coreVoltage=${coreVoltage#"volt="}
    coreVoltage=${coreVoltage%"V"}
    echo $coreVoltage
3

You can not rely on the 5V from the UBEC - because the UBEC is designed to maintain voltage even when input fails.

It is not difficult to detect. Dry cells are effectively exhausted when the voltage falls to ~1.0V - here 8V. A voltage divider (connected across the battery) which will produce 1.3V when battery falls to 8V connected to a GPIO will go low.

This is imprecise. The actual trigger point will be 0.8 - 1.3 V. More accurate results can be achieved with a comparitor, you have to decide if this is warranted.

You don't say which Pi you are using, but none of them will run for long on AA batteries - you should expect to change them several times a day. (This is a polite way of saying this is probably not the best solution.)

  • 8 of the good AA NiMH I use here would store 28 Wh. A Pi3 bare board apparently uses about 2W, but lower-spec models roughly halve that, meaning you could just about get a day out of them. (Just to back up your point with numbers) – Chris H Jul 19 '16 at 10:34
1

I would think some existing UPS units designed specifically for the pi would be a far better approach. Some can allow for additional battery for longer life. I think if I remember correct, some can initiate a shut down on low battery as well. On top of this, I found a nifty design idea for something that may work.

Raspberry Pi UPS

Quoted from this link is the part I want to convey here:

Connect the USB power bank to the USB power supply unit (which should be able to provide at least 2.000 mA of current), and connect the Raspberry Pi to the USB power bank. Further connect the Raspberry Pi to your LAN switch (or router) by cable, if this isn't already the case anyway. Note that the connected LAN device must be powered from the same power source as the USB power bank. The Raspberry Pi can now detect a power outage by noting that the wired LAN connection is going down.

Effectively you would power a small router or something that provides a external connection (from the same power source) that can cause a drop in LAN connectivity on the pi if it is shut off. It would have to be something that has a lower tolerance for power drops than the pi so it shuts off first. Then on the pi you have it ping that LAN and if it does not show connected it does a 'shutdown now'

Granted this would reduce battery life considerably, but it is a non-GPIO/hack to achieve what you are looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.