arduino oled

Cheap OLED Displays and Arduino

oled We all like cheap items off eBay especially if they do cool and unusual things, sometimes we get so carried away by the price that we do not even realize that fact that we do not know anything about making the product work. A while back, I was browsing through eBay dreaming of all the stuff I can buy if I become rich. Then I came across something very interesting. A set of two OLED displays with a 1.3” screen size. Very small but should be good for some Arduino projects, right? After a quick skim over the description, I found a few words that said here is the link to the library… In no time, the OLEDs where sold.

Let us talk a little more about what OLED displays are and why anyone would consider using them in their projects. OLED stands for organic light emitting diode. On the microscopic level, an OLED display is a matrix of organic LEDs that light up when they emit energy. Old LCD (Liquid Crystal Display) technology uses electronically controlled polarizers to change the way light passes or does not pass through them. This requires an external backlight the lights up the whole display underneath. This uses a lot of energy because at the time the display is on, enough light for all pixels must be provided. The new OLED technology only uses electricity per pixel. Because each pixel creates its own light, only the pixels that are on use electricity. This makes OLED technology very efficient; also, the way these types of OLEDs are built allows them to be very thin compared to LCD. That is why all the new TVs that are coming out are super thin. There is more to OLED technology but “HowStuffWorks” does a good job at explaining all the fine details of OLED technology.

Related Products: Displays | Display Misc

After waiting almost a month, I opened up the OLED and went right to testing it out. The link in the description pointed me to this website, which is a tutorial from Adafruit. Apparently, Adafruit also makes small OLEDs displays that are very similar to the ones I received. After going through the tutorial, adding the library, and setting up all connections, I load the Arduino example file and get something like this.

arduino oled

Very useless… however the image above shows a good example of the limitations of OLED displays because Of the way they’re built OLEDs have s slower refresh rate which is seen as darker lines on the OLED in the picture. At this point, I got very discouraged, set this OLED in my electronics box, and forgot about it. A few months past and I gained some interest in making this OLED work. Therefore, I started to do some research. I found a library that supports all sorts of displays for Arduino, and it supports Adafruit’s OLED. I loaded it up and got it to turn on, very exciting!

Related Products: OLED Modules | LCD Monitors

Here is what I did…

1. Connect the OLED as follows:

OLED Arduino
SCL pin 5
SDA pin 4
RST pin 3
D/C pin 2
CS pin 10 (optional)

To add CS (chip select) you have to solder a wire to the back of the OLED where it says chip select.

2. Download the U8glib library from their website and place it into libraries folder of your Arduino.

3. Now here is the tricky part that will make your OLED work perfect:
– Go into the libraries folder
– Open U8glib library folder
– Now open Utility folder
– Scroll down till you find the file with the name “u8g_dev_ssd1306_128x64”
– There are actually two of them… One of them is bigger, open the BIGGER one. Right about line 186 you will see this:

 0x000,		/* set lower 4 bit of the col adr to 0  */

Change it to this…

0x002,		/* set lower 4 bit of the col adr to 0  */

4. Open Arduino IDE
5. In examples under U8glib, you will see a “Hello World” example… Open it
6. Now if you look through the code you will see that in the beginning there is a lot of commented out code that allows the user to select what display they want to use. Right under all that add a new line and put this in. This tells the code how you connected your OLED.

U8GLIB_SSD1306_128X64 u8g(5, 4, 10, 2, 3);

7. Click upload and you are all set.

arduino oled hello world

A so-called garbage OLED is not really garbage after all. The HelTec OLED that I got has 128×64 pixels, which is not much, but you can actually play chess on it. Just look through the examples in this library and find the cool things you can do with this small OLED that I got from eBay. It was actually quite hard to get it to work for the first time because information about making it work was found scattered around all over the internet; this small write-up combines it all in one simple to read tutorial.

Related Products: LCD Character Modules


Join the conversation!

Error! Please fill all fields.
  • getter425

    I had tried many ways that I couldn’t make it work until I’ve seen your article, good job. Keep posting…

  • Ehsan

    Hi Guys
    I’ve bought a 4 pin OLED display and it’s working fine.
    it uses pins A4 = SDA and A5 = SCL on Arduino but aa I need these pins for my pressure sensor , I need to change them to other Arduino pins.can anyone know how can I do that in 4 pin OLED display.Many thanks in advanced

    • Paolo

      You have an i2c display, if you have an i2c pressure sensor (I suppose that since you connect it to SDA/SCL) there’s no problem to connect them in parallel.
      i2c bus uses addresses for every “slave” device connected to it, just be sure that display and sensor have different addresses (you should find references on datasheet)

  • BlueChip

    I notice you are using pins 2,3,4,5,(10) which means you must be using Software SPI …*EVERY* demo I can find online does exactly this …But I have found that if you use the hardware SPI (use specified pin numbers & choose the hardware constructor) the screen (and your Arduino) will fun about 4-6 times faster!

  • Tim

    Francisco the display you showed is very cheap however it is a LCD display. OLED displays are still a bit expensive if they are in color but technology is growing rapidly and before we know it the color OLED displays will be cheap too. I am very happy to find out that u8glib works with this display right out of the box. When companies copy the same design over and over it becomes like a broken telephone in the end not everything is the same.

  • u8glib

    Well done, however it is not required to patch the code: You own a SH1106 display which got sold as SSH1306. U8glib supports SH1106 OLEDs with the SH1106 constructor.

  • Francisco

    Hi Tim!

    Great explanation and documentation. I checked for the display in eBay and found it. Even better, I found a colour one:

    Which is compatible with Adafruit library and someone did make it work already with arduino and some help 😉

    Kind regards!

Looking for the latest from TI?