SSD1306 i2c OLED Display with nodemcu

Hello,
I have a SSD1306 i2c display connected with nodemcu using Adafruit_SSD1306 library. its working fine when I connect it with D1, D2 for SCL and SDA.

how could I connect it with D7, D8 or CLK , SDA pin available in nodemcu.

what changes I can do in ssd1306_128x64_i2c example code to work it for D7,D8 pins.

thanks

Adafruit_SSD1306 only has hardware I2C constructor. It is not possible to bit-bang I2C on random pins.

However there is both hardware SPI constructor and software SPI constructor if you had bought the SPI version of SSD1306 display.

U8glib library can control SSD1306 with software I2C.

David.

NodeMCU (esp8266) has no hardware i2c, it is always "bit-banged". It defaults to D1, D2 if you use Wire.begin(). You can use (almost) any 2 pins if you use Wire.begin(D7, D8) for example. With this library, you would change your code like this:

void setup() {
  Serial.begin(9600);

  Wire.begin(D7, D8);

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3D, true, false)) { // Address 0x3D for 128x64

Why do you want to use other pins?