LCD 16x2 via I2C PCF8574 - white boxes only

Hi everyone,

i have one of those 16x2 LCD Screens connected to a nodemcu-32s via I2C nand pcf8574.
Unfortunately the LCD only shows white boxes in the first line and nothing in the second line.
(looks similar like on the photo of this reddit user: https://www.reddit.com/r/esp8266/comments/l9afzl/need_help_with_1602_screen/)
I have already tried to turn the contrast on the pcf8574 up & down, but this only makes the boxes in the first line appear / disappear. - No text :frowning:

Never the less in the ESP log I can see the screen is correctly detected (and if I change sda / scl I can clearly see corresponding errors in the log)

INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.XX.XX using esphome API
WARNING Can't connect to ESPHome API for 192.168.XX.XX: Error connecting to ('192.168.XX.XX', 6053): [Errno 111] Connect call failed ('192.168.XX.XX', 6053)
INFO Trying to reconnect to 192.168.XX.XX in the background
INFO Successfully connected to 192.168.XX.XX
[12:22:58][I][app:102]: ESPHome version 2022.3.2 compiled on Apr  3 2022, 12:21:34
[12:22:58][C][wifi:491]: WiFi:
[12:22:58][C][wifi:353]:   Local MAC: AA:BB:CC:11:22:33
[12:22:58][C][wifi:354]:   SSID: [redacted]
[12:22:58][C][wifi:355]:   IP Address: 192.168.XX.XX
[12:22:58][C][wifi:357]:   BSSID: [redacted]
[12:22:58][C][wifi:358]:   Hostname: 'esp32-test'
[12:22:58][C][wifi:360]:   Signal strength: -67 dB ▂▄▆█
[12:22:58][C][wifi:364]:   Channel: 1
[12:22:58][C][wifi:365]:   Subnet: 255.255.255.0
[12:22:58][C][wifi:366]:   Gateway: 192.168.XX.1
[12:22:58][C][wifi:367]:   DNS1: 192.168.XX.1
[12:22:58][C][wifi:368]:   DNS2: 0.0.0.0
[12:22:58][C][logger:233]: Logger:
[12:22:58][C][logger:234]:   Level: DEBUG
[12:22:58][C][logger:235]:   Log Baud Rate: 115200
[12:22:58][C][logger:236]:   Hardware UART: UART0
[12:22:59][C][i2c.arduino:038]: I2C Bus:
[12:22:59][C][i2c.arduino:039]:   SDA Pin: GPIO18
[12:22:59][C][i2c.arduino:040]:   SCL Pin: GPIO19
[12:22:59][C][i2c.arduino:041]:   Frequency: 50000 Hz
[12:22:59][C][i2c.arduino:044]:   Recovery: bus successfully recovered
[12:22:59][I][i2c.arduino:054]: Results from i2c bus scan:
[12:22:59][I][i2c.arduino:060]: Found i2c device at address 0x27
[12:22:59][C][lcd_pcf8574:024]: PCF8574 LCD Display:
[12:22:59][C][lcd_pcf8574:025]:   Columns: 16, Rows: 2
[12:22:59][C][lcd_pcf8574:026]:   Address: 0x27
[12:22:59][C][lcd_pcf8574:027]:   Update Interval: 3.0s
[12:22:59][C][captive_portal:088]: Captive Portal:
[12:22:59][C][mdns:084]: mDNS:
[12:22:59][C][mdns:085]:   Hostname: esp32-test
[12:22:59][C][ota:085]: Over-The-Air Updates:
[12:22:59][C][ota:086]:   Address: 192.168.XX.XX:3232
[12:22:59][C][ota:089]:   Using Password.
[12:22:59][C][api:138]: API Server:
[12:22:59][C][api:139]:   Address: 192.168.XX.XX:6053
[12:22:59][C][api:143]:   Using noise encryption: NO
[12:22:59][D][api:102]: Accepted ::FFFF:C0A8:200E
[12:22:59][D][api.connection:827]: Home Assistant 2022.3.8 (::FFFF:C0A8:200E): Connected successfully

Any idea what could be wrong here?

This is my simple configuration for test:

#WIRING
# ESP32 G19 -> LCD/pcf8574 SCL
# ESP32 G18 -> LCD/pcf8574 SDA
# ESP32  5V -> LCD/pcf8574 VCC
# ESP32 GND -> LCD/pcf8574 GND

esphome:
  name: esp32-test

esp32:
  board: nodemcu-32s
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "XXXXXXXXXXXXXXXXXX"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Manually override what address to use to connect to the ESP. 
  use_address: 192.168.XX.XX
  
  #Set the domain of the node hostname used for uploading. 
  domain: ''

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Test Fallback Hotspot"
    password: "XXXXXXXXXX"

captive_portal:

### INTERNAL COMPONENTS & SETUP ###

i2c:
  sda: GPIO18
  scl: GPIO19

display:
  - platform: lcd_pcf8574
    dimensions: 16x2 
    address: 0x27
    id: lcd_screen
    update_interval: 3s
    lambda: |-
      it.printf(0,0, "Hello World!");
      it.printf(0,1, "Hello Line2!");
  1. With static text, use it.print instead of it.printf, (printf is used for formatted text and needs more parameters).
  2. How is the LCD powered, most of this type of screens need 5V (not 3.3V).

Thanks for your reply.

  1. I tested with print but still same result :frowning:
    Does that mean something is wrong with my Wirsing?
  2. I am already using 5V - If connected via 3.3V the LCD Shows the same but with much less contrast…

Wiring could be a problem, however without any information about your wiring I can only guess :slight_smile:

What is necessary to know about the wiring?
As you might have guessed I am no expert on electrics :stuck_out_tongue:

These are the notes I have / can provide:


#WIRING
# ESP32 G19 -> LCD/pcf8574 SCL
# ESP32 G18 -> LCD/pcf8574 SDA
# ESP32  5V -> LCD/pcf8574 VCC
# ESP32 GND -> LCD/pcf8574 GND

Yes, that’s on paper, however often people connect them irl otherwise :slight_smile: Do you have a picture of your setup? I just tried it with a esp8266 and that’s works fine for me. I will try it also with a esp32 devkit v1. Do you have another esp32/esp8266 lying around to exclude a defect esp32?

I can provide some pictures later, but I assume more and more it is related to the LCD <-> pcf8574 soldering I have done…even if I cannot see an physical „connection issue“.

The ESP should be fine - I can use a OLED screen on the same I2C at the same time without any issues…

Ok, just tried your yaml on an esp32 and it works like charm, so your assumption could be right.

hm… I now had the time to resolder the LCD <-> pcf8574

The white boxes are gone now, but unfortuantely that’s all… still no text - independently of the contrast setting :frowning:

Do you see still see any bad soldering here?


To be honest, my teacher would be very unhappy… Try to cover the whole pinhole with solder tin.

I have exactly the same issue. My guess is that the 1602 character set doesn’t support western ascii characters or smth, do you know how i can tell esphome to use another set and did you got anywhere with it?

esphome:
  name: esphome-64

esp8266:
  board: d1_mini
  restore_from_flash: true

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

wifi:
  networks:
  - ssid: LH
    password: !secret wifi_password
  - ssid: LHK
    password: !secret wifi_password
  - ssid: LHS
    password: !secret wifi_password
  - ssid: LH5
    password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.2.64
    gateway: 192.168.2.1
    subnet: 255.255.255.0
  ap:
    ssid: "Esphome-Web-Da8D14-64"
    password: ""

captive_portal:

i2c:
  scl: D3
  sda: D4
  scan: true
  frequency: 100khz

display:
  - platform: lcd_pcf8574
    dimensions: 16x2
    address: 0x27
    update_interval: 1s
    id: lcd
    lambda: |-
      it.strftime(0, 0, "t %d.%m.%Y \x07", id(my_time).now());
      it.strftime(0, 1, "t %H:%M:%S \x08", id(my_time).now());
    user_characters:
      - position: 0
        data:
          - 0b00000
          - 0b01010
          - 0b00000
          - 0b00100
          - 0b00100
          - 0b10001
          - 0b01110
          - 0b00000
      - position: 7
        data:
          - 0b00000
          - 0b01010
          - 0b00000
          - 0b00100
          - 0b00100
          - 0b00000
          - 0b01110
          - 0b10001

# Example configuration entry
# display:
#   - platform: lcd_gpio
#     dimensions: 16x2
#     data_pins:
#       - D4
#       - D5
#       - D6
#       - D7
#     rs_pin: D1
#     enable_pin: D2
#     lambda: |-
#       it.print("Hello World!");

time:
- platform: homeassistant
  id: my_time

IMG_20230110_211649_123
IMG_20230110_211705_697
IMG_20230110_211728_825

I don’t think your guess is right. I used your yaml and that works fine. Can you post the log file, so we can see if there is something strange in it.

https://hastebin.com/orodiyitoj.md

In your log file I see different results from the i2c scan, indicating that no i2c device was found and another time your lcd-screen was found. Could it be a bad wire problem? Furthermore I normally use D1/D2 for i2c see also ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials Did you tried that already?