I want to power a Raspberry PI from a power bank, which should give me - according to various sources on the Internet - 30 to 70 hours of operation.

How can I power up the Raspberry Pi once a week to stretch these hours over several weeks? (The Raspberry Pi would shut itself down after a few hours of operation.) I thought about using an Arduino or something, but couldn't find a tutorial on the Internet. Does anyone have a suggestion or a useful resource?

Update: I just found this: https://www.raspberrypi.org/forums/viewtopic.php?t=54653 , which seems to be pretty much what I'm looking for. Is this as easy to create as it looks? Just hook a USB cable to a timer?

Update 2: The above update does not look that practical, but I just found this: http://www.uugear.com/witty-pi-realtime-clock-power-management-for-raspberry-pi/ which might just be what I need. Has anyone used this "WittyPi"?

  • 1
    Easiest way would to buy a cheap electrical on/off timer that has the ability to program a weekly schedule. You can buy these at any hardware store for a few dollars. They're typically used to operate lamps at certain times of day. – stevieb Oct 14 at 13:58
  • 1
    @stevieb But these are usually for electrical outlets, no? Are there on/off timers for USB cables? – kratom_sandwich Oct 14 at 14:05
  • 1
    Yes, they are electrical timers. Some may have USB built-in nowadays. Worst case, just get a wall-to-USB adapter and plug that into the timer. – stevieb Oct 14 at 14:07
  • 1
    @stevieb: if I understand correctly there will not be a wall socket, only a USB power bank. Searching "usb timer" on Amazon shows various devices that ought to work. – Tomas By Oct 14 at 18:00
  • Your question is not clear . Can you explain what exactly are you trying to do? – Sohan Arafat Oct 30 at 7:16

The way I see it, no matter what, you will need to issue a poweroff at the raspberry after you do what ever you want to do. At this point you are left with a raspberry that needs either a plug/unplug of the usb cable or grounding pin 5 (or connect pins 5 and 6, 6 being the GND).

So yes, you will need another "brain" that draws a few mA of power and will either ground pin 5 or maybe drive a relay that will cut momentarily the red wire in your usb cable.

The question you then have is how do I tell the second brain when to power me off/restart me. If you have the serial free, you could connect the two brains and issue a "Hello restart me after that much time" command, or you could have the second brain performing the restart procedure every fixed amount of time. Arduino is an overkill for me, you can do the restart with a small atTiny chip or something like that.

The main problem with any second brain is the fact that you want to turn on the rpi every week. That limits your options a lot, because the way I see it you will be putting a lot of faith on your second brain to count the time properly and most of the timer relays are counting up to a day and/or are mains powered (google search:timer relays). That means that you will probably end up turning on the raspberry every time, have a counter in the raspberry (a txt file probably in the pihome folder) and when it reaches 7 (a week has passed then keep it on for as long as you need, other wise switch it off immediately and wait for the next day.

On a side note and based on this Power Consumption Benchmark "when you power off a Raspberry Pi (any model), it typically uses 20-30 mA (0.1W) until you physically disconnect the power." If those 20-30 mA are bothering you, then you can have the second brain, instead of toggling the red wire in your usb cable, to keep it disconnected and connect it when you want the raspberry turned on.

  • 1
    Shouldn't it be possible to just have the Pi sw turn itself off after a certain time? E.g. Pi runs for three hours, timer set to 3.5 hour interval, once per week. – Tomas By Oct 14 at 16:06
  • That's the thing, when you issue a poweroff command the raspberry goes in to something between switch off and standby. It doesn't completely switch off and it's not able to wake up. You need to power cycle it. If you power it off completely with a relay connected to the power line, and controlled by the raspberry it self, then how is the raspberry going to turn it self back on again, since there is no power? Maybe it's a crude example but it's like wanting to use a defibrillator on your unconscious self. – papatrexas Oct 16 at 8:05
  • Maybe I'm missing something but I thought the timer would turn the power off completely, and then back on next week. – Tomas By Oct 16 at 9:25
  • No, that is correct. It's just that we are trying to find out who that timer is going to be. It can't be the raspberry, it has to be an outsider. You either have a mechanical timer (springs and cogs and stuff) or you have an electronic timer which needs power constantly to count the time. And yes, I just saw the update in the original question. Looks like he found the timer for the job. – papatrexas Oct 18 at 7:50

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.