ESP8266IOT Projects

Nodemcu ESP8266 Oled Display Module Circuit diagram and programming

Nodemcu ESP8266 Oled Display, Description:

 

Nodemcu ESP8266 Oled Display Module Circuit diagram and programming– This is a very basic getting started tutorial, in which you will learn how to interface the SSD1306 Oled display module with Nodemcu ESP8266 WiFi Module. We will also discuss the issues related to the Oled display Modules and of course, I will explain how to fix them. In the end, I will also share with you an advanced level project in which we will use two I2C supported devices, we will display the values on the Oled display module and will also send the values to the Blynk application.

I have also used the same SSD1306 Oled display module with the ESP32 WiFi + Bluetooth Module.


About the Sponsor, PCBWay:

Nodemcu ESP8266 Oled Display

High quality & Only 24 Hours Build time

The PCB board used in this tutorial is sponsored by the PCBWay Company. Only 5 dollars for 10 PCBs and 30 dollars in total for 20 PCBs Assembly.  Besides this PCBWay also provides a great variety of services including Aluminum PCB, Rigid-Flex, Metal Core, flexible, High Frequency, High-TG, Thick-Copper, HDI, and LED PCBs. The signup process hardly takes 1 minute and you are welcomed with a 5 dollars welcome bonus, what are you waiting for go and get your first prototype order for free.

Download Gerber files:

Download link of the Nodemcu library for Cadsoft eagle:

In this tutorial, we will cover,

  1. Oled display Module Pinout and technical specifications.
  2. Nodemcu ESP8266 Pinout
  3. Oled Display Module Interfacing with Nodemcu ESP8266, Circuit Diagram.
  4. Oled Display Nodemcu ESP8266 Programming.

Without any further delay, let’s get started!!!

Amazon Purchase Links:

Nodemcu ESP8266 WiFi Module:

LM7805 Voltage Regulator:

470uf capacitor:

330-ohm resistor:

DC Female Power Jack:

Female Headers:

Male Headers:

LEDs:

SSD1306 128×64 Oled i2c display Module

Other Tools and Components:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



Oled Display Module:

Nodemcu ESP8266 Oled Display

If you look at both the Oled display modules it’s really hard to tell which one is the SH1106 and which one is the SSD1306 types. Each one uses a different Arduino Library. There are so many other types of Oled displays. The ones you can see in the image above are the 128×64 I2C supported 128×64 Oled Display modules. I have a complete full tutorial on the Oled Display modules, which explains how to fix the common issues including,

How to find the I2C address of the Oled display Module, how to install the correct Oled display Library etc. So, I highly recommend reading my article on Oled Display Module. Previously I used the SH1106 Oled display Module, so this time I will use the SSD1306 Oled display, as this version of the Oled display module is quite popular.

128×64 Oled Pinout and Technical Specs:

The SSD1306 Oled display Module has a total of 4 pins labeled as GND, VCC, SCL, and SDA. This Oled display Module can be easily powered up using 3.3V to 5V. This is a low power display module and can be easily used with the Arduino boards using 5 volts, and can also be used with 3.3V controller boards like ESP8266 and ESP32, etc.

Nodemcu ESP8266 I2C Pins:

Nodemcu ESP8266 Oled Display

Just like the Arduino Uno and Arduino Nano, Nodemcu ESP8266 is also provided with the I2C bus. D1 is the SCL which is the GPIO5 and D2 is the SDA which is the GPIO4. Using D1 and D2 pins of the Nodemcu ESP8266 multiple I2C supported devices can be connected without any problem, as every I2C supported has a unique address, which can be found by using the I2C scanner code given below.


Oled display SSD1306 interfacing with Nodemcu ESP8266:

Nodemcu ESP8266 Oled Display

Oled display SSD1306 interfacing with the Nodemcu ESP8266 Wifi Module is really simple. As you can see in the circuit diagram given above, there are no complicated connections. A potentiometer or variable resistor is connected with the analog pin A0 of the Nodemcu ESP8266. I am using this as the sensor, you can use any other analog sensor. So the middle wire of the Potentiometer should be connected with the A0 while the rightmost and leftmost legs should be connected with the 3.3v and gnd. You can interchange these two wires. Make sure the middle leg of the potentiometer is connected with the A0.

The Oled display Module I am using is an I2C supported, which means we can use the I2C bus. Unlike the Arduino board, Nodemcu also has the I2C bus. D1 is the SCL and D2 is the SDA, while in Arduino the I2C bus is available on A4 and A5 pins. The SCL and SDA pins of the SSD1306 Oled display module are connected with the D1 and D2 pins of the Nodemcu ESP8266. The VCC pin of the Oled display is connected with the 3.3v pin of the Nodemcu ESP8266 while the GND pin is connected with the GND pin of the Nodemcu module.

As a beginner, you can use your laptop to power up the Nodemcu module and check your coding, etc. For a permanent solution, you will need a power supply to power up all the electronics. For this, you can make your own 5V regulated power supply. You can use the LM7805 Voltage regulator. The regulated 5 volts from the power supply are connected with the VIN pin of the Nodemcu ESP8266 WiFi Module. Make sure you connect the GND of the power supply with the GND pin of the Nodemcu Module. You can also see two capacitors each one is 470uF connected at the input and output sides of the voltage regulator. These are the Decoupling Capacitors.

For the easy connections, I designed my own PCB board for the NodeMCU ESP8266 and connected the Oled display module and Potentiometer as per the circuit diagram.

Nodemcu ESP8266 Oled Display

I completed all the connections as per the circuit diagram already explained. Now it was ready for the programming. First of all, I started by finding the I2C Address of the Oled Display Module. For this, I used the I2C Address Scanner code.

Before, you are goind to use the following code, first of all, make sure you have installed the Nodemcu ESP8266 board, as the Arduino IDE does not come with the Nodemcu ESP8266 board pre-installed. You will have to manually install the Nodemcu ESP8266 board. Follow my video tutorial that explains how to install the board and get started with the Nodemcu ESP8266 WiFi module.


I2C address Scanner Code:

#include <Wire.h>

void setup()
{
    Wire.begin();
    Serial.begin(115200);
    Serial.println("\nI2C Scanner");
}

void loop()
{
    byte error, address;
    int nDevices;

    Serial.println("Scanning...");

    nDevices = 0;
    for(address = 0; address <= 127; address++ )
    {
        Wire.beginTransmission(address);
        error = Wire.endTransmission();
        if (error == 0)
        {
            Serial.print("I2C device found at address 0x");
            if (address<16)
                Serial.print("0");
            Serial.print(address, HEX);
            Serial.println(" !");
            nDevices++;
        }
        else if (error==4)
        {
            Serial.print("Unknow error at address 0x");
            if (address<16)
                Serial.print("0");
            Serial.println(address,HEX);
        }
    }
    if (nDevices == 0)
        Serial.println("No I2C devices found\n");
    else
        Serial.println("done\n");
    delay(30000);
 }

After uploading the code, Open your serial monitor to check the I2C address. Mine was 0x3C. You can use the above code for all the I2C supported devices.

Now, I know exactly what is the I2C address, and I also know which type of the Oled display module I am using. So, now I will have no problem in writing the final code.

Nodemcu ESP8266 Oled Display Programming:

Before you start the programming, first of all, make sure you download the Wire.h, Adafruit_GFX.h, Adafruit_SSD1306.h, and SimpleTimer.h libraries. This is the basic programming for reading a Potentiometer connected with the Analog Pin A0 of the Nodemcu ESP8266 and then display the value on the Oled display module.

/*
Download Libraries:
https://www.electroniclinic.com/arduino-libraries-download-and-projects-they-are-used-in-project-codes/
*/

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SimpleTimer.h>


#define REPORTING_PERIOD_MS     2000
SimpleTimer timer;
 
uint32_t tsLastReport = 0;


// for the OLED display

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
 
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

int Potentiometer = A0; 
int PotVal = 0; 

void setup()
{
    Serial.begin(115200);
    pinMode(Potentiometer,INPUT); 
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  
   timer.setInterval(2000L, getSendData);

   display.clearDisplay();
   display.setTextColor(WHITE);
}
 
void loop()
{

  timer.run(); // Initiates SimpleTimer


    if (millis() - tsLastReport > REPORTING_PERIOD_MS) {

PotVal = analogRead(Potentiometer); 

        tsLastReport = millis();
        
    }

}

void getSendData()
{
  
        
// Oled display
  display.clearDisplay();
  // display R G B Values
  display.setTextSize(3);
  display.setCursor(0,0); // column row
  display.print("POT:");


  display.setTextSize(4);
  display.setCursor(0,30);
  display.print(PotVal);

 display.display(); 
}


Nodemcu ESP8266 Oled Code Explanation:

You will need to add the final libraries, otherwise you won’t be able to compile and upload the code. The libraries download link is already given above.

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#include <SimpleTimer.h>

Then I defined period, this defines how often you update the values on the Oled display module. you can increase or decrease the period as per your requirement. Currently, its 2 seconds.

#define REPORTING_PERIOD_MS     2000

SimpleTimer timer;

uint32_t tsLastReport = 0;

// for the OLED display

#define SCREEN_WIDTH 128 // OLED display width, in pixels

#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)

#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

The Potentiometer is connected with the Analog pin A0. As I said earlier, you can use any other type of the analog sensor if you have. For the easy understanding I am using a potentiometer, which you can easily arrange.

int Potentiometer = A0;

A variable PotVal of the type integer. This will be used for storing the Potentiometer value.

int PotVal = 0;

void setup()

{

Serial.begin(115200);

pinMode(Potentiometer,INPUT);

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

timer.setInterval(2000L, getSendData);

display.clearDisplay();

display.setTextColor(WHITE);

}



void loop()

{

timer.run(); // Initiates SimpleTimer

if (millis() – tsLastReport > REPORTING_PERIOD_MS) {

Read the potentiometer and store the value in variable PotVal.

PotVal = analogRead(Potentiometer);

tsLastReport = millis();

}

}

getSendData() is a user defined function, it has no return type and does not take any argument as the input. This function is executed after every 2 seconds. The purpose of this function is to display the values on the Oled Display Module.


void getSendData()

{

// Oled display

display.clearDisplay();

// display R G B Values

display.setTextSize(3);

display.setCursor(0,0); // column row

display.print(“POT:”);

display.setTextSize(4);

display.setCursor(0,30);

display.print(PotVal);

 

display.display();

}

I successfully uploaded the code. Finally, I connected the Power supply and I was able to monitor the Potentiometer value on the Oled display Module.

Nodemcu ESP8266 Oled Display

This was the most basic tutorial to help you get started with the Nodemcu ESP8266 and Oled Display Module. Now, it’s time to build an advanced level project using Max30100 Pulse Oximeter. Read my article “Max30100 ESP8266 Nodemcu based Blood Oxygen & BPM Monitoring on Blynk“. In this tutorial, the Blood Oxygen and Heart Rate “BPM” values are displayed on the Oled display module and the same values are also sent to the Blynk application.

Nodemcu ESP8266 Oled Display

For video tutorials visit my YouTube Channel “Electronic Clinic”.


Video Tutorial:

 

 

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

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

Back to top button