So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By JohnAPA
#83810 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
Code: Select allScanning... 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();
}
User avatar
By rudy
#83814
So at this point the issue must be the board (Esp8266) itself.


That is a poor assumption to make. While that is a possibility, you might have done something electrically marginal the may have worked before. And may have damaged the first oled. It is possible that the second oled could fail given some time.

There are a number of possibilities and you will only know what was the cause once you have resolved the problem.
User avatar
By amar1
#83842 Are you using 4 pin OLED or 7 Pin? If you are using 7 pin OLED and using SPI communication, then why are you running I2C scanner?
In NodeMCU, firmware should not be a issue, it can be easily programmed with Arduino IDE, there are lot of tutorials on it like this one:
https://www.instructables.com/id/Quick-Start-to-Nodemcu-ESP8266-on-Arduino-IDE/
If it were ESP8266-01 then there may be struggle with firmware.
Coming to the connections, connecting OLED with NodeMCU is also easy and the coding should also not a problem as you are already using Adafruit Libraries. Commonly the connection should be like this:
Image
Cross check the connections and test check by dumping the code from the same circuit diagram link page here:
https://circuitdigest.com/microcontroller-projects/interfacing-ssd1306-oled-display-with-esp8266-nodemcu
THen update here if it works.
User avatar
By JohnAPA
#83961 Hey thank you for your response. I am actually using the 4 pin OLED. I went through all of the tutorials and seem to come up with no solution still. I also have a github account with the OLED coding in it if anyone would like to look it over maybe, to see where I may be going wrong?

Also, one thing I noticed I did.
I connected the VIN and GRD (5V) to the breadboard's power input. I then powered the ESP board using my USB Cable to computer. Could that have caused some sort of hardware damage?

https://github.com/JohnAPA/WiReefPi/issues