Writings - SSD1306 OLED with a Raspberry Pi Pico

Niek Sanders, September 2021

My weekend project was getting a tiny 128x64 pixel OLED display working with my Raspberry Pi Pico. My goal was to learn the I2C protocol. So instead of using an existing library, I snagged the SSD1306 datasheet and spent many hours of toil writing my own to achieve:

Demo of SSD1306 driven by RPi Pico.

The first hiccup was getting the display turned on. Applying 3.3V or 5V to the OLED does nothing. It just sits there stubbornly inert. It turns out that a complicated initialization sequence is needed:

Initialization sequence for SSD1306 driver IC.

Which brought me to the second hiccup. I couldn't get the OLED to "ack" any of my I2C commands. With my oscilloscope and some manual decoding I confirmed my code was correct. It took another hour to figure out that the I2C address printed on the OLED PCB is a lie. The real one matches the SSD1306 datasheet: 0x3C or 0x3D.

Incorrect I2C address printed on PCB.

Finally I had the OLED powered up and displaying pixels. Then I realized I didn't have a font. A practical (and smarter) person would have googled for a minute to find something suitable. Instead I channeled my inner masochist and made my own 16-pixel-high font in Gimp:

Numbers font created for SSD1306.

This slurped up two hours of my life. Passing years have not made me a better graphic designer. The alarm clock inspired font above was my third attempt at making something usable. It looks surprisingly good on the OLED.

I now feel pretty comfortable with I2C... so mission accomplished. I also learned more than I ever wanted about the Solomon SSD1306 OLED driver IC. I won't publish my C code since it's crufty, but I'm happy to share it if somebody drops me a line.

>>> Writings