Adding a tiny OLED display to the Particle Photon

Mark Zachmann
Home Wireless
Published in
2 min readSep 14, 2017

I’m creating a hardware product that has a fair amount of data to display to the user. The first design had 6 LEDs that would glow depending on status. Then I noticed this cool 1" OLED display that you can buy for $9 on Amazon or about $3 at Aliexpress.

Monochrome OLED with Yellow area at top

There’s a full color version for $12 that I didn’t bother with.

If you want a finished board to play with Sparkfun offers an OLED shield for the particle for $20.

Adafruit offers a 1.3" slightly larger display for $20.

Overview

I split this article into two pieces. The first piece (this one) is about how to connect up the system. The second (more interesting) piece is how to implement high quality bitmap fonts for use in this system.

Hardware Connection

Connecting the system couldn’t be easier. There’s a VCC of 3.3V, Gnd connection and then SDA/SCL as an I2C connection. On the Particle Photon those are usually at D0,D1 so that’s what I used. You don’t even need a pull-up resistor.

I did a simple prototype and that’s shown below. You can easily see where the wires go.

Prototype (note plastic still on display)

Software Support

Getting the software running, not surprisingly, was the hardest part of the task. There are a few things going around that work ok. I ended up starting with a demo app that did totally work. This at least validates the display and gives you a starting point.

I used an application that’s available on the Particle Build Web IDE named ssd1306_128x64_i2c. It almost compiles but there’s a small bug in one of the library files where a macro is redefined. I ended up putting all the code local so I could fix that (precede it by an #undef in Adafruit_GFX.cpp).

#undef pgm_read_byte
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))

SparkFun has a library on Github that looks pretty good and is Photon specific. The library on the Particle Build site is from Adafruit and was a bit more Arduino but did support the Wire interface (which is the built-in SPI code in the Photon).

The only thing I had to do was set the start address to 0x3C instead of 0x3d to get a working application.

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

--

--

Mark Zachmann
Home Wireless

Entrepreneur, software architect, electrical engineer. Ex-academic.