Skip to content

Instructions on setting up a Raspberry Pi Zero WH with a Waveshare ePaper 7.5 Inch HAT. Date/Time, Weather, Google Calendar, Pihole Stats

Notifications You must be signed in to change notification settings

buttonboy/waveshare-epaper-display

 
 

Repository files navigation

Instructions on setting up a Raspberry Pi Zero WH with a Waveshare ePaper 7.5 Inch HAT. The screen will display date, time, weather icon with high and low, Google Calendar entries.

example

Shopping list

Waveshare 7.5 inch epaper display HAT 640x384
Raspberry Pi Zero WH (presoldered header)
microSDHC card

Setup the PI

Prepare the Pi

I've got a separate post for this, prepare the Raspberry Pi with WiFi and SSH. Once the Pi is set up, and you can access it, come back here.

Connect the display

Turn the Pi off, then put the HAT on top of the Pi's GPIO pins.

Connect the ribbon from the epaper display to the extension. To do this you will need to lift the black latch at the back of the connector, insert the ribbon slowly, then push the latch down. Now turn the Pi back on.

Setup dependencies

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  # Pillow took multiple attempts to install as it's always missing dependencies
sudo pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
sudo sed -i s/#dtparam=spi=on/dtparam=spi=on/ /boot/config.txt  #This enables SPI
sudo reboot

Get the BCM2835 driver

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

Using this application

Clone it

git clone this repository in the /home/pi directory.

cd /home/pi
git clone --recursive https://github.com/mendhak/waveshare-epaper-display.git

This should create a /home/pi/waveshare-epaper-display directory.

Waveshare version

Copy env.sh.sample (example environment variables) to env.sh

Modify the env.sh file and set the version of your Waveshare 7.5" e-Paper Module (newer ones are version 2)

export WAVESHARE_EPD75_VERSION=2

Climacell API key

Modify the env.sh file and put your Climacell API key in there.

export CLIMACELL_APIKEY=xxxxxx

Climacell API is used for the weather forecast as well as several weather icons.

Location information for Weather

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_FORMAT=CELSIUS
export WEATHER_LATITUDE=51.3656
export WEATHER_LONGITUDE=0.1963

Google Calendar token

The Oauth process needs to complete once manually in order to allow the Python code to then continuously query Google Calendar for information. Go to the Python Quickstart page and enable Google Calendar API. When presented, download or copy the credentials.json file and add it to this directory.

Next, SSH to the Raspberry Pi and run

python3 screen-calendar-get.py

The script will prompt you to visit a URL in your browser and then wait. Copy the URL, open it in a browser and you will go through the login process. When the OAuth workflow tries to redirect back (and fails), copy the URL it was trying to go to (eg: http://localhost:8080/...) and in another SSH session with the Raspberry Pi,

curl "http://localhost:8080/..." 

On the first screen you should see the auth flow complete, and a new token.pickle file appears. The Python script should now be able to run in the future without prompting required.

Run it

Run ./run.sh which should query Climacell and Google Calendar. It will then create a png, convert to a 1-bit black and white bmp, then display the bmp on screen.

Using a 1-bit, low grade BMP is what allows the screen to refresh relatively quickly. Calling the BCM code to do it takes about 6 seconds. Rendering a high quality PNG or JPG and rendering to screen with Python takes about 35 seconds.

Automate it

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/waveshare-epaper-display && bash run.sh > 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.

Waveshare documentation and sample code

Waveshare have a user manual which you can get to from their Wiki

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.

Readme for the C demo

Readme for the Python demo

About

Instructions on setting up a Raspberry Pi Zero WH with a Waveshare ePaper 7.5 Inch HAT. Date/Time, Weather, Google Calendar, Pihole Stats

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.2%
  • Shell 3.8%