SSD1306 Oled Display with raspberry Pi Pico
Table of Contents
SSD1306 Oled Display with Raspberry Pi Pico:
SSD1306 Oled display with Raspberry pi pico- In majority of the projects, we need display units for printing text and sensor values. Nowadays one of the most commonly used displays is the Oled display. The one you can see on the screen is the SSD1306 I2C supported Oled display Module which I am going to use with Raspberry Pi Pico. I have also used this Oled display module with the Arduino boards, ESP32 WiFi + Bluetooth Module, NodeMCU ESP8266 WiFi module, and so on.
Most of the Raspberry Pi Pico Oled display module libraries display text which is too small. I have seen a lot of guys searching about how to increase the text size, so in this example, I will show you how to increase the text size. But first, let’s go ahead and take a look at the circuit diagram.
Previous Articles:
Raspberry Pi Pico Pinout & Specs
Raspberry Pi Pico MicroPython and Thonny IDE Installation.
Raspberry Pi Pico Led examples.
Raspberry Pi Pico Digital Input.
Raspberry Pi Pico ADC Analog Sensor
Raspberry Pi Pico Temperature Sensor.
Raspberry Pi Pico Ultrasonic Sensor.
Raspberry Pi Pico PIR Motion Sensor.
Raspberry Pi Pico LDR Sensor, Day & Night Detection.
Amazon Links:
Other Tools and Components:
Super Starter kit for Beginners
PCB small portable drill machines
*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
SSD1306 Oled display Interfacing with Raspberry Pi Pico:
The SSD1306 Oled display module VCC and GND pins are connected with the Raspberry Pi Pico board 3.3V and GND pins. The SCL and SDA pins of the SSD1306 Oled Display module are connected with GP17 and GP16 pins of the Pico Board. These are the Minimal connections which you need to get started with the SSD1306 Oled display module.
I connected the Oled display module with the Raspberry Pi Pico board as per the connection diagram. In order to display text or values on the Oled display module first we will need to install the SSD1306 library. So let’s go ahead and install the library.
Raspberry Pi Pico SSD1306 Library Installation:
Open Thonny IDE and make sure that your Thonny IDE is in Raspberry Pi Pico mode.
If the Thonny IDE is not in the Raspberry Pi Pico mode for that simply click on the tools, in the tools menu click on the options.
On the options windows, click on interpreter tab, in interpreter list, select the MicroPython (Raspberry Pi Pico) and click on the ok button.
After clicking the ok button your Thonny ide will be shifted to Raspberry Pi Pico mode, as you can see in the image given below.
Once your Thonny IDE is shifted to Raspberry Pi Pico mode, again click on tools Menu and this time click on manage packages.
In the manage packages window, write SSD1306 in the text box and click on the search button.
Wait for the search results, it depends on the internet speed, once the searching is completed then click on the first micropython-ssd1306.
Then click on the install button, and wait for the installation process to complete.
As you can see our ssd1306 library is installed successfully.
Now we have to install another library which is the micropython-oled, you might be thinking why am I installing another library? Well if you are not interested in the text size then you don’t have to install this library, you can use the SSD1306 library for printing the text and for displaying the values; but if you want to increase the fonts size then you will need this second library which I am about to install.
This time type oled_text in the text box and press the search button, and wait for the search results, it depends on the network speed.
Click on first link micropython-oled
Click on the install button and wait for installation process to complete.
As you can see our both the libraries ssd1306 and oled are installed successfully in the Raspberry Pi Pico board.
Raspberry Pi Pico SSD1306 Oled Programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
from machine import Pin, I2C from ssd1306 import SSD1306_I2C from oled import Write, GFX, SSD1306_I2C from oled.fonts import ubuntu_mono_15, ubuntu_mono_20 import utime WIDTH =128 HEIGHT= 64 i2c=I2C(0,scl=Pin(17),sda=Pin(16),freq=200000) oled = SSD1306_I2C(WIDTH,HEIGHT,i2c) write15 = Write(oled, ubuntu_mono_15) write20 = Write(oled, ubuntu_mono_20) write20.text("OLED", 0, 0) write15.text("Display", 0, 20) oled.text("ElectroniClinic", 0, 40) oled.show() The purpose of this code is to print Oled, Display, and ElectroniClinic. The fonts size will be different. write20.text("OLED", 0, 0) write15.text("Display", 0, 20) These two lines of codes uses the Oled library and oled.text("ElectroniClinic", 0, 40) |
This line of code uses the SSD1306 library. I am going to run this code and you will get the idea.
This is how easily you can print text on the SSD1306 Oled display module; it depends on your requirement whether you want to use the Oled library or the SSD1306 library.
Next article, Raspberry Pi Pico ADC Analog Sensor
these was a really helpfull tutorial, I was searching for it for a few weeks and now my ssd1306 is working!
Nope. Doesn’t work.
Traceback (most recent call last):
File “”, line 8, in
File “oled.py”, line 8, in
ImportError: can’t import name Write
search for ‘oled_text’, Install the ‘Micropython-oled’ (Micropython scripts for use OLED displays).
Hi,
Thank you for this tutorial.
I need a bigger size of font for my project, How can i do to have a font with 40 pixels high ?
Is there a font converter to do this job (.ttf ->.py) ?
Ty