Finally a bigger OLED display at a low price!
Let’s see how to use it with an Arduino
All my content is free.
If you feel that my videos are helping and you would like to contribute, you can toss some coins in the Tip Jar via PayPal.
Select amount then click the “Donate” button.
OLED displays have a lot of advantages compared to other displays you might use with an Arduino:
- They require very little power unlike LCD displays, maximum for this one is 0.75mA, compare that to a Nokia 5110 which can go as high as 80mA
- They can display graphics as well as text
- Have high resolutions
- And are relatively easy to connect and use with an Arduino
But they can be more expensive considering their size compared to other displays.
Most of the cheap OLED displays are under one inch in size and their resolution only go up to 128×64.
While browsing around I found this relatively inexpensive (~ $20cnd) OLED display on Amazon, but you can find it elsewhere for less than that.
It’s got the advantage of being 1.5 inch in size and has 128×128 resolution, which makes it very attractive for many projects.
The fact that it has double the vertical resolution of most OLED display out there is a big plus.
In this tutorial we will see how to display text and graphics and how to connect to an Arduino.
This OLED display uses either SPI or I2C communication, both of which are supported on the Arduino.
By default it’s configured to use SPI, which is much faster than I2C.
Since the resolution of this OLED is higher than most, SPI is better suited for this display, but depending on your application I2C might be ok.
In a future tutorial I will test the speed of two of these displays, one using I2C and one using SPI to show the performance difference, and see when to use one or the other.
The OLED display comes by default setup for SPI.
To switch from SPI to I2C all you would have to do is move the resistor on the back to choose which one you would like to use.
In this tutorial we will be using the default setting which is SPI.
With a higher resolution comes the requirement for more memory needed on the Arduino.
In this tutorial I will be using the Arduino MEGA instead of the UNO or Nano, but in a future tutorial I will be showing you how to use this display with them as well by using different ways to write to the display.
*** In my testing I found that the included connection cable wasn’t working… ***
*** So I soldered some headers on the other side and then it worked. ***
If you get one of these and it’s not working when using the included connector cable you might want to try soldering some headers and try it that way.
Not saying they are all like this but it’s something to keep in mind if yours doesn’t work.
I have used the U8G library in the past and it worked well with other OLED displays.
But for this one we will be using the more recent U8G2 library which has support for this SSD1327 128×128 OLED display.
Keep in mind that this OLED supports grayscale, but the U8g2 is a monochrome library, so all the images or text displayed using this library will be black and white (pixel on or off).
There’s many commands available inside this library, but we will be looking at the fast and simple way to get going by displaying some text and graphics.
You can get more information as well as a list of commands on the U8G2 Wiki page.
For more information on the programming don’t forget to watch the tutorial video below.
Like I said at the beginning were are using SPI to communicate with the OLED.
We are using the hardware SPI pins of the Arduino MEGA which are:
- Pin 51 = MOSI
- Pin 52 = SCK
When looking at the back legend of the OLED we see that those pin are:
- CLK pin of the oled is equal to SCK
- and the DIN pin is equal to MOSI.
The rest of the connections are as follow:
- VCC is connected to 5V of the Arduino
- GND is connected GND
- CS is connected to Digital Pin 10
- DC is connected to Digital Pin 9
- and RST is connected to Digital Pin 8
Like I said before, to use the OLED display I will be using the U8g2 library which is an updated version of the original U8g library.
In this tutorial I will be using the Full Screen Buffer mode which is faster but uses a lot of RAM on the Arduino, so this is why we are using the Arduino MEGA since the UNO or Nano would not have enough memory.
Two other modes are available:
- Page Buffer mode which uses less RAM but is much slower
- and U8x8 Character mode which require no RAM, is very fast, but can only display Text not graphics
These other modes might work with the UNO or Nano, so I will be looking at this option in a future tutorial.
To create the graphic array information, I’m using the LCD Image Converter software, link is at the bottom of this page.
Don’t forget to watch the tutorial video for more information.
After some testing, I can say that I really like this OLED display.
The 128×128 resolution is great and means that you can rotate the display in any orientation you want to fit your project since it’s basically a square.
The price is cheap enough to use in many projects, and as you saw it’s pretty easy to use using the U8g2 library.
I will be making more tutorials about this OLED display in the near future, so stay tuned.
In the meantime here is the Amazon.ca (not sponsored) link if you want to grab one: