SSD1309 OLED With Toit
![IMG_5913.JPG](/proxy/?url=https://content.instructables.com/FY7/FYWE/L0VBH27L/FY7FYWEL0VBH27L.jpg&filename=IMG_5913.JPG)
There's been a Toit driver for the ubiquitous SSD1306 OLED around for a while, but some OLEDs are controlled by the SSD1309 instead. In this instructable I'd like to show how to interface one of these using Toit and a 128x64 pixel OLED.
Supplies
- ESP32 dev kit. I like this one since it has a narrower form factor and is therefore better suited for breadboards. The form factor leaves breadboard-space on both sides of the dev kit for connections.
- SSD1309 OLED.
Hooking Up the Hardware
![Screenshot 2022-03-18 at 10.06.25.png](/proxy/?url=https://content.instructables.com/FJG/4OZ0/L0VBH2PS/FJG4OZ0L0VBH2PS.png&filename=Screenshot 2022-03-18 at 10.06.25.png)
Connecting the HW is trivial. Here's where the Huzzah GPIO should go:
- GPIO 22 - SCL
- GPIO 23 - SDA
- GPIO 25 - RST
- GPIO 32 - CS
- GPIO 14 - DC
Apart from this we power our OLED with 5V from the battery input (Pin labelled BAT on the Huzzah) and finally we connect GND.
Importing Required Toit Packages
![IMG_5916.jpg](/proxy/?url=https://content.instructables.com/FQ0/79LK/L0VBH2U1/FQ079LKL0VBH2U1.jpg&filename=IMG_5916.jpg)
The Toit package manager contains drivers for the SSD1306. You need to install the required packages by running
$ toit pkg install github.com/toitware/toit-ssd1306
$ toit pkg install github.com/toitware/toit-pixel-display
This should import the required drivers and allow you to import them into your Toit code.
The Toit Code
![IMG_5917.jpg](/proxy/?url=https://content.instructables.com/FU9/G1OY/L0VBH2UR/FU9G1OYL0VBH2UR.jpg&filename=IMG_5917.jpg)
Toit code to demonstrate both how to add graphical content and text to the OLED can be found in this repository: