Adafruit Oled library causing my esp8266 to crash!

Hello,

today I wanted to try to use a oled display with esp8266 using arduino language. Before I always used micropython to use an oled display. I had written a long code but it kept showing error. Then I decided to comment out the code that I used for the oled display. Then the error disappeared. Can someone please help me solve that problem?
My Code:

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

//netwok
const char* ssid = "Iffaiman";
const char* password = "iffaiman313";
//oled var
#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);

void setup() {
  Serial.begin(115200);
  delay(1000);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }

  Serial.println("Connected to WiFi");
  display.println("Hello, world!");
  display.display();
}

void loop() {
}```
The error message:
```--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (28):
epc1=0x40201e0a epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

Kind Regards

1 Like

Does the error occur when you compile the sketch or when you run it ?

Is the sketch that you posted the one that errors or not ? Please post the full error message, using code tags when you do

The error comes when I run it. That is the code which causes error.



--------------- CUT HERE FOR EXCEPTION DECODER ---------------

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v00049960
~ld

The code that you posted does not even compile as the WiFi library is not #included, so it could not have produced that error message.

Are you sure that you posted the correct sketch ?

Oh my mistake. but i figured out the solution now

For the benefit of others please shar details of the problem and solution

The problem was that I forget to initialize the display(if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); for (;;); }). that caused some error that always crashed my program. I found my mistake with the help of an tutorial, that showed how to use an oled display.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.