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...