This computer will run forever
It runs with the Sun
It all started with the word ‘solar’.
As I was tinkering with the Raspberry PI, I latched on PiJuice, a Kickstarter project promising solar power for the PI.
PiJuice is a Raspberry PI add-on board (aka HAT — Hardware Attached on Top) which includes a LIPO battery, a RTC (real time clock), a UPS (uninterrupted power supply), and a software environment to program the startup and safe shutdown of the PI.
The LIPO battery can be charged from USB or from a solar panel. I picked a 6 Watt solar panel.
I quickly realized that, even with perfect sun conditions, I would not be able to run the PI 24x7 using the energy provided by such a tiny solar panel. Even a PI model zero draws too much power (a few ma)
But thanks to the RTC and PiJuice libraries, it is very easy to program the PI to boot, do some useful work, schedule next boot, and safely shutdown. In the shutdown state, PiJuice will completely cut power to the PI.
What type of application suits this sequence of boot/shutdown? Of course not a server type (which needs to be on all the time), Instead, I went for a timelapse.
Timelapse is a technique to assemble a series of discrete pictures, taken at regular interval from the same view point, into a video clip. The resulting effect is typically quite interesting, a contraction of time.
In this case, the useful work is to take a picture using a USB web cam connected to the PI, and to push this picture to a web server. Then, any offline tool (such as Openshot, Time Lapse creator, etc ..) can be used to create the timelapse video from the individual pictures stored on the web server.
Example of Timelapse
It is also possible to view the individual pictures on the web server. Because I use Raspberry PI 4 to host the web server, I use PI gallery 2 as a friendly user-interface to the files.
The code is written in python and bash, and is available on GitHub.
I’ve used the excellent Blynk platform to monitor the PI application from a smartphone.
Blynk comprises 3 components:
- A python application running on the PI.
- A smartphone application, build without any code, just by assembling widgets.
- A public or private Blynk server, which managed asynchronous communication between the python app and the smartphone app.
As seen on the screenshot above, the Python Blynk app:
- sends a time stamp every time it runs. N means is it ‘night’, and no picture is taken.
- sends the LIPO SOC (state of charge, in %) and voltage. PiJuice library provides those values. On the blue graph, one can see the moment the sun hits the solar panel and the LIPO starts re-charging (a fully charged LIPO is 4.2V, a fully depleted one is ~3.1 V).
- increments a counter at each boot to make sure the system is working properly.
- configures the time interval between consecutive boot — here 59 minutes.
For systems that keep starting and stopping, a typical issue is how to connect to the system, e.g. to look at logs, or implement fixes or new features.
A simple solution is for the PI application to read a digital input to decide to shutdown or not. However, such a solution implies to physically access the PI, which is not always convenient.
A better solution is to implement a ‘stay on’ button on the smartphone, using Blynk. When the PI boots it reads the button value and decide to shutdown or not.
Not shutting down will obviously increase power consumption but also allow to connect to the PI using ssh.
Notifications are provided using Pushover. The PI application generates them and sends them to a smartphone application.
I’m also using Thingspeak to record various data in the Cloud for offline viewing. Again the PI application publishes the data into Thinkspeak’s cloud.
So… does it run forever?
My experience is that, unless the panel is totally buried in snow for several days (it happens, I’m living in the French Alps), my configuration (1 picture every hour, 6 Watt panel, 1500mah LIPO) will. Meaning it will survive many days without sun.
Besides, PiJuice provides some protection. If the LIPO gets depleted, the boot cycle will stop, and will resume only when the LIPO is sufficiently recharged.
Of course, in a few billions years, the sun outer envelope will vaporize the earth, but that’s not the point.
update mid march.
yes, it can be buried in snow. but still working.