Universal Library to drive OLED and LCD


From time to time I love using LCD to display “what is going on” in my projects. Led are fine but sometimes not enough and serial need to be physically connected to a computer. Not the best choice when working with “mobile” boards, for example Lipo powered.

I used to work with LCD such as HD44780 but they are very consuming (on power view) and big, and as my projects are smaller and smaller (on PCB view) I needed quick and small displays. Then I found the Adafruit I2C/SPI OLED that where perfect for my need. Small connection wire because on I2C or SPI, and easy to fit when PCB was created with this specific connection. This is why I put this kind of connector on ArdpuiPi board.

Adafruit I2C OLED

Adafruit I2C OLED

I started then to drive this OLED with the Adafruit demo code on my Arduino and I also ported the code to be run on Raspberry PI. Check this post if you want more details and source code.

But I found this OLED not very cheap and shipping to France is not very cheap too. So I started to find a new one. That was a nice idea ! It took me some time but I think I found “the one”, cheaper, smaller but with more pixels to display (128×64) and just 4 wires to connect. And most of all it is using the same controller (SSD1306) so the same code could be used without any modification (except I2C address).

Tindie OLED choice

This OLED come from Tindie and come in 2 versions, the 3.3V with minimal component for $9 and 5V compatible with onboard regulator for $12. It’s up to you to choose your needed version, but I always use the $9 version but take care 3V3 only, no Lipo at 3.7V that start with 4.2V, always remember that. This OLED have an unbeatable price.

Tindie OLED

Tindie OLED

The design is done by miker and he decided to give all needed information if you want to DIY. Really nice job and sharing. This is my favorite display for now and I always put 4 holes on my PCB to put this OLED. But do not forget the pullup on your board (I use 4.7K), I used to have some problems even using the Arduino integrated pullup. 😉

As said previously, I successfully used the Adafruit library to drive it without any problem until on a huge project I was out on RAM on Arduino. then I realized that Adafruit driver just take 512 bytes of RAM to buffer the OLED data. That is pretty in most case but not in mine. So I started to investigate on how other drivers was written (seeedstudio oled for example does nut use RAM buffer, but write directly to the driver, but quite complicated to manage from my point of view). Then I found the ultimate driver.

u8glib driver to display on OLED and LCD

The u8glib driver is an open source driver capable of driving so much LCD and OLED that I can call it universal. For the Tindie OLED (or Adafruit) the driver need 128 bytes of RAM instead 512, that is exactly what I needed. The author is also very accessible to reply to email, that is perfect.

Reading the documentation, first time driving OLED with the method firstPage() nextPage() seems tricky but the idea is pretty good, this is an excellent method to save precious RAM. It take also a little time more to display but every gain need compromise. I needed RAM, not time. This is my driver’s choice.

Also this driver come with so much integrated fonts that is really easy to find one that correspond to your choice. Font is added to PROGMEM code only if used, that is also a good thing. Of course if you need program code space, there is also limited fonts to save ROM code.

Check out documentation, sample code and all what you need to use it on the excellent documentation done by the Author.

Once again thank to Miker and Oliver, guys, you done a fantastic job, I find natural to promote it and leave a word on what you did, I use it day by day and you can checkout your job in action on my RF range tester using ArduiLED board.



You can discuss about this article or other project using the community forum