Template: 1.3inch OLED HAT
Specification
- Driver: SH1106
- Interface: 4-wire SPI, 3-wire SPI, I2C
- Resolution: 128 x 64
- Display Size: 1.3inch
- Outline Dimension: 65mm x 30mm
- Display color: blue
- Visible Angle: >160°
- Operating TEMP. (℃): -20~70
- Storage TEMP. (℃): -30~80
Pin Function
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 |
Hardware Configuration
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:
- Using 4-wire SPI:
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;
- Using 3-wire SPI:
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;
- Using I2C:
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