#527 SSD1306 With u8g v2
Testing an SSD1306 128x32 OLED with the new v2 u8g library over I²C.
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 |
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
Testing
Testing a couple of fonts with the U8g2 library API. Flash size: 9482 bytes.
Testing a couple of fonts with the U8x8 library API. Flash size: 6764 bytes.