Raspberry Pi Pico OLED SSH1106 tutorial using Arduino

In this Raspberry Pi Pico OLED SSH1106 tutorial I am going to show you how to connect this 1.3” OLED display to a Raspberry Pi Pico board. I will also show you how to use it with Arduino and I will share with you 3 useful projects to help you get started and save you a lot of time. Let’s start.

Intro to the Project

I recently discovered this OLED display and I wanted to try it out because it is bigger in size than the OLED display I was using so far which is 1” in diagonal. The new display is 1.3” in diagonal, which makes it a lot bigger.

Similar to other OLED displays, this display has an excellent contrast and low power consumption. 

The display has a resolution of 128×64 pixels, it is monochrome and it uses the I2C interface to communicate with the microcontroller. This makes the connection to the Raspberry Pi Pico extremely easy. All we have to do is to connect power and two more wires. Let’s see how to connect it.

Where to get the parts

Connecting the Parts

The first pin of the display is the GND pin, so we connect it to a GND pin of the Raspberry Pi Pico board. The second pin is VCC so we connect it to the 5V output of the Raspberry Pi Pico board. The next pin is named SCL and we connect it to pin GP5 which is right here, it’s the 7th pin of the board. The last pin is named SDA and we connect it to pin GP4 which is pin number 6. That’s it, our connections are ready. 

Let’s power up the board to see what happens. As you can see I have loaded a demo sketch to it, and it displays a “Hello World” message. Beautiful, our hardware setup is working fine. 

Software

Let’s now see the software we need to drive this display. I am going to use Arduino today, so I open up the latest version of the Arduino IDE at the time of this recording. 

All we have to do is to click here, at the Library Manager button, search for the excellent GyverOLED library and press the install button. Now that the library is installed we can use it at once.

As you can see the code of the first example is very simple. All we do is we create an oled object and we simply call some methods. At first we initialise the display, and then we clear it and we call the update method to reflect the changes to the screen. Next we set the cursor to the desired, X and Y coordinates on the screen, and we print the Hello World message with the print method. Next we draw a frame around the screen with the rect method, and lastly we send all the changes to the display with the update method. Easy, isn’t it?

The second example is a program that displays the temperature using a DHT22 sensor. I have connected the sensor to pin GP15. I have also included the DHT library to make it work. As you can see, the project is working fine and it updates the temperature every two seconds. 

The library only supports English and Russian text printing. But if we want to print the User Interface in another language we can load it as a bitmap and only print the numbers for the temperature with the library. For example, in Photoshop I created a new .bmp file with dimensions 128×64 pixels with the text “temperature” in Greek. I saved it as a .bmp file and loaded it into the LCDAssistant software. I then saved it to a .c file. The software created a byte array that I can use in my sketch. I just have to copy and paste it in my program. Now instead of printing the text and drawing a frame using the library I just call the drawBitmap function. Cool huh! Our project now speaks Greek.

The last project I want to share with you is a Pong game where the cpu controls both paddles. I wanted to see if the display can update fast enough to allow us to develop games with it. As you can, it is pretty fast. When I first ran the program I was disappointed because the frame rate was not as fast, it was barely playable. But after some search, I discovered that if we manually set the I2C bus frequency at 800KHz the display works fast! Very cool! 

Conclusion

So, this display is really fast using Arduino and I am going to use it a lot in the future. I am using Arduino and not CircuitPython or MicroPython because it is way faster in execution time. Please check the video comparison I did to see for yourself. If speed is an issue for your project, Arduino is the way to go. Thanks for watching, I will see you next time.