Template: 0.91inch-OLED-Module-RaspberryPi-Guides
Hardware connection
Please connect the LCD to your Raspberry Pi by the 7PIn cable according to the table below
OLED | Raspberry Pi | |
BCM2835 | Board | |
VCC | 3.3V | 3.3V |
GND | GND | GND |
DIN | SPI:10 / I2C:2 | SPI:MOSI / I2C:SDA.1 |
CLK | SPI:11 / I2C:3 | SPI:SCLK / I2C:SCL.1 |
Enable SPI interface
- Open terminal, use command to enter the configuration page
sudo raspi-config Choose Interfacing Options -> SPI -> Yes to enable SPI interface
sudo reboot
Please make sure that SPI interface was not used by other devices
I2C is the same, enter the configuration interface and select Interfaceing Options -> I2C -> Yes to open the IIC interface, and then restart
Install Libraries
- 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 the Raspberry Pi system after May 2019, it may need to be upgraded 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 Examples
Open Raspberry Pi terminal and run the following command
sudo apt-get install p7zip-full sudo wget https://www.waveshare.com/w/upload/2/2c/OLED_Module_Code.7z 7z x OLED_Module_Code.7z -O./OLED_Module_Code cd OLED_Module_Code/RaspberryPi
Run the demo codes
Please go into the RaspberryPi directory (demo codes) first and run the commands in terminal
C codes
- Re-compile the demo codes
cd c sudo make clean sudo make -j 8
- After the compilation is complete, the main file is generated, enter the command according to the OLED model you are using. If you have purchased a 1.3inch OLED Module (C), please enter the following command:
sudo ./main 1.3c
If you have purchased a 1.5inch RGB OLED Module, please enter the following command:
sudo ./main 1.5rgb
The command of each LCD model can check in the following table:
LCD model | Command |
---|---|
0.91inch OLED Module | sudo ./main 0.91 |
0.95inch RGB OLED (A)/(B) | sudo ./main 0.95rgb |
0.96inch OLED (A)/(B) | sudo ./main 0.96 |
1.3inch OLED (A)/(B) | sudo ./main 1.3 |
1.3inch OLED Module (C) | sudo ./main 1.3c |
1.5inch OLED Module | sudo ./main 1.5 |
1.5inch RGB OLED Module | sudo ./main 1.5rgb |
- Please make sure that the SPI is not occupied by other devices, you can check in the middle of /boot/config.txt
python
- Enter the python directory and run
cd python/examples
- Run the demo of the corresponding model OLED, the program supports python2/3
If you have purchased a 1.3inch OLED Module (C), please enter:
# python2 sudo python OLED_1in3_c_test.py # python3 sudo python3 OLED_1in3_c_test.py
If you have purchased a 1.5inch RGB OLED Module, please enter:
# python2 sudo python OLED_1in5_rgb_test.py # python3 sudo python3 OLED_1in5_rgb_test.pyre>
The command of each LCD model can check in the following table:
LCD Model | Command(python2) |
---|---|
0.91inch OLED Module | sudo python OLED_0in91_test.py |
0.95inch RGB OLED (A)/(B) | sudo python OLED_0in95_rgb_test.py |
0.96inch OLED (A)/(B) | sudo python OLED_0in96_test.py |
1.3inch OLED (A)/(B) | sudo python OLED_1in3_c_test.py |
1.3inch OLED Module (C) | sudo python OLED_1in3_test.py |
1.5inch OLED Module | sudo python OLED_1in5_rgb_test.py |
1.5inch RGB OLED Module | sudo python OLED_1in5_test.py |
- Please make sure that the SPI is not occupied by other devices, you can check in the middle of /boot/config.txt