On some computers, I am using my own "custom" / "bare metal" operating system on the Raspberry Pi written in C++. In addition, I also have a handful of Raspberry Pis that are running the official Raspberry Pi OS (formerly Raspbian).
My goal is to be able to externally control power off / power on the Raspberry Pis running my "custom" / "bare metal" OS, which does not run standard executables (e.g., no ELF) or any scripts (e.g., no Python or PERL)
My question is whether I can configure one of the Witty Pi Power Management boards on a Raspberry Pi running the full official Raspberry Pi OS, and then unplug it, move it, and plug it into one of my "custom" / "bare metal" Raspberry Pis, and have it power off / power on using a set schedule (e.g., every hour).
I am assuming that UUGear provides a program (executable or Python script, etc.) to program and configure the scheduled power off / power on. I am also assuming that the Witty Pi Power Management boards have a non-volatile configuration, so that the configuration is maintained even when powered off / unplugged / moved to a different Raspberry Pi. Please advise if either of these assumptions is incorrect.
Also, I am assuming that the Witty Pi Power Management boards work at the firmware / GPIO level, and do not require software to turn the power "on" or "off" to the Raspberry Pi?
Please advise if what I'm discussing is possible with the UUGear Witty Pi Power Management boards is possible. Please ask questions of any of this is not clear.
Thanks,
Dave Filip
dfilip@colornetlabs.com
Witty Pi 4 stores most of the configurations in its EEPROM, however that doesn't include the schedule. If you directly move Witty Pi to a new machine, it can only remember the most recent scheduled shutdown and startup. The schedule script is stored in Raspberry Pi and parsing that schedule script is also done by Raspberry Pi (automatically after it boots up).
Witty Pi 4 does not need software support to boot Raspberry Pi up, because Pi will automatically boot up as long as Witty Pi 4 powers it.
Witty Pi 4 does need software to make a graceful shutdown. The daemon.sh detects the GPIO-4 falling (button clicked or RTC alarm triggered) and then runs "shutdown -h now" command in Raspberry Pi. The power cut is configured to be perform after the system has been shut down.
Thanks for the feedback, I think I have a somewhat better idea now. I am not concerned about my custom OS doing a graceful shutdown, as you can pretty much pull the power at any time and it won't do damage, since everything is managed in memory. My OS is more of an IoT OS, designed to monitor sensors and provide data via a web interface. Also, I have coding around a lot of the GPIO pins built into the OS already (for sensors), and it would be pretty trivial to add an interrupt that was triggered on the falling edge of GPIO 4 to do any necessary clean-up.
But it sounds like the problem is setting the schedule. Is that something that I could send to the Witty Pi from my custom OS, e.g., via 1-Wire or I2C? Or is there a proprietary serial protocol on one of the GPIO pins that you could document?
Here's what I want to accomplish in the end: I want to have a battery powered Raspberry Pi with 2x 18650s (Lion batteries) that power a fully functional Linux Raspberry Pi about 2-4 hours (depending on the model and activity), but what I want to do is get many days from a charge by having the Raspberry Pi boot up, do something for a few seconds, then go to sleep for an hour, then repeat (my custom OS is small -- 1.5 MB -- and boots very quickly). So I don't need a schedule as much as a timer to turn off and on the Raspberry Pi.
I could do this with a network switch and a network script, but I have found those tend to sometimes be unreliable and drop off the network. So I was looking for a bit of hardware that directly connects to the Raspberry Pi, and doesn't rely on a stable WiFi connection or anything else.
So I think the question then becomes whether there is any way to get the Witty Pi to either "remember" a simple set schedule (like on and off every hour, but it sounds like there is not), or whether I can easily send that "schedule" to the Witty Pi (e.g., over 1-Wire or I2C, or over one of the GPIO pins).
Thanks,
Dave.
Witty Pi 4 doesn't remember the schedule script, it only remembers the two alarms: one for startup and one for shutdown.
The runScript.sh on Raspberry Pi will get executed on boot. It parses the schedule script and configures the next two alarms on Witty Pi 4.
Witty Pi 5 (on development) does have the ability to store and parse the schedule script. You may consider waiting for Witty Pi 5, if one or two months waiting are not too long for your project.