NodeMCU / 0.96 OLED Not Working
Posted: Mon Sep 16, 2019 9:53 am
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.
https://randomnerdtutorials.com/esp8266-0-96-inch-oled-display-with-arduino-ide/
I additionally ran a an i2c scanner provided by Rui Santos to troubleshoot.
https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/master/Projects/LCD_I2C/I2C_Scanner.ino
The Output is
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 my 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.
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. 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?
My setup is derived from Rui Santos and Random Nerd Tutorials.
https://randomnerdtutorials.com/esp8266-0-96-inch-oled-display-with-arduino-ide/
I additionally ran a an i2c scanner provided by Rui Santos to troubleshoot.
https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/master/Projects/LCD_I2C/I2C_Scanner.ino
The Output is
Code: Select all
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 my 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.
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. 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?
Code: Select all
/**********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();
}