SSD1306 is a popular OLED display driver. Portable and wearable devices are the new trends. Small OLED displays are just perfect for such compact and portable devices. SSD1306 is a single-chip CMOS OLED/PLED driver. It can manage a 128×64 dot-matrix graphic display. It is designed to control common-cathode OLED panels. The chip has several built-in features like 256-step brightness control, display RAM, oscillator, and contrast control. These built-in features reduce the required external components and make the chip ready to use with any OLED screen of compatible resolution.
SSD1306 is commonly used in monochromatic OLED displays up to 128×64 screen resolution. These displays are now the best alternative to conventional character LCDs. Compared to character LCDs, SSD1306 OLED displays are easy to interface via I2C or SPI and can display many complex graphics, including text, bitmap images, and animations. Comparing prices, small OLED displays are not much costlier than character LCDs. Instead, OLED displays are much aesthetic and compact to use in wearable and portable consumer devices. For example, for a smartwatch, character LCDs are not suitable, and graphic LCDs are quite costlier, but a small OLED display is just perfect for it.
In this tutorial, we will interface an SSD1306 OLED display with Arduino using the SPI interface. SSD1306 chip-based OLED displays can be interfaced to a microcontroller or single-board computer using an I2C, SPI, or parallel interface. Though, I2C and SPI interfaces are most commonly exposed interfacing in OLED display modules.
Components required
- Arduino UNO x1
- 7-pin SSD1306 OLED Module x1
- Connecting wires or jumper wires
About SSD1306 OLED display
OLED stands for Organic Light Emitting Diode. OLED displays are similar to LED displays used in televisions and monitors. However, these displays are compact and suitable for use in wearable and portable devices. There are many types of OLED displays. These displays can be classified according to the size, color, number of pins, and controller IC. OLED displays come in two common sizes – 0.91″ with 128×32 screen resolution and 0.96″ with 128×64 resolution. The display may be monochrome blue, monochrome white, or Yellow-Blue color. The OLED display module may have a 3-pin/4-pin port for only the I2C interface or a 7-pin interface for 3-wire SPI, 4-wire SPI, and I2C interface. SSD1306 and SSD1331 are the most popular OLED display driver chips. Any OLED display module has the controller chip integrated within the module.
In this project, we are using a 0.96″ OLED display having SSD1306 controller IC. The module has a Yellow-Blue screen with 128×64 screen resolution. The module used here has a 7-pin interface, allowing interfacing the module with any microcontroller or SBC via 3-wire SPI, 4-wire SPI, and I2C interface. The 4-wire SPI interface is the default interfacing option in the 7-pin module.
How to interface SSD1306 OLED with Arduino
A 7-pin OLED module offers all interfacing options like 3-wire SPI, 4-wire SPI, and I2C. The 4-wire SPI is the fastest communication mode with the OLED and is also the default one. The 7-pin OLED display has the following pin configuration.
For interfacing the module with Arduino (or any microcontroller or SBC), connect the GND and VCC/VDD pins to ground and 5V out of the Arduino, respectively. OLED runs on minimal power, so it does not require any external power supply. It is important to note that OLED does not light up its backlight just by supplying power. No changes in the OLED display are noticeable until it is properly programmed. The D0, D1, RST, DC, and CS pins can be connected to any GPIO. A 6-pin module does not have Chip Select.
The 4-pin OLED modules offer only an I2C interface to communicate with it. It has the following pin configuration.
To interface the 4-pin module, connect the GND and VCC pins to ground and 5V out of the Arduino. Connect the D0 and D1 pins to any GPIO.
Circuit connections
In this project, a 7-pin SSD1306 OLED module is interfaced to Arduino UNO. The module is connected to the Arduino as the following.
Programming SSD1306 OLED display with Arduino
The library for interfacing SSD1306 with Arduino is available from Adafruit. To find it navigate to library manager of Arduino IDE, Sketch -> Include Library -> Manage Libraries. Search for SSD1306 and select the latest version of the Adafruit SSD1306 library. It will also download the GFX library as one dependency.
Once included, the library can be imported in the code using following lines:
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
The working examples of the library can now be found in File -> Examples -> Adafruit SSD1306.
The library provides several useful functions. Some of these frequently used functions are listed below.
To convert any image to bitmap for display on SSD1306 OLED, you can use the following link.
Arduino sketch
Result
[Link to demonstration video P15-DV]
You may also like:
Filed Under: Arduino, Electronic Projects, Tech Articles, Tutorials
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.