I2C LCD Display not showting text, backlight works

Hi I'm new to Arduino and got a basic set. I setup the LCD I2C and installed both libraries (hd44780 and LiquidCrystal I2C). After running the I2C scan I got the following:

Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.3.2
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.15
CPU ARCH: AVR - F_CPU: 16000000
--------------------------------------------------------------------
SDA digital pin: 18 A4
SCL digital pin: 19 A5
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
Checking for I2C pins shorted together - Not Shorted
--------------------------------------------------------------------
Scanning i2c bus for devices..
 i2c device found at address 0x27
Total I2C devices found: 1
--------------------------------------------------------------------
Scanning i2c bus for all lcd displays (4 max)
 LCD at address: 0x27 | config: P01245673H | R/W control: Yes
Total LCD devices found: 1
--------------------------------------------------------------------
LCD Display Memory Test
Display: 0
 Walking 1s data test:	PASSED
 Address line test:	PASSED
--------------------------------------------------------------------
Each working display should have its backlight on
and be displaying its #, address, and config information
If all pixels are on, or no pixels are showing, but backlight is on, try adjusting contrast pot
If backlight is off, wait for next test
--------------------------------------------------------------------
Blinking backlight test: to verify BL level autodetection
If backlight is mostly off but
you briefly see "BL Off" on display with backlight on,
then the library autodetected incorrect BL level
and the library cannot autoconfigure the device
--------------------------------------------------------------------
Displaying 'uptime' on all displays
--------------------------------------------------------------------

The backlight test works but I don't see any text anytime.

picture (could only upload 1):

code:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

const int buttonPin = 9; // D9
const int ledPin = 8; // D8

int buttonState = 0;
int ledState = false;

// Set the LCD address to 0x27
LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  // initialize Serial
  Serial.begin(9600);
  
  // initialize the LCD
  lcd.init();

  // initialize pins
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) {
    ledState = !ledState;
    if (ledState == HIGH) {
      digitalWrite(ledPin, HIGH);
      Serial.println("Device turned on");
      lcd.backlight();
      lcd.setCursor(3,0);
      lcd.print("Device turned on");
    } else {
      digitalWrite(ledPin, LOW);
      Serial.println("Device turned off");
      lcd.clear();
      lcd.print("Device turned off");
    }
    delay(1000);
  } 
}

I've tried so many things that I actually think the LCD might be broken. Hope I'm wrong.

Did you try adjusting the contrast pot on the I2C backpack?
I2C back pack CONTRAST
I wired up my Uno with a 20x4 LCD a button switch and an LED and tried your code. On reset the LCD reads Device turned off and the LED is off. A button press turns on the LED and the LCD reads DevDevice turned on. Pushing the button again toggles the LED state and the message on the LCD.

1 Like

You used the hd44780 diagnostic to detect the pinout.
But then included the random "LiquidCrystal_I2C.h" and the random constructor.

The whole point of "hd44780.h" is to have a known header with known methods. Or better still, let hd44780 detect and create the correct class instance automagically.

The "problem" with these random "LiquidCrystal_I2C.h" things is that one variety expects config: P01245673H but the other variety defaults to P45601237H

David.

Your LCD display it seems has 16x2 size, but you set 20x4 when creating lcd.
Try
LiquidCrystal_I2C lcd(0x27, 16, 2);
Try the Hello World example from LiquidCrystal_I2C library first, it works great.
Just set the screen size and adjust the contrast.

I agree with @ david_prentice. The hd44780 library is far better than any of the LiquidCrystal libraries. And it will autodetect the I2C address and I2C ecpander to LCD pin mapping.

You need to adjust the contrast control as groundFungus points out, until you see a clear row of "blocks" on the upper line. This is possibly easiest with SDA and SCL temporarily disconnected.

changing it to

LiquidCrystal_I2C lcd(0x27, 16, 2);

and then adjusting the contrast worked, thank you!

The hd44780 diag tool suggested adjusting the pot:

If all pixels are on, or no pixels are showing, but backlight is on, try adjusting contrast pot

I'm curious as to why you went back to the LiquidCrystal_I2C library vs using the hd44780 library which auto locates the ic2 address for you?

--- bill

Because that is what the tutorial he was following showed? :woozy_face:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.