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, and PiHole blocked stats.
Waveshare 7.5 inch epaper display HAT 640x384
Raspberry Pi Zero WH (presoldered header)
microSDHC card
Use Etcher to write the SD card with the Raspbian Stretch Lite image, no need for desktop.
After the image has been written,
Create a file called ssh
in the boot partition of the card.
sudo touch /media/mendhak/boot/ssh
Create a file called wpa_supplicant.conf
in the boot partition
sudo nano /media/mendhak/boot/wpa_supplicant.conf
with these contents
update_config=1
country=GB
network={
ssid="yourwifi"
psk="wifipasswd"
key_mgmt=WPA-PSK
}
Connect the Pi to power, let it boot up. In your router devices page, a new connected device should appear. If all goes correctly then the pi should be available with its FQDN even.
Login with the default password of raspberry and change it using passwd
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.
sudo apt install git ttf-wqy-zenhei ttf-wqy-microhei 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
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
sudo apt-get install python3
In the /home/pi
directory, git clone the sample repo from waveshare, which contains the libraries needed to write to the screen.
cd /home/pi
git clone https://github.com/waveshare/e-Paper.git
This should create a /home/pi/e-Paper
directory.
git clone this repository in the /home/pi
directory.
cd /home/pi
git clone https://github.com/mendhak/waveshare-epaper-display.git
This should create a /home/pi/waveshare-epaper-display
directory.
cd waveshare-epaper-display
cd display
make
Modify the env.sh
file and put your Climacell API key in there.
export CLIMACELL_APIKEY=xxxxxx
Modify the env.sh
and add the domain of the PiHole in there, eg pi.hole
or 192.168.0.111
export PIHOLE_ADDR=192.168.0.111
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 ./run.sh
which should query Climacell, PiHole, 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.
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 waveshare-epaper-sample
cd waveshare-epaper-sample
cd ~/waveshare-epaper-sample/7.5inch_e-paper_code/RaspberryPi/bcm2835/
make
sudo ./epd
cd ~/waveshare-epaper-sample/7.5inch_e-paper_code/RaspberryPi/wiringpi/
make
sudo ./epd
cd ~/waveshare-epaper-sample/7.5inch_e-paper_code/RaspberryPi/python3/
sudo python3 main.py