Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales01@spotpear.com
dragon_manager@163.com
services01@spotpear.com
manager01@spotpear.com
WhatsApp:13246739196
1.3inch LCD HAT, SPI/I2C interfaces
PIN Function | BCM | Description |
KEY1 | P21 | Button 1/GPIO |
KEY2 | P20 | Button 2/GPIO |
KEY3 | P16 | Button 3/GPIO |
Joystick Up | P6 | Go Up |
Joystick Down | P19 | Go Down |
Joystick Left | P5 | Go Left |
Joystick Right | P26 | Go Right |
Joystick Press | P13 | Press Down |
SCLK | P11/SCLK | SPI Clock input |
MOSI | P10/MOSI | SPI Data input |
SCL | P3/SCL1 | I2C Clock Input |
SDA | P2/SDA1 | I2C Data Input |
DC | P24 | Data/Command |
CS | P8/CE0 | Chip Selection |
RST | P25 | Reset |
The OLED module provides three drive interfaces: 3-wire SPI, 4-wire SPI and I2C interface. There are six resistors that can be soldered on the back of the module. The corresponding communication method is selected by the electronic selection, as shown in the figure:
The module uses a 4-wire SPI communication mode by default, that is, BS0, BS1, DC, CS, CLK, and DIN are connected to 0 by default (1 and 0 do not represent the level, but the welding method of connecting or connecting the resistance, the specific hardware link is as follows surface):
Note: The above picture is the welding on the hardware, the following table is the actual hardware connection
Communication Method | BS1/BS0 | CS | DC | DIN | CLK |
3-wire SPI | 0/1 | CS | 1 | MOSI | SCLK |
4-wire SPI | 0/0 | CS | DC | MOSI | SCLK |
I2C | 1/0 | 0 | 1 | SDA | SCL |
The specific hardware configuration is as follows:
That is, the factory program settings: BS0 and BS1 connect 0 to ground, CS connect 0 to CE0 (enable pin), D/C connect 0 to P24 (data/command pin) of Raspberry Pi, DIN to 0 is connected to Raspberry Pi MOSI, and CLK to 0 is connected to Raspberry Pi SCLK;
Connect BS0 to 1 to VCC, BS1 to 0 to connect to GND, CS to 0 to connect to Raspberry Pi CE0, D/C to 1 to connect to GND, DIN to 0 to connect to Raspberry Pi MOSI, CLK to 0 to connect to the tree Raspberry Pi SCLK;
Connect BS0 to 0 to GND, BS1 to 1 to VCC (3.3V), CS to 1 to connect to GND, D/C to 1 to connect to GND, DIN to 1 to connect to Raspberry Pi SDA, CLK to 1 to connect to the tree Raspberry Pi SCL; when using I2C: the high and low states of DC can control the address of the slave device, here is connected to GND, then the 7-bit address of I2C is: 0x3C
sudo raspi-config Choose Interfacing Options -> SPI -> Yes to enable SPI interface
Reboot Raspberry Pi:
sudo reboot
Please make sure that the SPI interface was not used by other devices, and you can check it in /boot/config.txt.
To make sure SPI is not occupied, it is recommended to close other drivers' coverage. You can use ls /dev/spi to check whether SPI is occupied. If the terminal outputs /dev/spidev0.1 and /dev/spidev0.1, SPI is not occupied.
sudo raspi-config Select Interfacing Options -> I2C ->yes to start the i2C kernel driver
and the reboot RPi
sudo reboot
#Open the Raspberry Pi terminal and run the following command 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, please refer to the official website: http://www.airspayce.com/mikem/bcm2835/
#Open the Raspberry Pi terminal and run the following command sudo apt-get install wiringpi #For Raspberry Pi systems after May 2019 (earlier than before, you may not need to execute), you may need to upgrade: wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v # Run gpio -v and version 2.52 will appear. If it does not appear, the installation is wrong #Bullseye branch system use the following command: git clone https://github.com/WiringPi/WiringPi cd WiringPi ./build gpio -v # Run gpio -v and version 2.60 will appear. If it does not appear, it means that there is an installation error
#python2 sudo apt-get update sudo apt-get install python-pip sudo pip install RPi.GPIO sudo apt-get install python-smbus sudo pip install spidev #python3 sudo apt-get update sudo apt-get install python3-pip sudo pip3 install RPi.GPIO sudo apt-get install python3-smbus sudo pip3 install spidev
Run in the terminal of RPi:
sudo apt-get install p7zip-full wget https://www.waveshare.com/w/upload/5/53/1.3inch-OLED-HAT-Code.7z 7zr x 1.3inch-OLED-HAT-Code.7z -r -o. sudo chmod 777 -R 1.3inch-OLED-HAT-Code cd 1.3inch-OLED-HAT-Code/RaspberryPi/
cd C make clean make sudo ./main
#python2 cd python2 sudo python main.py sudo python key_demo.py #python3 cd python3 sudo python3 main.py sudo python3 key_demo.py
sudo nano /boot/config.txt #add: gpio=6,19,5,26,13,21,20,16=pu
Open C\obj\DEV_Config.h,change
#define USE_SPI 1 #define USE_IIC 0
To
#define USE_SPI 0 #define USE_IIC 1
and then execute again:
make clean make sudo ./main
Open python2/config.py, change:
Device_SPI = 1 Device_I2C = 0
To
Device_SPI = 0 Device_I2C = 1
and then execute again:
sudo python main.py
The same is true for python3
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 username you use, such as waveshare
sudo apt-get install python-smbus
sudo apt-get install python3-pil sudo apt-get install python3-numpy
sudo apt-get install p7zip wget https://www.waveshare.com/w/upload/5/53/1.3inch-OLED-HAT-Code.7z 7z x 1.3inch-OLED-HAT-Code.7z sudo chmod 777 -R 1.3inch-OLED-HAT-Code cd 1.3inch-OLED-HAT-Code/JetsonNano/
Due to the weak GPIO drive capability of Jetson Nano, it can only be controlled using SPI.
cd C make clean make sudo ./main
#python2 cd python2 sudo python main.py sudo python key_demo.py #python3 cd python3 sudo python3 main.py sudo python3 key_demo.py
Working current of 0.95inch RGB OLED: about 38mA for full white display, about 4mA for full black display.
The working current of 0.96inch OLED is about 25mA when fully on, and 1.5mA when fully off.