Library 61- SSD1306 OLED I2C LCD for STM32F4xx

Yeah, I got it too. These little, small and with nice contrast devices are really great.

I2C communication from my module isn’t really powerful because of slow I2C, even at 400kHz. To update full LCD, there are 1024 bytes of data to be transfered. And this can really take a while. But anyway, for having this LCD just to showing small updates and notifications for users in your project, I2C is still nice. Probably I should make it using I2C DMA transfer.

The heart of this OLED LCD is SSD1306 driver. Driver itself allows also some other communications like 3-wire SPI or 4-wire SPI as well as 6080 parallel interface any maybe more. Parallel interface is really not necessary here because of small amount of data to be transfered since each pixel is a bit in a bytes area.

In my LCD, I don’t like the fact that about 1/3 of LCD is yellow when pixel is ON and the rest is blue. This looks really crazy and not so useful. Anyway, library is here and ready to use.

Since this LCD is very small, LCD rotation is not possible with this library. By having interest in this feature I will add this too.

Library

Features

  • Draw strings to LCD at any position you want
  • Draw graphic things like lines, rectangles and circles
  • Invert pixels in one function call
  • Data for LCD are stored in STM’s ram, after each change, UPDATE command is necessary to get changes on LCD

Dependencies

  • CMSIS
    • STM32F4xx
    • STM32F4xx I2C
  • TM
    • TM GPIO
    • TM I2C
    • TM FONTS
    • defines.h
  • C
    • string.h
    • stdlib.h
SSD1306 STM32F4 Description
VCC 3.3V
GND GND
SCL PA8 Serial clock line
SDA PC9 Serial data line

LCD works on I2C and it has options to select custom I2C address by changing BIT1 in I2C address. Default address (also used in this library) is:

Functions and enumerations

Example

SSD1306 OLED I2C LCD with STM32F4

SSD1306 OLED I2C LCD with STM32F4



Project is available on my Github, download library below.

tilz0R

Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!