This is a 2.23inch OLED display with a controller. You can directly add it on Raspberry Pi by the 40 PIN pinheader, or connect it to another hardware platform via the IIC and SPI interfaces. The interface of 2.23inch OLED HAT is the default SPI, you can also switch to I2C by soldering the resistors on the back of the OLED.
- Controller: SSD1305
- Interface: SPI/I2C/OLED
- Resolution: 128 * 32
- Display size: 2.23inch
- Pixel size: 0.41mm x 0.39mm
- Display color: White
- Working voltage: 3.3V
- Working temperature: -40~70℃
|CS||Chip select (Low active)|
|DC||register / Data selection (SPI)|
|RST||Reset (Low active)|
The module uses the SPI communication mode by default, that is, BS1, BS2, DIN, CLK, CS, and DS connect the 0R resistor to the upper two pads by default. The welding method shown in the figure above is to select the I2C communication method. The specific hardware connection is shown in the following table: Note: The above picture is the welding on the hardware, the following table is the actual hardware connection.
- SSD1305 is a 132*64 pixel OLED controller, but the OLED only has 128*32 pixels, so the screen only uses the first part of the SSD1305 cache;
- The OLED supports 8bit 8080 parallel, SPI and I2C, and other communication methods, but considering the size of the module and saving the precious IO resources of the microcontroller, the 8bit 8080 parallel method is abandoned and supports the communication method of I2C and SPI.
Communication Protocol I2C
- During I2C communication, first send a 7-bit slave device address + 1 bit read and write bit, and wait for the device’s response.
- After the slave device responds, a control byte is sent, which determines whether the following byte is a command or data, and then waits for the slave device to respond.
- After the slave device replies again if a command is sent, only a one-byte command is sent. If data is sent, only one byte can be sent, or multiple bytes of data can be sent together, depending on the situation.
- See Datasheet Page 22 Figure 8-6 for details.
SPI Communication Timing
- As shown in the figure above, the data on SDIN is shifted into an 8-bit shift register on each rising edge of SCLK in MSB first LSB last order.
- D/C# is sampled at every 8th clock, and the data in the shift register is written to the Graphics Display Memory (GDDRAM) or command register, at the same count clock.
- In serial mode, only write operations are allowed. Write operation process in 4-wireSPI mode.
- See Figure 8-5 on Datasheet Page 21 for details.
Provides C and Python demo
- Open the Raspberry Pi terminal and enter the following command to enter the configuration interface