Interfacing PIC12F1822 with SSD1306 OLED

This project is a simple interfacing of SSD1306 OLED display with PIC12F1822 microcontroller which has only 128 bytes of RAM. This project shows how to write texts and print numbers on the screen.
The SSD1306 OLED used in this example is configured to work in I2C (IIC) mode. So, make sure that your SSD1306 OLED display is configured to work in I2C mode, some displays need jumper placing or some soldering.  —  IIC or I2C: Inter-Integrated Circuit  —

Related Projects:
Interfacing PIC16F877A with SSD1306 OLED display
Real time clock with PIC12F1822, SSD1306 OLED and DS3231 RTC

Hardware Required:

  • PIC12F1822 microcontroller
  • SSD1306 OLED display
  • 5V source
  • Breadboard
  • Jumper wires

PIC12F1822 MCU with IIC I2C SSD1306 OLED display

Interfacing PIC12F1822 with SSD1306 OLED circuit:
The following image shows project circuit schematic diagram.

PIC12F1822 SSD1306 OLED dsiplay IIC I2C mode

(All grounded terminal are connected together)

The PIC12F1822 microcontroller has one hardware I2C module with SDA on pin RA2 (#5) and SCL on pin RA1 (#6). The SDA pin of the MCU is connected to the SDA pin of the display and the SCL pin of the MCU is connected to the SCL (SCK) pin of the display.
The reset pin of the display is connected to pin RA0 (#7) of the microcontroller.

The SSD1306 OLED display DC pin is connected to VDD which means the I2C slave address of the display is 0x7A.

In this project the PIC12F1822 microcontroller uses with its internal oscillator @ 32 MHz, MCLR pin is configured as an input pin.

Interfacing PIC12F1822 with SSD1306 OLED C code:
The C code below is for CCS C compiler, it was tested with version 5.051 and version 5.079.

Version 5.051:
Used RAM: 31%
Used ROM: 66%

Version 5.079:
Used RAM: 27%
Used ROM: 66%

To be able to compile the C code below with no error, a driver for the SSD1306 OLED display is required, its name is SSD1306.C, download link is below:
SSD1306 OLED display driver

after the download, add the driver file to project folder or CCS C compiler drivers folder.

For more details about this driver see the following post:
Interfacing PIC16F877A with SSD1306 OLED display

CCS C code:

Interfacing PIC12F1822 with SSD1306 OLED simulation:
The simulation of this project with Proteus should give a result similar to what shown in the following video where PIC16F877A microcontroller is used. Simulation file download link is below, use Proteus version 8.6 or higher to open it!
PIC12F1822 MCU + SSD1306 OLED


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

2 thoughts on “Interfacing PIC12F1822 with SSD1306 OLED”

  1. Thanks for the nice project.
    the oled display module is said to work with 3.3 in many websites.
    are you sure it is ok to sıpply it with 5volts?

    1. Simple Projects

      Yes its controller (SSD1306) works with 3.3V only, but many modules (as the one shown in the circuit diagram) come with voltage regulator that supplies the display controller with 3.3V from 5V supply input. These modules also may contain voltage level converter for the lines between the MCU and the display controller.
      For the I2C mode, the MCU sends a logic high by making its pin floating so a pull up resistor rises the line. The SSD1306 display module shown in the circuit diagram has 2 pull-up resistors for SDA and SCL lines, they’re connected to 3.3V.
      So, before you connect your SSD1306 OLED display to a 5V microcontroller make sure there’s a voltage regulator placed in the board!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top