HD44780 initialization failed LCD 1602 I2C

Hello, I am using an LCD display 16x2 with an I2C module (based on the PCF8574 IC, see 2nd pic) alongside a Arduino Uno WiFi Rev2.

I'm a beginner to Arduino and I want to use the LCD display as part of a project for a uni course and I'm stuck with trying to get the LCD to display something. I'm connecting the SCL and SDA pins of the I2C module to the A5 and A4 pins of the Arduino, respectively.

From what I've read on-line, in particular from other posts from this forum (e.g. HD44780 not working on my I2C LCD - #2 by outbackhut), the hd44780 library is ideal for my project, with this sort of LCD display. However, when running the I2CexpDiag Example in Arduino IDE (File -> Examples -> hd44780 -> ioClass -> hd44780_I2Cexp), when trying to initialize the LCD display (with lcd.begin()..), I'm getting "LCD 0 begin() failed: -4" (see 1st pic).

Note that, in the 1st pic, it says "i2c device found at address 0x60", which is odd given that this I2C module came configured with the 0x27 address. However, I have another LCD (not the one I'm currently using but used before for troubleshooting) which has a different I2C with the 0x60 address, if that helps in building an understanding of the issue.

I am able to use this second LCD display (see https://mauser.pt/catalog/product_info.php?products_id=096-6824) with address 0x60 but the issue is exactly the same.

Any help would be greatly appreciated!

Edit: I ended up switching to a Arduino Uno Rev3 + an ESP8266 module (instead of an Arduino Uno Wi-Fi Rev2) and a similar LCD display for which I used a different library (Grove - 16x2 LCD | Seeed Studio Wiki, if you're curious) and this is enough for my purposes so I abandoned my previous implementation!


are the pins fully soldered correctly ?

did you also connect 5V and GND?


Yes, the pins are fully soldered (I will add a picture).
Yes, I did connect the 5V and GND to the VCC and GND pins in Arduino


look at the board's pinout. It's not A4 A5 on that board, that's would be for the regular UNO R3


try this code

#include <Wire.h>
#include <hd44780.h>                        // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h>  // i2c expander i/o class header

const uint8_t nbCols = 16;
const uint8_t nbRows = 2;
hd44780_I2Cexp lcd;

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

  int result = lcd.begin(nbCols, nbRows);
  if (result) {
    Serial.print("LCD initialization failed: ");
    Serial.println(result);
    hd44780::fatalError(result);
  }
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print(millis());
  delay(1000);
}

Yes, I've tried connecting the LCD pins to the D21/SCL and D20/SDA pins of the Arduino but the issue remains the same (originally I was trying with A5 and A4).

Thank you for the code! I've tried it (adjusting for Serial.begin(9600) instead) but the issue remains "LCD initialization failed: -4"

may be you have a weird module at address 0x60
try forcing the address in the code

 hd44780_I2Cexp lcd(0x60); // <=== specify a specific i2c address

full test code


#include <Wire.h>
#include <hd44780.h>                        // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h>  // i2c expander i/o class header

const uint8_t nbCols = 16;
const uint8_t nbRows = 2;
hd44780_I2Cexp lcd(0x60); // <=== specify a specific i2c address

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

  int result = lcd.begin(nbCols, nbRows);
  if (result) {
    Serial.print("LCD initialization failed: ");
    Serial.println(result);
    hd44780::fatalError(result);
  }
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print(millis());
  delay(1000);
}

Thank you. There seems to have been a change in the error code, it changed to "LCD initialization failed: -1". I will have to look up as to why in the documentation for the hd44780 lib

Have you already run the I2C scanner.....?

https://playground.arduino.cc/Main/I2cScanner/

There should be no need to run any other code other than I2Cexpdiag.
In terms of pins, I2Cexpdiag tells you which Arduino pins can be used.
If A4 and A5 are i2c signals those should be reported in the output.

The first thing I2Cexpdiag does after checking the i2c signals and pins is to scan the bus
for ALL i2c slaves.
You see one slave device at address 0x60.
This is not a PCF8574.
This is why it reported no working LCD devices.
It scanned all addresses looking for the LCD backpacks (0x20-0x27 and 0x38-0x3f)
and didn't find any. Which agrees with the i2c slave device scan which only found
a single i2c slave at address 0x60.

It isn't clear to me which Arduino board was being used to create the I2CexpDiag.
Maybe you ran it on the Wifi board and and has an i2c device on board.
OR maybe you were using some other i2c LCD which has a PWM slave device that
is at address 0x60

Do you only have the 1 device (the LCD with the PCF8574 backpack) hooked up?
For diagnostic purposes, it is best to only hook up one LCD with a PCF8574 backpack.

Did you get the SDA and SCL signals connected backwards or to the incorrect pins on the Arduino board?

--- bill

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