Raspberry Pi
Hardware Connection
Insert the LAFVIN 2.9 inch E-paper Module directly into the Raspberry Pi 40-pin GPIO header, and make sure all pins are aligned correctly before powering on.
E-paper module pin |
Raspberry Pi signal |
Physical pin |
|---|---|---|
VCC |
3.3V |
Pin 1 |
GND |
GND |
Pin 6 |
DIN / MOSI |
GPIO10 |
Pin 19 |
CLK / SCK |
GPIO11 |
Pin 23 |
CS |
GPIO8 |
Pin 24 |
DC |
GPIO25 |
Pin 22 |
RST |
GPIO17 |
Pin 11 |
BUSY |
GPIO24 |
Pin 18 |
Enable SPI Interface
Open the Raspberry Pi terminal and run the following command:
sudo raspi-config
# Select Interfacing Options -> SPI -> Yes to enable the SPI interface
Then restart your Raspberry Pi:
sudo reboot now
Check /boot/config.txt or /boot/firmware/config.txt to confirm that SPI is enabled:
sudo cat /boot/config.txt
# Or for newer systems
sudo cat /boot/firmware/config.txt
Download Demo Code
If you have already downloaded the code, you can skip this step.
git clone https://github.com/lafvintech/LAFVIN-2.9inch-ePaper-HAT.git
cd LAFVIN-2.9inch-ePaper-HAT/RPI
ZIP Download (Alternative)
If you prefer downloading a ZIP file, use the commands below. Rename the extracted folder to match the Git clone folder name, so all remaining commands are the same for both download methods.
wget -O main.zip https://github.com/lafvintech/LAFVIN-2.9inch-ePaper-HAT/archive/refs/heads/main.zip
unzip main.zip
mv -T LAFVIN-2.9inch-ePaper-HAT-main LAFVIN-2.9inch-ePaper-HAT
cd LAFVIN-2.9inch-ePaper-HAT/RPI
Choose a demo language:
C Language
Note
On the latest Raspberry Pi OS, the tested C demo only requires the lg
library. The other GPIO libraries below are optional; install them only
if your demo configuration requires them.
Install lg Library (Required)
Open the Raspberry Pi terminal and run the following commands:
wget https://github.com/joan2937/lg/archive/master.zip
unzip master.zip
cd lg-master
make
sudo make install
cd ..
For more details, refer to the source code: https://github.com/gpiozero/lg
Optional GPIO Libraries
Skip these installations for the tested lg demo on the latest
Raspberry Pi OS. Expand a section only if your demo configuration requires
that library.
Install gpiod Library (Optional)
Open the Raspberry Pi terminal and run the following commands:
sudo apt-get update
sudo apt install gpiod libgpiod-dev
Install BCM2835 (Optional)
Open the Raspberry Pi terminal and run the following commands:
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz
tar zxvf bcm2835-1.71.tar.gz
cd bcm2835-1.71/
sudo ./configure && sudo make && sudo make check && sudo make install
For more information, refer to the official website: http://www.airspayce.com/mikem/bcm2835/
Install WiringPi (Optional)
Open the Raspberry Pi terminal and run the following command:
sudo apt-get install wiringpi
For Raspberry Pi systems released after May 2019, you may need to upgrade WiringPi. Earlier systems may not require this step.
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
Running gpio -v should display version 2.52. If it does not, the installation was not successful.
For Bullseye systems, use the following commands instead:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
gpio -v
Running gpio -v should display version 2.60. If it does not, the installation was not successful.
Compile the Demo Program
Note
On the latest Raspberry Pi OS, install only the lg library before
compiling the tested C demo. The other GPIO libraries are optional and
are needed only if your demo is configured to use them.
-j4 uses 4 threads for compilation, and you can adjust the number as needed.
cd c
sudo make clean
sudo make -j4
Run the Demo Program
sudo ./epd
Python
Use Python 3
This example requires Python 3 (3.8 or later). Use the system python3
interpreter to run it.
Note
In our tested Raspberry Pi OS setup, the Python demo runs without any
additional library installation. Pillow and the Python lgpio module
are already available. Try running the demo first; use the collapsed
installation instructions below only if a missing-library error appears.
Download Demo Code
If you have already downloaded the code, you can skip this step and open
RPI/python/examples in the extracted project folder.
git clone https://github.com/lafvintech/LAFVIN-2.9inch-ePaper-HAT.git
cd LAFVIN-2.9inch-ePaper-HAT/RPI/python/examples
Run the Demo Program
sudo python3 epd_2in9g_test.py
The example loads the project driver directly from RPI/python/lib;
installing the project as a Python package is not required.
Install Missing Libraries
Pillow handles images, drawing, and fonts. The Python lgpio module
handles GPIO and SPI. Install only the library reported as missing, then
run the demo command above again.
Install Pillow If Missing
If the demo reports ModuleNotFoundError: No module named 'PIL', install
Pillow for the system Python 3 interpreter:
sudo apt update
sudo apt install python3-pil
Confirm that Pillow can be imported:
sudo python3 -c "from PIL import Image, ImageDraw, ImageFont; print('Pillow is available')"
Install Python lgpio If Missing
If the demo reports Cannot import lgpio or
ModuleNotFoundError: No module named 'lgpio', install the Python binding:
sudo apt update
sudo apt install python3-lgpio
Confirm that lgpio can be imported:
sudo python3 -c "import lgpio; print('lgpio is available')"