Fork me on GitHub

Project Notes

#527 SSD1306 With u8g v2

Testing an SSD1306 128x32 OLED with the new v2 u8g library over I²C.

Build

Notes

I grabbed a white 128x32 0.91” OLED Module to test for a new project, and discovered there’s a new version of the U8g library (v2) that’s also worth checking out.

It seems the author has put a lot of work into refactoring and improving what was already one of the best lightweight libraries for driving monochrome displays.

One of the main differences is that Arduino support is provided in two classes that can be chosen to best suit the application:

  • U8g2 - includes all graphics procedures, many fonts, but requires buffer memory
  • U8x8 - text only, fonts that fit an 8x8 grid, writes direct to device (no buffer memory)

I cobbled together two sketches to test each of the interfaces: DemoU8g2 and DemoU8x8 respectively.

OLED Module Specs

  • OLED display, self-illuminating (no backlight), also lower consumption.
  • Driver IC: SSD1306
  • Size: 0.91 inch
  • OLED Resolution: 128 x 32
  • I²C interface
Pin Description
GND Power Ground
VCC Power + (DC 3.3~5v)
SCL Clock Line
SDA Data Line

oled_mechanical1 oled_mechanical2

Construction

The module works well on 3.3V or 5V. I have added pull-up resistors on the I²C, but with short jumper wires these don’t seem essential. Combinations I’ve tested that work:

  • 5V Arduino, 3.3V power to OLED, with pull-up resistors
  • 5V Arduino, 5V power to OLED, with pull-up resistors
  • 5V Arduino, 5V power to OLED, no pull-up resistors

Breadboard

Schematic

Testing

Testing a couple of fonts with the U8g2 library API. Flash size: 9482 bytes.

DemoU8g2

Testing a couple of fonts with the U8x8 library API. Flash size: 6764 bytes.

DemoU8x8

Credits and References

About LEAP#527 OLEDArduino
Project Source on GitHub Project Gallery Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is just my personal collection of projects. Two main themes have emerged in recent years, sometimes combined:

  • electronics - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting
  • scale modelling - I caught the bug after deciding to build a Harrier during covid to demonstrate an electronic jet engine simulation. Let the fun begin..
To be honest, I haven't quite figured out if these two interests belong in the same GitHub repo or not. But for now - they are all here!

Projects are often inspired by things found wild on the net, or ideas from the many great electronics and scale modelling podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know (or send a PR!). See the individual projects for credits where due.