Re: Long term power supply programing
by cstratton on Sat Mar 16, 2013 1:43 pm
This is actually not that trivial, as unless I'm mistaken the Raspberry Pi does not have software control of its own power, or that of USB peripherals. So it probably cannot switch itself between operation and a sufficiently low power mode to save your battery.
Most small Microcontrollers can do this however (even the broadcomm chip on the pi might be able to, if you could get a full data sheet and were designing your own board), so a direct solution would probably be an accessory microcontroller which would power the pi. Conceptually speaking:
1) Get a microcontroller, something such as the ATMEGA off an Arudino, and learn to program a timer for it to wake up from microampere sleep mode at some point in the future. Build a circuit free of current-wasting components such as pullup resistors working against the dominant state of signals.
2) Create a way for this micrcontroller to provide power to the raspberry pi, for example turning on a small relay, or enabling a (switching?) 5v regulator that has an enable input and a sufficiently low current when disabled.
3) Program the pi to automatically take a picture on startup, then cleanly shut down it's software, umounting all file systems and more or less halting itself as it usually does.
4) Create a way for the microcontroller to determine that the pi has finished shutting down before it removes the pi's power. You could do this with a simple timer, but it would be better to look for a final message on a serial console on the pi's uart, or something like that.
5) Test it. Program it for a shorter interval than you need and leave it running for a few days, and see if you can actually get that many cycles out of it without suffering sd card corruption. You might consider manually backing up the photos twice a day to a USB stick, and having a spare card all ready to go on hand which you can substitute in if it does start failing to boot. (Or just swap between two cards every day, taking the other one home to offload)
Alternatively, consider using something designed with power management more in mind - a smart phone running a timelapse app might do the job just fine if given that external battery, though if the charging circuit is wasteful you might need to only connect it periodically.