12

I want my raspberryPi to shut down during the night and wake up in the morning.

I.e., at 10pm raspberry should shutdown or at least turn of the WiFi and the HDD. At 10am every day my raspberry should wake up or at least turn on the WiFi and the HDD.

How can I do this?

Edit:

How can I set a timer to turn of the WiFi and HDD and turn it on again at a certain time?

  • there's absolutely no point in doing that. RPi is already optimized for running 24/7, low consumption and no moving parts (no noise), it will happily run for a year or more. if you try to play with turning power on and off, the savings will be negligible, but the chances to corrupt SD card and destroy the system increase tenfold. and you most definitely don't want that. – lenik Oct 6 '14 at 11:49
  • @lenik, you care about this if you're running off batteries/solar. By shutting down at night you could make your device last longer without intervening with a new battery or charge. – Whome Mar 19 '18 at 14:53
13

You could check out the Witty Pi from UUGear as a simple extension to the Raspi. Will do proper startup and shutdown of system, includes real-time clock.

  • 3
    Extra credit for actually answering the question that the OP asked. – WineSoaked Aug 16 '15 at 21:34
3

The Raspberry Pi doesn't have the hardware needed to shut-down/start-up like a regular desktop PC.

The simplest, and possibly most reliable, solution would be to use a timer switch to switch the power to the Pi on and off. If doing so I'd add a cron job on the Pi to do a software shutdown several minutes before the timer shutdown. That would leave the SD card in a safe state.

3

Why do you want to shut down the Pi? The Pi itself uses so little power (<5W) that it is not worthwhile unless you are running on batteries. The B+ uses even less.

EDIT 2016-06-18 The following comment is no longer correct. halt shutdown and poweroff all perform a orderly shutdown of the OS.

Having said that halting the Pi puts into a very low power state, but can only be restarted with external events. It is simple to "restart" the B or B+ from the halt state using a simple externally driven circuit. This could be a timer or even a light dependent sensor. see https://raspberrypi.stackexchange.com/a/19754/8697

If your motivation is to limit access you can use cron to close down the relevant services and/or power down external devices. You would leave the Pi running to restart the next morning using a cron task.

  • Yes I want to power down the external hard drive which is connected to the Pi as wenn as the user WiFi Adapter. Could you please post a solution for that? – confile Oct 29 '14 at 12:48
2

I know this is "sorta" cheating, but I found an old laptop for under $20, and I use it to power my Pi. It also runs Linux and has WOL for it's ethernet, so I can simply login to the pi and shut it down, then log in to the laptop and shut it down. Then all i have to do is run etherwake AA:BB:CC... (the hardware address of the laptop's ethernet) and it will also then boot the Pi. Some laptops still send power out of the USB even if not on if it's plugged into the wall so you'll need to do a little research.

  • Why can't that laptop do the RPi's work in that case? If it can't I'd still assume that the laptop will consume more power than the RPi. – Ghanima Oct 14 '14 at 20:21
  • The laptop doesn't have GPIO or any real way to access the outside world; it can't use sensors/start motors, etc. and as I live in Tanzania, East Africa our power comes and goes without warning so you never plug any computer straight into the wall without some battery backup. I just thought I'd share what I did which allows me to turn on / off a Pi remotely. – linuxgnuru Oct 15 '14 at 20:39
1

While - as joan already put it - it's not possible to shut the RPi completely down and/or start it up by its own hardware, your "at least" demand of turning off WiFi and the HDD could be accomplished with only minor hardware hacking. Joans solution however provides higher savings with respect to electrical energy since the RPi also got no real power-off circuit thus consuming power if halt-ed.

Find a solution the use the GPIO-Pins to turn of a connected USB device (such as the WiFi dongle) here. Be sure to spin down the HDD before turning of its power using tools like hd-idle. Be also aware that some users claim reduced life-time of HDDs if spun down to often.

  • How can I set a timer to turn of the WiFi and HDD and turn it on again at a certain time? – confile Oct 6 '14 at 8:46
  • If we assume that the power savings of halting the RPi are negligible thus keeping it running you could use cron to both turn your devices off and on again. – Ghanima Oct 6 '14 at 9:21

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.