Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP8266 NodeMCU OLED Display: Wi-Fi Enabled Hello World Project

View and Edit Project In Cirkit DesignerImage of ESP8266 NodeMCU OLED Display: Wi-Fi Enabled Hello World Project

Circuit Documentation

Summary

This circuit involves an ESP8266 NodeMCU microcontroller connected to a 1.3" OLED display. The microcontroller communicates with the OLED display using the I2C protocol. The circuit is designed to initialize the OLED display and display a simple "Hello, World!" message.

Component List

ESP8266 NodeMCU

OLED 1.3"

Wiring Details

ESP8266 NodeMCU to OLED 1.3"

Code Documentation

Code for ESP8266 NodeMCU

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

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  Serial.begin(9600);  // Ensure the correct baud rate

  // Initialize I2C with specific pins for NodeMCU 12E
  Wire.begin(4, 5);  // SDA to GPIO4, SCL to GPIO5

  Serial.println("Initializing OLED...");
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 initialization failed!"));
    while (1);  // Stay here if initialization fails
  }
  Serial.println(F("OLED initialized successfully"));

  display.clearDisplay();
  
  // Draw a line as a basic test
  display.drawLine(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
  display.display();
  delay(2000);  // Pause for 2 seconds to see the line

  // Now print text again
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.println(F("Hello, World!"));
  display.display();
}

void loop() {
  // Nothing to do in loop
}

This code initializes the OLED display and prints "Hello, World!" on it. The I2C communication is set up with the SDA pin connected to GPIO4 and the SCL pin connected to GPIO5 on the ESP8266 NodeMCU. The display is cleared, a line is drawn for testing, and then the text is displayed.