Nodemcu oled SD1306 4 pin problem

Hi,
I just tried to connect SD1306 (128x64) oled to nodemcu 4 pin version and nothing displays on screen.
I connected as follows:
screen <-> nodemcu
GND - GND
VCC - 3.3V
SCL - D2
SDA - D1
my code is as follows:

font:
  - file: 'tiny.ttf'
    id: font1
    size: 8

i2c:
  sda: D2
  scl: D1
  scan: True
  frequency: 800kHz

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    lambda: |-
      it.print(0, 0, id(font1), "Hello World!");

any help will be appropriated
regards,
Maciek

Sometimes there is oled displays which can make use of SPI or I2C and they expose all the headers while being set to use SPI for default. To make use of I2C instead it’s often necessary to switch or bridge a resistor to have the “mode” changed. Could you provide a photo of your display (both sides)?

Here you are:


What are the logs saying?

INFO Reading configuration /config/esphome/test-8266-01.yaml...
INFO Starting log output from test-8266-01.local using esphome API
INFO Successfully connected to test-8266-01.local
[19:00:16][I][app:102]: ESPHome version 2022.12.8 compiled on Feb  8 2023, 18:55:05
[19:00:16][C][wifi:504]: WiFi:
[19:00:16][C][wifi:362]:   Local MAC: 5C:CF:7F:23:FC:81
[19:00:16][C][wifi:363]:   SSID: [redacted]
[19:00:16][C][wifi:364]:   IP Address: 192.168.1.221
[19:00:16][C][wifi:365]:   BSSID: [redacted]
[19:00:16][C][wifi:367]:   Hostname: 'test-8266-01'
[19:00:16][C][wifi:369]:   Signal strength: -52 dB ▂▄▆█
[19:00:16][C][wifi:373]:   Channel: 4
[19:00:16][C][wifi:374]:   Subnet: 255.255.255.0
[19:00:16][C][wifi:375]:   Gateway: 192.168.1.1
[19:00:16][C][wifi:376]:   DNS1: 192.168.1.1
[19:00:16][C][wifi:377]:   DNS2: 0.0.0.0
[19:00:16][C][logger:293]: Logger:
[19:00:16][C][logger:294]:   Level: DEBUG
[19:00:16][C][logger:295]:   Log Baud Rate: 115200
[19:00:16][C][logger:296]:   Hardware UART: UART0
[19:00:16][C][i2c.arduino:052]: I2C Bus:
[19:00:16][C][i2c.arduino:053]:   SDA Pin: GPIO4
[19:00:16][C][i2c.arduino:054]:   SCL Pin: GPIO5
[19:00:16][C][i2c.arduino:055]:   Frequency: 800000 Hz
[19:00:16][C][i2c.arduino:058]:   Recovery: bus successfully recovered
[19:00:16][I][i2c.arduino:068]: Results from i2c bus scan:
[19:00:16][I][i2c.arduino:070]: Found no i2c devices!
[19:00:16][C][switch.gpio:076]: GPIO Switch 'IN1'
[19:00:16][C][switch.gpio:098]:   Restore Mode: restore defaults to OFF
[19:00:16][C][switch.gpio:031]:   Pin: GPIO14
[19:00:16][C][switch.gpio:076]: GPIO Switch 'IN2'
[19:00:16][C][switch.gpio:098]:   Restore Mode: restore defaults to OFF
[19:00:16][C][switch.gpio:031]:   Pin: GPIO12
[19:00:16][C][switch.gpio:076]: GPIO Switch 'IN3'
[19:00:16][C][switch.gpio:098]:   Restore Mode: restore defaults to OFF
[19:00:16][C][switch.gpio:031]:   Pin: GPIO0
[19:00:16][C][switch.gpio:076]: GPIO Switch 'IN4'
[19:00:16][C][switch.gpio:098]:   Restore Mode: restore defaults to OFF
[19:00:16][C][switch.gpio:031]:   Pin: GPIO2
[19:00:16][C][esp8266_pwm:022]: ESP8266 PWM:
[19:00:16][C][esp8266_pwm:023]:   Pin: GPIO13
[19:00:16][C][esp8266_pwm:024]:   Frequency: 1000.0 Hz
[19:00:16][C][switch.gpio:076]: GPIO Switch 'Buzzer'
[19:00:16][C][switch.gpio:098]:   Restore Mode: restore defaults to OFF
[19:00:16][C][switch.gpio:031]:   Pin: GPIO16
[19:00:16][C][rtttl:018]: Rtttl
[19:00:16][C][ssd1306_i2c:023]: I2C SSD1306
[19:00:16][C][ssd1306_i2c:023]:   Rotations: 0 °
[19:00:16][C][ssd1306_i2c:023]:   Dimensions: 128px x 64px
[19:00:16][C][ssd1306_i2c:024]:   Address: 0x3C
[19:00:16][C][ssd1306_i2c:025]:   Model: SSD1306 128x64
[19:00:16][C][ssd1306_i2c:027]:   External VCC: NO
[19:00:16][C][ssd1306_i2c:028]:   Flip X: YES
[19:00:16][C][ssd1306_i2c:029]:   Flip Y: YES
[19:00:16][C][ssd1306_i2c:030]:   Offset X: 0
[19:00:16][C][ssd1306_i2c:031]:   Offset Y: 0
[19:00:16][C][ssd1306_i2c:032]:   Inverted Color: NO
[19:00:16][C][ssd1306_i2c:033]:   Update Interval: 1.0s
[19:00:16][E][ssd1306_i2c:036]: Communication with SSD1306 failed!
[19:00:16][C][captive_portal:088]: Captive Portal:
[19:00:16][C][web_server:125]: Web Server:
[19:00:16][C][web_server:126]:   Address: test-8266-01.local:80
[19:00:16][C][mdns:103]: mDNS:
[19:00:16][C][mdns:104]:   Hostname: test-8266-01
[19:00:16][C][ota:093]: Over-The-Air Updates:
[19:00:16][C][ota:094]:   Address: test-8266-01.local:8266
[19:00:16][C][ota:097]:   Using Password.
[19:00:16][C][api:138]: API Server:
[19:00:16][C][api:139]:   Address: test-8266-01.local:6053
[19:00:16][C][api:141]:   Using noise encryption: YES

The i2c scan did not found any device, so I think you have to check your wiring.

Looks like a legit i2c only display. As @jsuanet suggest check the wiring as no i2c is found on the bus and the display can’t work.

try to change the display type and set the frequency, I use the same type and it works like this

i2c:
  sda: D1
  scl: D2
  frequency: 800kHz

display:
  - platform: ssd1306_i2c
    model: "SH1106 128x64"
    address: 0x3C
    update_interval: 5s
    contrast: 60%
    auto_clear_enabled: true
    lambda: |-
      it.print(0, 0, id(font1), "Hello World!");

Thank you. When I get home I will try that.

sorry - no change
still in log i have:

[09:51:20][C][ssd1306_i2c:023]: I2C SSD1306
[09:51:20][C][ssd1306_i2c:023]:   Rotations: 0 °
[09:51:20][C][ssd1306_i2c:023]:   Dimensions: 128px x 64px
[09:51:20][C][ssd1306_i2c:024]:   Address: 0x3C
[09:51:20][C][ssd1306_i2c:025]:   Model: SH1106 128x64
[09:51:20][C][ssd1306_i2c:027]:   External VCC: NO
[09:51:20][C][ssd1306_i2c:028]:   Flip X: YES
[09:51:20][C][ssd1306_i2c:029]:   Flip Y: YES
[09:51:20][C][ssd1306_i2c:030]:   Offset X: 0
[09:51:20][C][ssd1306_i2c:031]:   Offset Y: 0
[09:51:20][C][ssd1306_i2c:032]:   Inverted Color: NO
[09:51:20][C][ssd1306_i2c:033]:   Update Interval: 5.0s
[09:51:20][E][ssd1306_i2c:036]: Communication with SSD1306 failed!

maybe my display is broken?

check your pins, it looks like you have in your yaml set

i2c:
  sda: D2
  scl: D1
  scan: True
  frequency: 800kHz

But your screen <-> nodemcu is
GND - GND
VCC - 3.3V
SCL - D2
SDA - D1

change yaml to and see if that works

i2c:
  sda: D1
  scl: D2

checked - still

[10:39:12][E][ssd1306_i2c:036]: Communication with SSD1306 failed!

I will try to replace nodemcu8266 with nodemcu32

And you changed your yaml file too?

i2c:
  sda: D1
  scl: D2

yes I changed
and maybe I order one more display - maybe that I have is failed

maybe bad oled… you can try to check if there is any solder bridges on the oled ribbon cable.
I have had displays where the cable had bridges, some flux and slide the iron on the ribbon fixed any bridges.

Upload a picture of your setup, where we clearly can see how you have it connected up.


red is D1
green is D2

red is SDA
green is SCL
so code:

i2c:
  sda: D1
  scl: D2

is OK

Do you power the oled with 3.3v or 5.0v ? never mind you stated 3.3v to oled,
Also the GND is it connected to the GND of the nodemcu?

I just realized the 3.3V and GND were exchanged.
Should screen died?
I change them as they should be … and nothing on display.

well thats, not so good.
That might have killed it, but not sure.
Make sure you have 3.3 volt on display, and ground for oled and nodemcu is the same.
Do you smell any magic smoke or does the oled heatup, the oled IC is just below the display area?

Also for future handling. always use black for ground and red for vcc. That way it is easier not to connect wrong.

oled IC is cold;
anyway I will try to replace it
I will use black and red for GND and power for sure.
thanks for all your help