Use OLED Display of ESP8266 NodeMCU with U8g2 library

The ESP8266 board with an attached 0.96 inch OLED display is a great deal. I bought is for about 6 Euros. The full title of my offering was “NodeMCU ESP8266 Development Board w/0.96” OLED Display CH340 Driver Module USB-C".

Unfortunately. the description in the offering is incorrect and the OLED display does not work as expected when using the code/values given in the description.

In the description, the SCA and SCL port numbers are interchanged. Here is a short working example with the correct values:

 1#include <Arduino.h>
 2#include <SPI.h>
 3#include <Wire.h>
 4#include <U8g2lib.h>
 5
 6U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock= */ 12, /* data= */ 14, /* reset= */ U8X8_PIN_NONE);
 7
 8void setup(void)
 9{
10    u8g2.begin();
11}
12
13void loop(void)
14{
15    u8g2.clearBuffer();
16    u8g2.setFont(u8g2_font_7x14B_tr);
17    u8g2.drawStr(0, 15, "Hello World!");
18    u8g2.sendBuffer();
19}

The relevant part is in the constructor of the u8g2 instance. Make sure to use the correct values for SCA and SCL.