0

What are the solutions to locally schedule the power on / power off of a Raspberry (power on at 8 am and power off at 8 pm) ? I was asked to do so by the person in charge of my project. I told him it has to be done by plugin an additional device such as PiJuice or PiWatcher (I'm new to Raspberry sorry if I'm wrong on these) since I was told that by internet and a teacher. Is it really true, there are no way to script that, like cron for example?

I have a Pi0, soon will have a Pi4 instead I believe.

2 Answers2

1

You can't use a script running on the Pi to switch the Pi on when off. I leave it to you to work out why a script will not work if the Pi is not powered.

You need an external device to switch the power on.

Why do you need to switch the power on and off? You could use a script to reboot the Pi.

joan
  • 67,803
  • 5
  • 67
  • 102
  • Yeah I understand. I don't need to reboot, I need to have it on during the day only, to save power, mainly. – Axel Carré Apr 24 '21 at 20:27
  • 1
    Simplest thing is one of those plug in timers to switch the mains on an off. For safety I would have a script on the Pi to software shutdown just before the timer mains off time. – joan Apr 24 '21 at 20:32
  • To save you a little time, the Pi does not support Wake on LAN. It can send the packets to wake up other machines but it cannot be woken by that mechanism (hardware limit not software) If it's a standard cycle then Joans answer is the lowest cost - we have a timer that has 22 on/off options that can have daily / weekly / weekend cycles set in it and it cost £8-10 (total OTT for the lights at Christmas). –  Apr 24 '21 at 20:58
  • Yes I will just need to power it off pragrammatically, to power it on I will use an additional device. Do you know any that are often used? – Axel Carré Apr 24 '21 at 21:00
  • We don't give shopping advice. Switching off in software will not stop the power drain. From memory the Pi will still draw 150 milliamps or so. – joan Apr 24 '21 at 21:04
  • The power saving over the lifetime of the Pi will be less than the cost of the external hardware needed, so unless you have a pressing need e.g. battery power is pointless. The Pi will draw less than most appliances on standby. – Milliways Apr 24 '21 at 22:59
  • I know right. Academics... At least now I know what I'm going to say to them. Thank you. – Axel Carré Apr 24 '21 at 23:35
1

Reading the comments to @joan's answer, it occurs to me that you might be open to "Low Power" in lieu of "Zero Power".

If that's the case, and your RPi model is 4B you can reduce the current draw to about 35-40 mA (200mW) by changing a couple of configuration variables in your EEPROM bootcode. See this answer for details.

You can schedule entry into "Low Power" power mode programmatically (e.g. cron), but you will still need external hardware (a momentary push-button switch) to restore the RPi to an operational state. If it must be automated, this can be done with the DS3231 Realtime Clock (RTC) to pull the GLOBAL_EN via on the PCB low at the specified time. Additional hardware is required to automate wakeup, but software-wise this is supported by the kernel via a dtoverlay.

If you actually do need "Zero Power", you can also get that, but NOT through the EEPROM bootcode. And it will require a bit more external hardware. I won't go on as I'm not sure which solution you're committed to, but feel free to ask another question, or edit this one.

In summary then:

  1. You can enter "Low Power mode" by properly setting two (2) config variables in the bootcode stored in EEPROM but you can't exit "Low Power mode" without external hardware.

  2. You can enter "Zero Power mode" using the dtoverlay=gpio-poweroff in /boot/config.txt. This will require additional hardware; perhaps a RTC and a PMIC.

  3. You cannot have them both (Zero Power and Low Power). I cannot explain why this is, but will refer you to The Organization's experts.

Seamus
  • 18,728
  • 2
  • 27
  • 57