How to make your OLED display 10x slower!∞
I have been working on some Arduino-related things recently, which involved displaying some things on an OLED display (this one). However, I was very disappointed by how slow it was.
It took about 30ms per character to update, which was really disappointing. Knowing not much about actual hardware, possibilities, or how slow/fast it should be, I just continued on, assuming I’d just have to work with it.
It turns out I do not.
The display in question is an I2C display, connected on the
A5 pin on the Arduino Uno
board I’m using. And initially, it really was connected on those two pins, because that is what
I found in the code sample from the seller:
#include <U8x8lib.h> // this will be hella slow, mind the _SW_ constructors U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=A5*/ A5, /* data=A4*/ A4);
The problem is that it was doing the I2C communication in software, which apparently is really
slow. The funny thing is that on the Arduino the pins actually have multiple purposes,
A5 in particular are also special I2C pins, then called
And using a different configuration for the
u8x8 display library, it suddenly was about ten
times faster with updates. About 30ms for a “full screen” update now, and 2ms for smaller
// _much_ faster U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8;
So… if you want your OLED display to be really slow, do as I demonstrated. Otherwise, mind the
u8x8 constructors with
SW (i.e. software) in the name, and stick with the ones that use the
actual capabilities of the hardware.
Some more info:
- forum post mentioning I2C vs SPI speeds
(SPI would be even faster, probably also more expensive)
- interestingly, SPI might also be used to connect multiple Arduino’s, e.g. to run processing and UI functionality on different boards
- Arduino Uno pinout diagram (also linked in the text above)
- OLED libararies: u8g2 and u8x8
u8x8is part of
u8g2, but uses less memory, but can’t do graphics, only text)
See you soon (ah well, let’s see) with more Arduino things, voltage ladders and USB-MIDI firmware tricks! Oh my! :)