Difference between revisions of "1.3inch OLED Module (C)"
Line 1: | Line 1: | ||
− | <div class=" | + | |
− | {{infobox item | + | <div class="wiki-pages blue-color"> |
+ | |||
+ | {{infobox item|colorscheme=blue | ||
|img=[[File:1.3inch-OLED-Module-C-1.jpg|360px|alt=1.3inch-OLED-Module (C)|{{Amazon_nolink|default={{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}|url=link=https://www.waveshare.com/1.3inch-oled-module-c.htm}} | 1.3inch OLED Module (C)]] | |img=[[File:1.3inch-OLED-Module-C-1.jpg|360px|alt=1.3inch-OLED-Module (C)|{{Amazon_nolink|default={{#ifeq: {{#urlget:amazon|0}}|{{#urlget:Amazon|0}}| default|}}|url=link=https://www.waveshare.com/1.3inch-oled-module-c.htm}} | 1.3inch OLED Module (C)]] | ||
|category=[[:Category:OLEDs / LCDs|OLEDs / LCDs]] | |category=[[:Category:OLEDs / LCDs|OLEDs / LCDs]] |
Revision as of 02:21, 10 June 2022
| ||
1.3inch LCD HAT, SPI/I2C interfaces
More |
Product Specification
- Working Voltage:3.3V
- Communication Interface:SPI/IIC
- Controller:SH1107
- Resolution:64 × 128
- Display Area:14.7 × 29.42 (mm)
- Pixel size:0.15 × 0.15 (mm)
- Dimension:30 × 39.5(mm)
Pins
PIN | Description |
VCC | Power input(3.3V) |
GND | Ground |
DIN | MOSI pin of SPI (Data input) |
CLK | SCLK pin of SPI (Clock input) |
CS | Chip selection, low active |
DC | Data/Command, Low for command and High for data |
RST | Reset, Low active |
OLED and its controller
This OLED integrates the SH1107 controller which has 128x128 bits SRAM, supports 128x128 resolution. The controller features SPI/IIC/ 6800/8080 interface and 256 brightness levels. The resolution of this 1.3inch OLED is only 64x128, only half of the SRAM is used.
This OLED use four-line SPI and I2C interface for communicating, which supports higher compatibility and speed.
Protocol
Note: The MISO pin is hidden, for more details, you can refer to Datasheet Page11.
CS: Chip selection of the slaver, the chip is activated when CS is Low;
SI(D1): This is MOSI pin, the pin is used to transmit data from master to slaver;
SCL(D0)is the SPI clock
A0: This is the DC pin, it is used to determine the data input, DC=0: command is sent;
SPI communication has data transfer timing, which is combined by CPHA and CPOL.
CPOL determines the level of the serial synchronous clock at an idle state. When CPOL = 0, the level is Low. However, CPOL has little effect on the transmission.
CPHA determines whether data is collected at the first clock edge or at the second clock edge of the serial synchronous clock; when CPHL = 0, data is collected at the first clock edge.
According to the figure, SCL is high in idle and it starts to transmit data at the second edge. therefore the timing is Mode 3 (0x11). Data is transmitted in MSB format.
We provide examples that are based on BCM2835、WiringPi、File IO and RPI(Python)librraies.
Hardware connection
You should connect the OLED to your Raspberry Pi by the 7pin cable according to the table
OLED | Raspberry Pi | |
BCM2835 | Board | |
VCC | 3.3V | 3.3V |
GND | GND | GND |
DIN | SPI:10 / IIC:2 | SPI:MOSI / IIC:SDA.1 |
CLK | SPI:11 / IIC:3 | SPI:SCLK / IIC:SCL.1 |
CS | 8 | CE0 |
DC | 25 | GPIO.26 |
RST | 27 | GPIO.2 |
Enable SPI and IIC Interface
- Open the Raspberry Pi terminal and run the following command
sudo raspi-config Choose Interfacing Options -> SPI -> Yes
Choose Interfacing Options -> I2C -> Yes
Reboot Raspberry Pi:
sudo reboot
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
下Downlaod example
Open the terminal and run the following commands:
sudo apt-get install p7zip-full sudo wget https://www.waveshare.com/w/upload/3/37/1.3inch_OLED_Module_C_code.7z 7z x 1.3inch_OLED_Module_C_code.7z -O./1.3inch_OLED_Module_C_code cd 1.3inch_OLED_Module_C_code/raspberry/
Run the test codes
Please first go into the raspberry directory of examples and then run the following command:
C Code
- Compile the codes
cd c sudo make clean sudo make -j 8
Run the codes:
sudo ./main
Python
- Go to the python directory
cd python/
- run main.py
# python2 sudo python main.py # python3 sudo python3 main.py
STM32 guides
The examples is based on STM32F103RBT6
Harware connection
The examples is based on STM32F103RBT6, if you want to use the OLED with other STM32 board, you should porting the codes to your project.
OLED | STM32 |
VCC | 3.3V |
GND | GND |
DIN | SPI:PA7 / IIC:PB9 |
CLK | SPI:PA5 / IIC:PB8 |
CS | PB6 |
DC | PA8 |
RST | PA9 |
Run demo codes
The examples provided are based on HAL libraries.
Download the demo codes and go into STM32 directory
Open the oled_demo.uvprojx project by Keil5, which is located in 1.3inch_OLED_Module(C)_code\STM32\MDK-ARM, compile and download it to your STM32 board
Arduino guides
Hardware connection
The examples and connections are based on Arduino UNO, if you want to use the OLED with other type of Arduino, you need to correct the connection and codes according to the Arduino board.
OLED | UNO |
VCC | 3.3V |
GND | GND |
DIN | SPI:11 / IIC:SDA |
CLK | SPI:13 / IIC:SCL |
CS | D10 |
DC | D7 |
RST | D8 |
Run the example
Download the demo codes and go into Arduino directory.
Open the OLED_Show.ino file by Arduino IDE, which is located in 1.3inch_OLED_Module(C)_code\Arduino\OLED_Show, compile and upload the codes to your Arduino board