13

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?

confile
  • 241
  • 1
  • 2
  • 10
  • 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 06 '14 at 11:49
  • 2
    @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

6 Answers6

19

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.

ericool
  • 191
  • 1
  • 2
4

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.

joan
  • 67,803
  • 5
  • 67
  • 102
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.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • 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
1

I don't know if this is still relevant to anyone, but this is how I solved it: In our Company we have tons of Displays that just Display Information, and I was looking, just like the person that asked this question, to reduce the energy my Raspberry Pi's use at night (since no one really needs them at night).

I modified /etc/crontab to kill all tasks (specifically all chromium tasks, as we run the info on an html site) at 8pm. After that my PI used 0.5% of their ram. I also disabled the task bar and made the background black. The PI uses just a little more energy than if he was actually turned off (which you could only do with additional hardware). And it's an easy solution.

(For turning the PC back on, I modified crontab to reboot at 7am and added the website in autostart (/etc/xdg/lxsession/LXDE-pi/autostart)). As a result, all of our PI's use little to no energy overnight.

I hope I was able to help someone that was facing the some problem that we had.

I also want to add that in normal circumstances you dont have to worry about turning your PI off, as it uses little to no energy anyways (especially when you're just displaying something).

Dominik R.
  • 21
  • 1
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.

Ghanima
  • 15,578
  • 15
  • 58
  • 113
  • How can I set a timer to turn of the WiFi and HDD and turn it on again at a certain time? – confile Oct 06 '14 at 08: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 06 '14 at 09:21
1

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.

linuxgnuru
  • 605
  • 8
  • 19
  • 1
    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