Can't get I2C display to work

Dear people,

I have an Arduino Uno Rev 3 with an I2C (PCF8574T) 16X2 display.
According to the sellers website it's 0x27. I tried running an I2C scanner but it keeps scanning without any results. When I pull the SDA cable from pin A4 and the SCL kabel from pin A5 the scanner notices that there are no I2C devices found. When I plug the cables back in it stalls on scanning again.

I have turned the constrast pot to the max.

I ran multiple different simple test codes like the one below without succes. The LCD stays on with one bar of white blocks.

LCD DISPLAY.png

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
 
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
 
 
void setup() 
{
  lcd.begin(16,2); 
  lcd.backlight();
}
 
 
void loop()
{
  lcd.setCursor(2,0);
  lcd.print("Ciao Ragazzi");
  lcd.setCursor(6,1);
  lcd.print("(TEST)");
}

What can be the problem of my LCD not functioning?

LCD DISPLAY.png

Some (few) I2C backpacks (in my experience) do not have the required pullup resistors on board. Does yours have them? If not you need to pull SDA and SCL up to 5V with external resistors.

Can you post a photo of the I2C backpack showing the solder joints on the I2C chip and the header between the backpack and LCD? There have been instances of bad soldering causing problems, lately.

A better library to use is the hd44780 library.

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

Install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.

In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results.

Dear groundFungus,

Thanks very much for you indepth and detailed answer!

I installed the library but sadly the result is no different.

I tried with this code:

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

hd44780_I2Cexp lcd; // declare lcd object: auto locate & config display for hd44780 chip

void setup()
{
  // initialize LCD with number of columns and rows:
  lcd.begin(16, 2);

  // Print a message to the LCD
  lcd.print("Hello, World!");
}

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

The screen still displays only one bar of white blocks.

As you asked I attached pictures of the soldering of the headers. They are not the prettiest solder joints but seem to hold.

I will try to run a diagnostic sketch now, will post results in a bit.

Diagnostic came back with:

"Arduino:1.8.9 (Windows 10), Board:"Arduino/Genuino Uno"

hd44780examples:140:28: error: hd44780_I2Cexp.h: No such file or directory

compilation terminated.

exit status 1
hd44780_I2Cexp.h: No such file or directory

Dit rapport zou meer informatie bevatten met
"Uitgebreide uitvoer weergeven tijden compilatie"
optie aan in Bestand -> Voorkeuren."

Which is weird since I installed Bills library just the now.

first thin I would try is swap ther I2C leads to see if the I2C scanner wakes up. I would also adjust the pot on the back of the module to reduce the garish white glow to just a hint of gray.

I changed the pot meter to get the display to display a hint of grey.

I swapped SDA - A4 and SCL - A5 to the dedicated SDA and SCL port on the other side of the board without avail. The scanner still doens't notice and stalls on scanning....

Did you install the library using the library manager (as in the instructions that I posted)? The diagnostic will check a lot of things besides the address if you can get it to run. Also, the author of the library is often on this forum and given the diagnostic output he can usually spot the problem.

How about photos showing the other side of the chip solder joints?

The problem here is that the Arduino is not communicating with the PCF8574. The display itself, soldering of the backpack to the display and the contrast adjustment are entirely irrelevant until this communication i established. Check the continuity of the wires used to connect SDA and SCL.

Driez:
Diagnostic came back with:

"Arduino:1.8.9 (Windows 10), Board:"Arduino/Genuino Uno"

hd44780examples:140:28: error: hd44780_I2Cexp.h: No such file or directory

compilation terminated.

exit status 1
hd44780_I2Cexp.h: No such file or directory

Dit rapport zou meer informatie bevatten met
"Uitgebreide uitvoer weergeven tijden compilatie"
optie aan in Bestand -> Voorkeuren."

Which is weird since I installed Bills library just the now.

That type of error looks like the library was either not installed or was not properly installed.
The IDE will install it for you if you use the library manager and it is very simple, quick & easy.
You do not have to download anything like zip files. Let the IDE do the install for you rather than trying to do it manually or using a zip file as those methods are very error prone.

There are installation instructions on how to use the IDE on the github page: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
See the "Installation" section, "Installation using Library manager (IDE 1.6.2 and later)" subsection.

The I2CexpDiag sketch is a good tool for helping diagnosing issues.
Once the hd44780 library is installed, there should be no issues compiling and uploading it to your Arduino.

--- bill

Ok, I just noticed that you are using REALLY REALLY old code that isn't a clone or fork of the actual repository and perhaps are mixing old and new hd44780 library code & examples.

I would suggest that you do not run any code from here: https://github.com/ikozin/Arduino/tree/master/KitchenStation/libraries/hd44780
That code appears to have come from 3 years ago at release 0.7.1
MANY things have changed since then, including some of the hd44780 library tree structure - which affects where header files are which affects the #include for hd44780 header files in sketches.

As recommended, install an official release using the IDE library manager.
The latest version of the hd44780 library (as of 2019-08-30) is 1.1.0

--- bill

Turns out it was a bad LCD, a friend hooked me up with another one and it works with no problems.

Thanks everyone!

Correction: Bad backpack, not the LCD module. $1 on eBay.

Driez:
Turns out it was a bad LCD, a friend hooked me up with another one and it works with no problems.

Thanks everyone!

Not necessarily.
You had several issues.
You also never showed us the soldering of the pins to the LCD module.
The best thing to do would be run the hd44780 diagnostic sketch, I2CexpDiag, and have it report what it finds.

While I have seen a few bad backpacks, it is pretty unusual.

--- bill

bperrybap:
Not necessarily.

Yes, Necessarily.

As per the OP, the I2Cscanner found no I2C device and baulked. How could a fault in the LCD module possibly cause that? And the LCD correctly hardware initialised.

bperrybap:
While I have seen a few bad backpacks, it is pretty unusual.

No doubt, but bad soldering is always a risk. What happens to the I2Cscanner (different versions) when SDA and SCL are shorted?

Paul__B:
Yes, Necessarily.

Sometimes a non working or "bad" LCD/module (backpack + LCD) is not working because of wiring or soldering issues and can easily be fixed/repaired.

As per the OP, the I2Cscanner found no I2C device and baulked. How could a fault in the LCD module possibly cause that? And the LCD correctly hardware initialised.
No doubt, but bad soldering is always a risk. What happens to the I2Cscanner (different versions) when SDA and SCL are shorted?

It appears that the LCD powered up in its default state but was not initialized by the host (arduino).
True the I2Cscanner didn't appear to be working which seems to point to an i2c backpack issue but,

I've seen several weird cases that have also caused those types of symptoms

  • bad wires connecting the Arduino to the LCD backpack
  • bad 4 pin connector connecting to the backpack with opens on SCL or SDA signals
  • bad 4 pin connector connecting to the backpack with shorts between SCL and SDA (inside the 4 pin connector)
  • lack of good contacts on Arduino SCL & SDA wires to header pins on the Arduino board.
  • backpacks with PCF8574 chips that were not properly soldered to the backpack PCB.

opens on SCL or SDA tend to isolate the external pullups.
While most AVR based Arduino boards seem to "work" using the internal pullups, some have issues when there are not external pullups.
Shorts on SCL and SDA can also create very odd symptoms.
I've seen both missing external pullups and shorts create i2c hangs, which is why I2CexpDIag attempts to test for both.

In some cases these issues can "magically" go away or are intermittent as the board, wires, or connectors are moved around.

The I2CexpDiag sketch will test SDA and SCL for shorts between each other, and to gnd as well as for the presence of external pullups.
IMO, it is the best tool to help tracking down issues with i2c lcd backpacks.

--- bill

Sorry, I perhaps misread your comment #13 where you were replying to a comment on a "bad LCD".

I believe we are definitely in agreement that the problem is the backpack (or the wiring between it and the Arduino) and not the LCD module proper.

But you did say:

bperrybap:
You also never showed us the soldering of the pins to the LCD module.

Which is not relevant.

Given that - as I advised in #7 - the wires have been checked and there is no soldering fault on the backpack, it would be possible with consummate skill, to unsolder the backpack from the LCD module itself and replace - the backpack. Or the LCD could be tested by (I of course never advise this for an end product) connecting directly to the Arduino. :grinning: