Home ARDUINO How to Drive OLED with ESP8266 NODE MCU

How to Drive OLED with ESP8266 NODE MCU

0

OLED is a very small display made of 128 by 64 individual OLED pixels and no backlight is required it will run with 3volt so the GPIO pin is the sufficient for this type of LCD. That OLED display is monochrome (white color), but there are other models with several colors. Such as I have yellow and Blue color of OLED

This display uses I2C communication. This means that it communicates with the Arduino using just 2 pins.

Here is the Datasheet of this OLED

Pin wiring

Wiring the OLED display to your Arduino is pretty straightforward:

PIN Wiring to Arduino UNO
Vin 5V
GND GND
SCL A5
SDA A4

 

Need to know about Node MCU Esp8266?

NodeMCU is an open source IoT platform. It includes firmware running on Espressif Systems’ ESP8266 Wi-Fi SOC, as well as hardware based on the ESP-12 module. The term “NodeMCU” by default refers to the firmware rather than the development kit. Firmware uses the Lua scripting language. It builds on the eLua project and builds on ESP8266’s Espressif non-OS SDK. It uses many open source projects, such as lua-cjson and spiffs.

Step 1:-

Collect the hardware

Node MCU ESP8266

 How to Drive OLED with ESP8266 NODE MCU

OLED

 How to Drive OLED with ESP8266 NODE MCU

Step 2

Set software and compile the source code

Download the Arduino compiler from the official website of Arduino from here.
Install the software and execute it,
Go to File -> Preferences

Beginners guide for Arduino UNO

How to Drive OLED with ESP8266 NODE MCU

4.Add http://arduino.esp8266.com/stable/package_esp8266com_index.json to the Additional Boards Manager URLs.

How to Drive OLED with ESP8266 NODE MCU

  1. Click to Tools-> Boards Manager

How to Drive OLED with ESP8266 NODE MCU

  1. Type keyword ‘esp8266’
    7. Select 2.0.0 and click on Install (must be version 2.0.0 never go for latest).

esp8266-OLED is an esp8266-Arduino library for I2C-OLED displays. This article show how to download and install to Arduino IDE, and test with example.

  • It’s assumed you are programming NodeMCU on Arduino Software, with ESP8266 core for Arduino installed.
  • Connect I2C OLED to NodeMCU as the figure draw below.

How to Drive OLED with ESP8266 NODE MCU

OLED VCC –   NodeMCU 3v3
OLED GND – NodeMCU GND
OLED SCL –   NodeMCU D1
OLED SDA –  NodeMCU D2

(Remarks: the Fritzing parts of can OLED_SSD1306_I2C_128x64 can be download HERE)

How to Drive OLED with ESP8266 NODE MCU

Step 3 Add esp8266-OLED library to Arduino Software:
visit https://github.com/klarsys/esp8266-OLED, follow the steps to install the library:

  • Click on the Download ZIP button in the top right corner.
  • Extract it.
  • Rename the uncompressed folder to OLED.
  • Find out the OLED source directory contains OLED.cpp and OLED.h files, and make the upload.
  • Place the OLED folder in your <arduinosketchfolder>/libraries/ folder – you may need to create the libraries subfolder if it is your first library.
  • Restart the IDE.

Step 4 Open the example and Upload Code,
File > Examples > ESP8266-OLED Display Library > example

How to Drive OLED with ESP8266 NODE MCU

In order to match with our connection, we have to modify it to correct SDA and SCL pins:
change the code:
OLED display(2, 14);

to
OLED display(4, 5);

 

// Example sketch for testing OLED display

// We need to include Wire.h for I2C communication

#include <Wire.h>

#include “OLED.h”

// Declare OLED display

// display(SDA, SCL);

// SDA and SCL are the GPIO pins of ESP8266 that are connected to respective pins of display.

OLED display(4, 5);

void setup() {

Serial.begin(9600);

Serial.println(“OLED test!”);

// Initialize display

display.begin();

// Test message

display.print(“Techincal      \n USTAD     HERE   “);

delay(3*1000);

display.clear();

// Test long message

display.print(“www.technicalustaad.com “);

delay(5*1000);

// Test display clear

display.clear();

delay(3*1000);

// Test message postioning

display.print(“TOP-LEFT”);

display.print(“4th row”, 4);

display.print(“RIGHT-BOTTOM”, 7, 4);

delay(3*1000);

// Test display OFF

display.off();

display.print(“3rd row”, 3, 8);

delay(3*1000);

// Test display ON

display.on();

delay(3*1000);

}

int r = 0, c = 0;

void loop() {

r = r % 8;

c = micros() % 6;

if (r == 0)

display.clear();

display.print(“Hello World”, r++, c++);

delay(500);

}

Here is the test Video

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here