Neu: Die KI-Firewall überwacht die gesamte Plattform und erklärt jeden Vorfall in einfachen Worten. So funktioniert es

20×4 I2C LCD on the cleanroom pressure display only shows a row of solid blocks

20×4 I2C LCD on the cleanroom pressure display only shows a row of solid blocks

Gelöst 5 4

Small side project. We want a local readout next to a cleanroom door: an ESP32 reads a differential pressure transmitter (4-20 mA through a 165 ohm shunt into the ADC), sends the value to Hermetry, and shows it on a 20×4 LCD with the usual PCF8574 I2C backpack so people can see it without opening a dashboard. The Hermetry side is done.

The LCD shows the first and third rows as solid blocks and nothing else. Backlight is on. Code:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
  Wire.begin(21, 22);
  lcd.init();
  lcd.backlight();
  lcd.print("dP: 12.4 Pa");
}

Backpack VCC is on the 5V pin, SDA/SCL straight to 21/22. I’ve swapped the display for a second one, same result. Wrong pins somewhere?

♥ 0

Have you turned the little blue screw on the back? Mine showed blocks until I did. Not sure it’s the same thing.

♥ 1

Yes, turned it end to end. Blocks get lighter and darker, no text.

♥ 0

Blocks on rows 1 and 3 with contrast fine means the display powered up but never got initialised, so it’s sitting in its one-line power-on mode. Almost always the I2C address. Backpacks with a PCF8574A chip are at 0x3F, not 0x27, and from the outside they look identical. Run a scanner:

#include <Wire.h>
void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);
  for (uint8_t a = 1; a < 127; a++) {
    Wire.beginTransmission(a);
    if (Wire.endTransmission() == 0) Serial.printf("found 0x%02Xn", a);
  }
}
void loop() {}

Second thing for an ESP32: the backpack on 5V has its pull-ups to 5V, so SDA/SCL idle at 5V into a 3.3V chip. It usually works and it’s not great. Either power the backpack from 3.3V (some LCDs go faint at 3.3V) or remove the backpack’s pull-up resistors and add 4.7k to 3.3V, or put a small level shifter in between. For something on a cleanroom wall for years I’d do the level shifter.

Akzeptierte Lösung♥ 4

Same experience, two of my backpacks from the same seller were 0x3F.

QoS 1 and a lot of patience.
♥ 2

0x3F. Changed the constructor and it reads „dP: 12.4 Pa“ on the first line. Going with a BSS138 level shifter board for the final build as you suggest. Bit embarrassed I didn’t scan first.

♥ 1
Ansicht von 6 Beiträgen – 1 bis 6 (von insgesamt 6)
  • Du musst angemeldet sein, um auf dieses Thema antworten zu können.

Mitdiskutieren

Melde dich an, um Fragen zu stellen und zu beantworten, hilfreiche Beiträge mit „Gefällt mir“ zu markieren und die Antwort zu kennzeichnen, die dein Problem gelöst hat. Jeder Beitrag bringt Punkte und Stufen.

Teilen