0.96-inch I2C Monochrome Display
Module Source
Purchase link: https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-23284685151.19.1ffe61919S9gQy&id=40809409804 Materials download link: https://pan.baidu.com/s/1xy2zH8-hs-S8-_AcVtBP_g Materials extraction code: 0jhj
Specifications
Operating voltage: 3.3V Operating current: 9 mA Module size: 27.3 x 27.8 mm Pixel size: 128(H) x 64(V) RGB Driver chip: SSD1306 Communication protocol: I2C Number of pins: 4 Pin (2.54mm pitch header)
Principle Analysis
The I2C bus requires only two data lines: the serial data line (SDA) and the serial clock line (SCL), which makes it a very simple interface.
In the I2C protocol, there is one master device and multiple slave devices on the bus. The master device controls the communication process on the bus and is responsible for initiating, controlling, and terminating communication. Slave devices must wait for requests from the master device to receive or send data. Data exchange between the master and slave devices uses a frame format, where each frame typically contains address, data, and control information. The master device selects the device to communicate with based on the slave device's address, and the slave device performs the corresponding operation based on the control information.
This module uses I2C communication, which generally only requires sending data and receiving ACK responses. The I2C communication flow follows these steps:
- The master sends a START signal to the bus.
- The master sends the device address and the read/write (R/W) bit to be communicated with onto the bus.
- After receiving the address, the device sends an acknowledgment signal. After receiving the acknowledgment, the master sends data or continues sending the address.
- After receiving the data, the device sends an acknowledgment signal. After receiving the acknowledgment, the master can continue sending data or stop communication.
- The master sends a STOP signal to the bus.
WARNING
📌 Note: On the LCSC-Openkits (LCKFB) ESP32-S3 dev board, any GPIO pin routed out from the dev board can be used as an I2C hardware pin.
From the chip control specification manual, we can understand the I2C bus data frame format. The module address is 0x78.
The screen has 128 columns (Column) and 64 rows (Row), for a total of 128*64 pixels. Every 8 rows form one page, and there are 8 pages in total.
Taking the second page as an example: each column is stored in one byte, so one page requires 128 bytes. Note that the low bit is at the bottom.
Porting Process
Our goal is to port the example to the ESP32-S3 dev board. Complete driver code has been provided for you. Follow the steps below to complete the porting.
Software I2C Porting
This screen requires 4 interfaces. For specific interface descriptions, see Table 1.4.1-1 Pin Descriptions.
The module is an I2C communication protocol slave. SCL is the I2C signal line, and SDA is the I2C data line.
The pins selected here are shown in Table 1.4.1-2 Software I2C Wiring.
Copy the prepared [OLED] folder into the main folder of your project.
Software I2C OLED driver code (adapted):
File Download
📌 Materials Download Center (Click to Jump)
📌 In the Materials Download Center -> Module Porting Materials Download, inside the compressed package of this chapter.
Open your project and import the files we just copied into the .c and .h file paths.
- In VSCode, open the CMakeLists.txt file in the main folder.
- Add these two paths.
The software I2C porting is now complete. Please proceed to section 1.5 for porting verification.
Hardware I2C Porting
This screen requires 4 interfaces. For specific interface descriptions, see Table 1.4.2-1 Pin Descriptions.
The module is an I2C communication protocol slave. SCL is the I2C signal line, and SDA is the I2C data line.
The pins selected here are shown in Table 1.4.2-1 Hardware I2C Wiring.
Copy the prepared [OLED] folder into the main folder of your project.
Hardware I2C driver code:
File Download
📌 Materials Download Center (Click to Jump)
📌 In the Materials Download Center -> Module Porting Materials Download, inside the compressed package of this chapter.
Open your project and import the files we just copied into the .c and .h file paths.
- In VSCode, open the CMakeLists.txt file.
- Add these two paths.
The hardware I2C porting is now complete. Please proceed to the last section for porting verification.
Porting Verification
Enter the following code in main.c:
#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_flash.h"
#include "oled.h"
#include "esp_timer.h"
void app_main(void)
{
OLED_Init(); // Initialize OLED
OLED_Clear();
while(1)
{
OLED_ShowString(0,0,(unsigned char*)"ABC",8,1);//6*8 "ABC"
OLED_ShowString(0,8,(unsigned char *)"ABC",12,1);//6*12 "ABC"
OLED_ShowString(0,20,(unsigned char *)"ABC",16,1);//8*16 "ABC"
OLED_ShowString(0,36,(unsigned char *)"ABC",24,1);//12*24 "ABC"
OLED_ShowChinese(54,0,3,16,1);//Display Chinese character
OLED_ShowChinese(72,0,4,16,1);//Display Chinese character
OLED_ShowChinese(90,0,5,16,1);//Display Chinese character
OLED_ShowChinese(108,0,6,16,1);//Display Chinese character
OLED_Refresh();
delay_ms(500);
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Power-on effect: