Cant display on Wemos OLED display

Hi

I am trying to diaply on WEMOS D1 mini (ESP8266 based) with the OLED on top of it. I can contr5ol the WEMOS (e.g. control servo and UltraSonic sensor).
I can also identify the OLED device on adress 0x3C responding on the I2C bus, and also see some changes on the display, such as the Adafruit logo at first.
But somehow I cant print to diaplay, nor draw on it, although I am following up the examples, such as in Adafruit_SSD1306_Wemos_OLED/ssd1306_64x48_i2c.ino at master · stblassitude/Adafruit_SSD1306_Wemos_OLED · GitHub .

I am using VScode with platformIO, Somehow I guess it is something to do with the libraries, but I have no clue. Any ideas?

here is my platformio.ini:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
upload_protocol = esptool
lib_deps = 
	adafruit/Adafruit BusIO@^1.7.1
	adafruit/Adafruit GFX Library@^1.10.4
	adafruit/Adafruit SSD1306@^2.4.2

Can you show the exact code you’re running and what you’re expecting from the code?

Or does the provided example sketch not work at all?

Can you give an exact link to the module and shield that you’re using here / buy-link?

The code seems to run well, I can control any other aspect of the design, but I don’t get the text/pixels/etc. on the OLED display. I can see the printf’s debug results on my terminal.
I can see the original logo displayed on start, but it doesn’t look good.
After clear display it is gone, leaving a left over.
(is there a way to read back from the device? from the 1306 controller? I didn’t read yet it’s spec).

The WEMOS OLED display:
[0,66 inch OLED LED LCD Dispaly Schild Kompatibel für WEMOS D1 MINI ESP32 64X4 8 0,66 zoll Display 0.66 "oled modul IIC I2C|shield lcd|iic i2c lcdiic lcd - AliExpress]

Here is the code, including trials I have done, such as adding SPI lib (I am not using SPI bus), GFX lib (not needed to compile), same for wire.h (I assume it is included with the 1306 lib):

#include <Servo.h>
//#include <Wire.h>

#include <SPI.h>
#include <Adafruit_SSD1306.h> // for the display
#include <Adafruit_GFX.h>

//#include <Arduino.h>

int servo_pin = 12; // D6

int echoPin = 13; // Echo Pin (D7)
int trigPin = 14; // Trigger Pin (D5) 
int pos = 0;    // variable to store the servo position
 
#define OLED_RESET -1  // GPIO0
//Adafruit_SSD1306 display(OLED_RESET);
#define SCREEN_WIDTH 64 // OLED display width, in pixels
#define SCREEN_HEIGHT 48 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//Adafruit_SSD1306 display( OLED_RESET);

Servo servo_base;  // create servo object to control a servo
int I2C_scanner(byte _dev); // scan I2C and return fist device found

int ultrasinic_measure();
int move_servo_and_read(int _pos);
void radar_search(int min_dist, int _max_dist);

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  servo_base.attach(servo_pin);  // attaches the servo on pin 9 
  Serial.begin(9600);
  Wire.begin(); // for I2C
  Serial.println("");

  delay(2000); // for debug, to allow time to open terminal
    
  byte oled_i2c_addr = 0x3c;

  int i2C_dev = I2C_scanner(oled_i2c_addr); // the 3C Hex is 60 Dec.
  Serial.print("Oled display detected address:");
  Serial.println(i2C_dev, HEX);

  if (i2C_dev==0) {
    Serial.println("no I2C devices ");
  }
  else {
    Serial.print("I2C device found: ");
    Serial.println(i2C_dev, HEX);
  }
  

  // display
    // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 64x48)
  Serial.println("show logo");
  display.display(); // logo of Adaftuit is loaded at start
  delay(1000);
  display.clearDisplay();

Serial.println("show pixel");
  display.drawPixel(10, 10, SSD1306_WHITE);
  display.display(); 
  delay(1000);

   // draw many lines
  //estdrawline();
  //display.display();
  //delay(2000);
  //display.clearDisplay();



  
  // init done
 

  Serial.print("SSD1306_LCDHEIGHT: ");
  Serial.println(SSD1306_LCDHEIGHT);

  Serial.print("display.width() ");
   Serial.println(display.width());
   
   Serial.print("display.height() ");
   Serial.println(display.height());
  delay(4000);
 
  // Clear the buffer.
  display.clearDisplay();
  display.drawPixel(10, 10, SSD1306_WHITE);
  display.drawPixel(20, 20, SSD1306_WHITE);
  display.display();
  
  Serial.println("setting pixles");
  delay(1000);
  display.clearDisplay();
  display.writeFillRect(1,1,20,10,SSD1306_WHITE);
  display.display();
  Serial.println("Show Rect ");
  delay(3000);

} // of setup

void loop() {
    
  for (int i=1;i<=5;i++) {
    digitalWrite(LED_BUILTIN, HIGH); // led OFF
    display.clearDisplay();
    Serial.print("cycle: ");
    Serial.println(i);
    // text display tests
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println("ABC ");
    display.println("... ");
    display.println("123456 ");
    //display.println(i);
    display.display();
    delay(5000);
    
    digitalWrite(LED_BUILTIN, LOW); // led ON
    delay(1000);
  } // of for loop
  return;
  digitalWrite(LED_BUILTIN, HIGH); // led OFF
  radar_search(20, 40); // TBD - use min & max to define a range of detection
  delay(500);
  digitalWrite(LED_BUILTIN, LOW); // led ON
} // of loop

I just read part of the data sheet: it is possible to read back the status register of the ssd1306, but not using serial mode :frowning:

I think I found the solution: from here : It seems the Adafruit in the PlatformIo are not updated. Once I added the files, it seems it is working.

Yep, this is what I was about to say too after looking at the code. In the code below you just initialize the display and then start telling it to display whatever is in it’s framebuffer RAM.

After a power-cycle or overwriting it with something else, the RAM gets corrupted / overwritten with something else. You need to upload the picture you want to display beforehand to the device.