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
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.