Difference between revisions of "Template:Hardware/Software setting for SPI e-paper"

From Waveshare Wiki
Jump to: navigation, search
Line 109: Line 109:
 
sudo pip3 install spidev
 
sudo pip3 install spidev
 
</pre>
 
</pre>
 
+
Note: if you install on Raspian Lite, the git package is not istalled by default.
 +
*Install git
 +
<pre>
 +
sudo apt-get install git -y
 +
</pre>
 
;Download examples
 
;Download examples
 
----
 
----

Revision as of 07:48, 14 October 2020

We provide examples for four popular platforms: Arduino UNO, Jetson Nano, Raspberry Pi, and STM32. You can refer to the corresponding part according to the platform you use(This is a common template will be used by all types of the e-Paper, please refer to the corresponding type you have)

Arduino UNO

The example we provide for Arduino platform is based on Waveshare UNO PLUS (it is compatible with official Arduino UNO R3). If you use other Arduino board which is not compatible with UNO, you may need to change the wring.

Hardware connection

Connect to Arduino UNO
e-Paper Arduino
Vcc 5V
GND GND
DIN D11
CLK D13
CS D10
DC D9
RST D8
BUSY D7
Running examples

Download demo codes from Resources, unzip it to get projects. Arduino example is located in the directory ~/Arduino UNO/…
Open project according to the type. For example, if the e-Paper you have is 1.54inch e-Paper Module, please open the epd1in54 folder and run project epd1in54.ino.
Open project, choose the correct Board and Port, then compile and upload it to board.
Note: Because of the small RAM of Arduino, it cannot support drawing function, therefore, we only provide image display function. The image data are stored in flash. Or you can think about using Waveshare e-Paper Shield for Arduino board

Raspberry Pi

Hardware connection

If the board you get is the HAT version like 2.13inch e-Paper HAT, you can directly attach it on the 40PIN GPIO of Raspberry Pi. Or you can wire ti to Raspberry Pi with 8PIN cable.

Connect to Raspberry Pi
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

Enable SPI interface

PS: If you are using a system with a Bullseye branch, you need to change "apt-get" to "apt", and the system of the Bullseye branch only supports Python3.
  • 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

RPI open spi.png
Reboot Raspberry Pi:

sudo reboot

Make sure that the SPI is not occupied by other devices, you can check in the middle of the /boot/config .txt.


Libraries Installation

  • Install BCM2835 libraries
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz
tar zxvf bcm2835-1.60.tar.gz 
cd bcm2835-1.60/
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:
cd /tmp
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

Note: if you install on Raspian Lite, the git package is not istalled by default.

  • Install git
sudo apt-get install git -y
Download examples

Open terminal and execute command to download demo codes

sudo git clone https://github.com/waveshare/e-Paper
cd e-Paper/RaspberryPi\&JetsonNano/
Running examples

  • C codes

Find the main.c file, uncomment the definition of e-Paper types, then compile and run the codes.

cd c
make clean
make
sudo ./epd
  • python

Run examples, xxx is the name of the e-Paper. For example, if you want to run codes of 1.54inch e-Paper Module, you xxx should be epd_1in54

cd python/examples
# python2
sudo python xxx.py
# python3
sudo python3 xxx.py

Jetson nano Developer Kit

The example for Jetson Nano use software SPI, speed of sfotware SPI is a little slow

Hardware connection

Jetson Nano's 40PIN GPIO is compatible with Raspberry PI, and API of Jetson.GPIo is same as RPi.GPIO, therefore, the pin numbers of Jetson nano are same as Raspberry Pi's

Connect to Jetson Nano
e-Paper Jetson Nano Developer Kit
BCM2835 Board
VCC 3.3V 3.3V
GND GND GND
DIN 10(SPI0_MOSI) 19
CLK 11(SPI0_SCK 23
CS 8(SPI0_CS0) 24
DC 25 22
RST 17 11
BUSY 24 18
Software setting

  • Open terminal, and install GPIO libraries :
sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install Jetson.GPIO
sudo groupadd -f -r gpio
sudo usermod -a -G gpio your_user_name
sudo cp /opt/nvidia/jetson-gpio/etc/99-gpio.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger

Note: your_user_name is the user name of your Jetson, for example:waveshare

  • Install I2C libraries
sudo apt-get install python-smbus
  • Install PIL libraries
sudo apt-get install python3-pil
sudo apt-get install python3-numpy
Download examples

Open terminal and execute commands:

sudo git clone https://github.com/waveshare/e-Paper
cd e-Paper/RaspberryPi\&JetsonNano/
Running examples

  • C codes

Find main.c file, Open it and uncommend the e-Paper which you use, compile and run it

cd c
make clear
make
sudo ./epd
  • python

Run examples, xxx is the name of e-Paper. For example, if you want to run examples of 1.54inch e-Paper Module, xxx should be epd_1in54

cd python/examples
# python2
sudo python xxx.py
# python3
sudo python3 xxx.py

STM32

Hardware connection

The examples we provide are based on Wavshare Open103Z, the connecting method provide is based on STM32F13ZET6 as well. For other board, please port it by yourself.

Connect to STM32F103ZET6
e-Paper STM32F103ZET6
Vcc 3.3V
GND GND
DIN PA7
CLK PA5
CS PA3
DC PA2
RST PA1
BUSY PA3
Running examples

Enter the directly of STM32 examples, open project by Keil5 software. Set Board and programmer, then compile and download it to board