U8G2 1,3" OLED lines missing

Hello, i bought Wemos D1 mini (esp8266 board) and 1,3" I2C OLED screen with SH1106 chip. i am trying to control it through U8G2 library, but everything after line 16 doesnt appear
i have set the correct adress. the screen power is connected to 5V, and the logic is 3.3V

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_SH1106_128X64_NONAME_2_SW_I2C u8g2(U8G2_R0, 2, 0, U8X8_PIN_NONE);
void setup(void) {
  u8g2.begin();
  u8g2.setI2CAddress(0x3C*2);
}
void loop(void) {
  
  u8g2.clearBuffer();					// clear the internal memory
  u8g2.setFont(u8g2_font_ncenB10_tr );	// choose a suitable font
  u8g2.drawStr(0,17,"Hello World!");	// write something to the internal memory
  u8g2.sendBuffer();					// transfer internal memory to the display
  delay(10000);  
}

If you want to use clearBuffer() and sendBuffer() you must use an _F_xxx() constructor. e.g.

U8G2_SH1106_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, 2, 3, U8X8_PIN_NONE);

I ran this on a Uno clone. I chose 2, 3 because the pcb had a matching header socket.
Obviously you want GPIO2, GPIO0 for your Wemos D1 Mini.

You can use the tiny buffer constructors like _2_xxx() if you want. But you need to use the sequence

  u8g2.firstPage();
  do {
    draw();
  } while ( u8g2.nextPage() );

David.

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