This project is built around the 7.5 inch HD panel from Waveshare. This has a resolution of 880x528. Other panels will require tweaks to the layout.
When you first execute the script, it will create a weather.json
. You will need to enter into this file the latitude and longitude of the forecast to display, and a Met Office API key.
To authorise the Google Calendar API, go to https://developers.google.com/calendar/quickstart/php and click on Enable the Calendar API
. You can then download credentials.json
and place it in the same folder as the main script.
Execute:
./render.py -o test
on your desktop/laptop, and it will load an authentication webpage, allowing you to complete authentication and generate a token, which the script will save as token.json
. If everything is sucessfull it will create the test output files test-b.png
and test-r.png
which are the black and red channels that would be sent to the eink.
After performing this step once, copy all files to the Raspberry Pi and it will execute headlessly from now on.
For a full list of options run:
./render.py -h
The most important option is -c
(or --calendars
). This is how you tell the script which calendars from your Google Account to render, separated by commas. primary
is a special calendar name understood by the Google Calendar API as the user's "main" calendar. For example:
./render.py -c primary,Work,Family
Calendar names with spaces are not currently supported.
One particularly useful option allows you to test the script locally by redirecting the output to image files rather than the eink.
./render.py -o test -c Calendar1,Calendar2
This will create two files test-b.png
and test-r.png
which are the black and red channels respectively.
The script supports caching to prevent unnecessary screen refreshes. If the --cache <filename>
option is provided, then a file is created in the same directory as render.py
which contains the events that were fetched in that run. Subsequent runs will only refresh the eink if the fetched events differ from the cache file contents. This allows you to have the script refresh much more frequently without causing distracting refreshes.
Almost any Raspberry Pi will work for this project, once set up in as a headless device. You will need to install the Python prerequisites:
pip3 install google-api-python-client google-auth-httplib2 google-auth-oauthlib pillow metoffer
If metoffer is not installing from pip, you can find it at github.com/sludgedesk/metoffer.
You will also need to install and set up the Waveshare drivers and Python libraries, details of which are available on the Waveshare Wiki.
Once you have a headless Pi running that you can SSH to, clone this repository onto the Pi and set up a crontab to execute the refresh periodically. This example refreshes every five minutes using a cache file to ensure that the eink only refreshes when events change. Additionally on reboot the script is run without the cache to force a refresh. Edit your crontab with crontab -e
and add the following, taking care to adjust the paths to point to the correct location.
*/5 * * * * /home/pi/eink/render.py -c primary --cache cachefile
@reboot /home/pi/eink/render.py -c primary
Finally, you might want to turn off the power and activity LEDs, which on most devices you can do by adding these lines to /boot/config.txt
dtparam=act_led_trigger=none
dtparam=act_led_activelow=off
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off
The weather icons in this project are the Meteocons project by Alessio Atzeni.
Fonts used:
- Louis George Cafe by Chen Yining
- Open Sans by Steve Matteson
- Pixellari by Zacchary Dempsey-Plante