Friday, January 12, 2018

ESP32 connect OLED display ( SSD1306 )

ESP32 connect OLED Display

We have ESP32 WiFi Module and We'd like to connect to some small display.Easy way to interface with small display is OLED on I2C Bus. because of use 4 wire to connect.
We choose to OLED is  0.96 inch 128x 64 OLED  and SSD1306 Library from Adafruit.
and we test on Nano32 development board from Gravitech and Maker Asia.


Wiring Diagram


OLED SSD1306 Pin SCL  to  ESP32 GPIO 22
OLED SSD1306 Pin SDA  to  ESP32 GPIO 21

IDE and  Library

We use Arduino IDE to develop code in C/C++.
If you are new for this see How to develop ESP32 on Arduino IDE first.
We use Arduino IDE 1.8.5
Add SSD1306 Library
Goto Menu Sketch => Include Library => Manage Libraries


Then search "ssd1306" and Install Adafriut SSD1306 by Adafriut Version 1.x.x


Edit Some Library code for OLED 128x64 only.
When install library done.
In folder Documents / Arduino / libraries /
We will found Adafriut_SSD1308.ccp and Adafriut_SSD1306.h


Edit Adafruit_SSD1306.ccp line 206
Wire.begin();   to  Wire.begin( 21, 22 );


Edit Adafruit_SSD1306.h line 55
0x3D    to   0x3C


and line 73
uncomment this line for use  #define SSD1306_128_64



Example Code

Goto Menu  File => Examples => Adafruit SSD1306 => ssd1306_128x64_i2c
and edit code line 61 in Setup Function.
change address i2c from 0x3D  to  0x3C.


Then upload code to your ESP32 development board.


Test with ESP32 Thing form Sparkfun



Reference

http://esp32.net/




My Website

email : info@softpowergroup.net  ,amphancm@gmail.com  Tel .+6681-6452400

Android and Arduino IoT



LINE : adunfong
FaceBook : https://www.facebook.com/adun.nantakaew
email: amphancm@gmail.com