Getting started with μOLED displays

Wanna add some glam to your next project?? Then you are at the right place!! We are talking about μOLEDs, the latest trend in embedded sector. They are light, thin and elegant (and really interesting); thats why we wanted to do some sample projects with this beauty ever since we had the first piece of it, and finally we have done one!

Before we start here is a bit of technology behind the μOLEDs. μOLED stands for Micro Organic Light Emitting Diode, a flat light emitting technology that can provide brighter, crisper displays on electronic devices. We have used the1.30″ display, made of 128×64 individual white OLED pixels, each one is turned on or off by the controller chip. The graphic display panel uses the SH1106 display controller, designed for Common Cathode type OLED panel. The driver chip, SH1106 can communicate in two ways: I2C or SPI. The OLED itself require a 3.3V power supply and 3.3V logic levels for communication but the module boast off 3.3V regulation and level shift features, so you can use these things with 5V devices!.

We tried out both the SPI and I2C communication with the module using an Arduino Uno. It worked fine, well Uno comes handy for anything and everything these days. At first we used a level converter for communication and later we did it without any level conversion, both cases the module worked just fine. First we will have a look at the SPI interface and later on the IIC interface.

SPI Communication with the uOLED display

Caution: Even though the display seems to be 5V tolerant, we do recommend using 3V3 supply & 3V3 level converter while interfacing with 5V controllers.

Wire up your connections as shown here and you are ready to go on with the OLED SPI communication. By default the display module is SPI configured and therefore to work with SPI we wont have to mess up the module. The 4 wire serial interface consists of serial clock SCL, serial data MOSI, DC and CS. The OLED also has an additional reset pin (RES). The DC will determine whether the transferred data is written to the display data RAM or command register. You may change pins D/C, Reset and CS to map them to different pins on your Arduino board. Please keep SDA/DI and SCL/CLK connected to your Arduino’s MOSI and SCK (hardware SPI) pins. We used theSPI librarythat we found on thearduino forum, and here is the code that we used to display our own logo. We can display alphabets, numbers, symbols, images and anything once we learn to handle the pixels.

Attention! This is important! To display an image make sure that its size falls within the available pixel range (128×64). Only bitmap monochrome images can be crisply displayed as the display can produce either black or white pixels only. Hex data of the image can be obtained usingbit map converter, which can then be stored in an array as show in the code above.

IIC Communication with the uOLED display

As mentioned before, by default the module is configured for SPI interface. So we will have to change the configuration manually for IIC interface. Well thats simple, desolder the resistor R3, solder it on the vacant R1 slot and short the vacant R8 slot. Thats it and the module is IIC ready. Now, wire up the connection as shown above. For the IIC communication 4pins should connected between the module and the arduino; SCK, SCL, RES and DC.

As you have seen, hex data stored in program array was used to display graphics on the display.How do we scale and import a bitmap, then compile it into our Arduino code and send it to the display?? To begin, find a bitmap image that you’d like to print to your OLED. 128×64 monochrome pixels doesn’t give you a lot of room, but you can still get some fun stuff on there. After you’ve picked an image, you’ll need to massage it to make it both monochrome (2-bit color) and the required number of pixels. Most standard image editors can help with this.

The next step is converting that regular image file to an array of char’s. There are a number of programs that can help with this around the web. We recommend LCD Assistant.

To load up an image in LCD Assistant, go to File > Load Image. A preview of the image should open up, make sure it’s the right size. Also make sure the Byte orientation is set to Vertical and the Size endianness is set to Little. The rest of the default settings (8 pixels/byte, etc.) should already be set correctly:

Then go to File > Save output to generate a temporary text file. Open that text file to have a look at your shiny new array. With that array created, copy the entire table over to your Arduino sketch. Fun stuff! Now you can overlay text, or draw on your bitmap. You can even try importing multiple graphics to create animations!