• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

NodeMCU / 0.96 OLED Not Working

Q&A Forum › Category: ESP8266 › NodeMCU / 0.96 OLED Not Working
0 Vote Up Vote Down
John Albanese asked 4 years ago

Hello I am using NodeMCU ESP8266, and trying to connect SD1306 0.96 OLED Display. I’ve been troubleshooting for a week and can’t seem to find an answer. It was previously working, and then somewhere, somehow it just stopped.

My setup is derived from Rui Santos and Random Nerd Tutorials.

I additionally ran a an i2c scanner

The Output is

Scanning... No I2C Devices found

I’ve confirmed that all wires are in place including SCL/SDA.

-D1 -- SCL
-D2-- SDA

I then Tried to connect a second OLED I had to see if it was a hardware issue.

The OLED was found. However, no output!

when running the original code which would display information, the second OLED still didn’t work!

So at this point the issue must be the board (Esp8266) itself…I think

To see if it was a library issue I tried installing the specific libraries for Node MCU ESP8266, that didn’t work.

To see if it was my coding, I tried running the example code for the OLED Demo directly from the library. Didn’t work.

At this point I feel this may be a ESP8266/NodeMCU firmware issue, and unsure where to go from here. I looked into firmware reloading but it seems really complicated on a mac. Unless maybe someone may have an idea of what could be the problem I am running into? If you want to see the code I used to run the program see below (you will see in void loop, that i’ve added the I2C Scanner in there for troubleshooting:

Does anyone else have any suggestions?

/**********Include Libraries**********/
/*************************************/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>

/**********
**********/
//------------------------------------------------------------------
// Definitions
#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)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)

#define DHTPIN 0 // Digital pin connected to the DHT sensor (D3)
#define DHTTYPE DHT11 // DHT 11

//------------------------------------------------------------------
// Create the DHT22 temperature and humidity sensor object
DHT dht(DHTPIN, DHTTYPE);

//-----/**********--VOID SETUP--**********/-----//
//**********************************************//
void setup() {

Serial.begin(115200);
dht.begin();
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}

delay(5000);

display.setTextColor(WHITE);
}
//-----/**********--VOID LOOP--**********/-----//
//**********************************************//
void loop() {
delay(1000);
//-------------------------------------------------------------------
// Read Temperature and Humidity
float t = dht.readTemperature();
float h = dht.readHumidity();
float f = dht.readTemperature(true);
//------------------------------------------------------------------
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
//--------------------------------------------------------------------
// Compute Heat Index
// Must send in temp in Fahrenheit!
float hi = dht.computeHeatIndex(f, h);
//--------------------------------------------------------------------
//print data to serial
Serial.print("Humidity: "); 
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: "); 
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hi);
Serial.println(" *F");
//------------------------------------------------------------------
// Display
display.clearDisplay();

//Temperature------------------------------------
display.setTextSize(1);
display.setCursor(0,0);
display.print("Temperature: ");
display.setTextSize(2);
display.setCursor(0,10);
display.print(f);
display.print(" ");
display.setTextSize(1);
display.cp437(true);
display.write(167);
display.setTextSize(2);
display.print("F");

//Humidity------------------------------------
display.setTextSize(1);
display.setCursor(0, 35);
display.print("Humidity: ");
display.setTextSize(2);
display.setCursor(0, 45);
display.print(h);
display.print(" %");

display.display(); 
}
Question Tags: ESP8266, OLED, SD1306
1 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi John.

Sometimes these issues are very difficult to troubleshoot.

When you run an I2C scanner and nothing is found, it is usually something wrong with the OLED: it is not wired properly (SDA swapped with SCL) or it may be broken.

Also, make sure that you use the right I2C address on your code.

Which OLED display are you using? Some OLED displays seem very similar to the ones we use, but in fact they are “fake”.

Something that may cause issues is unstable power supply. If you’re powering your ESP8266 using a long or not very good quality USB cable, or if you’re using a USB hub, it might not provide enough power to the circuit.

Regards,

Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.