Template: Hardware/Software setting for touch e-paper HAT
Hardware Connection
You can directly attach it to the 40PIN GPIO of Raspberry Pi. Or you can wire it to Raspberry Pi with 12PIN cable, please refer to the Pin definition below:
Touch e-Paper | Raspberry Pi | |
BCM2835 | Board | |
VCC | 3.3V | 3.3V |
GND | GND | GND |
DIN | MOSI | 19 |
CLK | SCLK | 23 |
CS | CE0 | 24 |
DC | 25 | 22 |
RST | 17 | 11 |
BUSY | 24 | 18 |
INT | 27 | 13 |
SCL | SCL1 | 5 |
SDA | SDA1 | 3 |
TRST | 22 | 15 |
Take the 2.13inch Touch e-Paper HAT as an example, just plug it into the Raspberry Pi:
Enable SPI interface
- Open the terminal, and use the command to enter the configuration page.
sudo raspi-config Choose Interfacing Options -> SPI -> Yes to enable the SPI interface
sudo reboot
Make sure that the SPI is not occupied by other devices, you can check in the middle of the /boot/config .txt.
Enable I2C interface
- Open terminal, use command to enter the configuration page
sudo raspi-config Choose Interfacing Options -> I2C -> Yes to enable I2C interface
And then reboot the system:
sudo reboot
Libraries Installation
- Install BCM2835 libraries
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz tar zxvf bcm2835-1.68.tar.gz cd bcm2835-1.68/ sudo ./configure && sudo make && sudo make check && sudo make install
For more details, please refer to http://www.airspayce.com/mikem/bcm2835/
- Install wiringPi libraries
sudo apt-get install wiringpi #For Pi 4, you need to update it: wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v #You will get 2.52 information if you install it correctly
- Install Python libraries
#python2 sudo apt-get update sudo apt-get install python-pip sudo apt-get install python-pil sudo apt-get install python-numpy sudo pip install RPi.GPIO sudo pip install spidev #python3 sudo apt-get update sudo apt-get install python3-pip sudo apt-get install python3-pil sudo apt-get install python3-numpy sudo pip3 install RPi.GPIO sudo pip3 install spidev
Download the demo
Open the terminal of the Raspberry Pi, execute command to download demo codes:
cd ~ git clone https://github.com/waveshare/Touch_e-Paper_HAT
Running the demo
C
Enter the directory of the C demo
cd ~/Touch_e-Paper_Code/c/examples
【Note】You can switch dependent libraries by modifying lines 14-16 of the Makefile. The program uses BCM2835 by default, which runs the fastest.(If you have already used BCM2835, you need to reboot the system when you switch to another library so that the demo can run normally.)
As shown in the picture below, switch libraries by commenting the lines:
Using the following commands to run the demo:
sudo make clean sudo make -j4 sudo ./main
python Enter the directory of the python demo
cd ~/Touch_e-Paper_Code/python/examples
Enter the following commands, the demo can support python2/3: The following uses the 2.9inch Touch e-paper HAT as an example
# python2 sudo python2 TP2in9_test.py # python3 sudo python3 TP2in9_test.py