This project uses a Raspberry Pi Zero WH, a microSDHC card, and a Waveshare 7.5 inch e-Paper display HAT 800x480 to make a clock that displays the time using quotes from books, today's date, a weather icon, and the high and low temperatures.
This project heavily adapted and borrowed from multiple sources and is indebted to the following projects specifically:
- Jake Krajewski's Raspberry Pi + e-Paper Tutorial
- Mendhak's Waveshare e-Paper Display
- Jaap Meijers's Instructables Kindle Literary Clock
- Dhole's Monochrome Weather Icons
- Google Fonts
I borrowed the weather source code from Mendhak's repo. Jake Krajewski's Medium post showed me that writing to the screen with Python Pillow was easy to do. Jaap Meijers's project provided the quotes and code I modified to generate the quotes. I used Dhole's weather icons to display weather. I used Google Fonts to find good fonts (Literata is apparently designed for displays).
- Shopping list
- Setup the PI
- Setup dependencies
- Using this application
- Pick a Weather provider
- Run it
- Troubleshooting
- Waveshare documentation and sample code
- Waveshare 7.5 inch e-Paper display HAT 800x480 (I think this is the V2 display)
- Raspberry Pi Zero WH (presoldered header. You don't have to get a presoldered header, but I don't have a soldering iron)
- microSDHC card (I used a Samsung EVO 32GB card but probably any microSDHC card will do)
I tried to follow Mendhak's post with instructions to prepare the Raspberry Pi with WiFi and SSH, but the instructions didn't work for me entirely for ssh
and WiFi setup. I followed the steps for the ssh
and WiFi in this guide from the Instructables website. I also had to switch to a Linux machine instead of my Windows machine to finish the ssh
and WiFi setup after I could not get it working on Windows 10.
The Waveshare display I received came with standoffs that were too small to attach the display HAT to the Raspberry Pi Zero WH. I had to wire the Waveshare display to the Raspberry Pi using the GPIO pins and the included cabling for use with other boards.
sudo apt install git ttf-wqy-zenhei ttf-wqy-microhei python3 python3-pip python-imaging libopenjp2-7-dev libjpeg8-dev inkscape figlet wiringpi
sudo pip3 install astral spidev RPi.GPIO Pillow
sudo sed -i s/#dtparam=spi=on/dtparam=spi=on/ /boot/config.txt #This enables SPI
sudo reboot
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.58.tar.gz
sudo tar zxvf bcm2835-1.58.tar.gz
cd bcm2835-1.58/
sudo ./configure
sudo make
sudo make check
sudo make install
git clone this repository in the /home/pi
directory.
cd /home/pi
git clone --recursive https://github.com/jadonn/literary-clock.git
This should create a /home/pi/literary-clock
directory.
Register on the OpenWeathermap website, and go to the API Keys page, that's the key you'll need. Add it to the env.sh file.
export OPENWEATHERMAP_APIKEY=xxxxxx
Whichever weather provider you've picked, you'll need to provide the location and units to display in.
Modify the env.sh
file and update with the latitude and longitude of your location.
As needed, change the temperature format (CELSIUS or FAHRENHEIT).
export WEATHER_LATITUDE=51.3656
export WEATHER_LONGITUDE=0.1963
export WEATHER_FORMAT=CELSIUS
From within the /home/pi/literary_clock.py
folder run python literary_clock.py
. The display should update with an icon for the weather, today's date, and a quote if there is a quote for the minute of the day when the script is run.
Once you've proven that the run works, and an image is sent to your epaper display, you can automate it by setting up a cronjob.
crontab -e
Add this entry so it runs every minute:
* * * * * cd /home/pi/literary-clock && . ./env.sh && python3 ./literary_clock.py > run.log 2>&1
This will cause the script to run every minute, and write the output as well as errors to the run.log file.
If the scripts don't work at all, try going through the Waveshare sample code linked below - if you can get those working, this script should work for you too.
Cron job errors should go to syslog or be viewable through running sudo journalctl -xe
.
The scripts cache the calendar and weather information, to avoid hitting weather API rate limits.
If you want to force a weather update, you can delete the weather-cache.json
.
Check the Waveshare wiki for more information for your display
The Waveshare demo repo is here. Assuming all dependencies are installed, these demos should work.
git clone https://github.com/waveshare/e-Paper
cd e-Paper
This is the best place to start for troubleshooting - try to make sure the examples given in their repo works for you.