16x02 LCD + I2C module problem

Hi all

I was trying to make my 16x02 LCD+I2C module work. I failed.
This is my LCD: LCD+I2C
PCF8574T is written on the I2C module chip.

I’ve tried two different pin configurations of the I2C module in the sketch however nothing still appears on the monitor (yes, I’ve tried to adjust the contrast but it’s not the cause).
I have to say that the monitor worked just fine using the traditional connection with 4 data wires, so the LCD works just fine.
Can it be that the I2C module doesn’t work properly?

Any suggestions?

I’ve taken a couple of pictures to inform you better.

Photo_1
Photo_2

After I’ve identified the I2C address of the LCD (0x27), I’ve tried a simple sketch:

// Include Wire Library for I2C
#include <Wire.h>
// Include NewLiquidCrystal Library for I2C
#include <LiquidCrystal_I2C.h>

// Define LCD pinout
const int  en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;
//const int  en = 4, rw = 5, rs = 5, d4 = 0, d5 = 1, d6 = 2, d7 = 3, bl = 7;
// Define I2C Address - change if reqiuired
const int i2c_addr = 0x27;

LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

void setup()
{
  lcd.begin(16,2);
  lcd.clear();
  lcd.print("Hello world!");
}


void loop()
{
}

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 menus, 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.

Thanks for the reply.
I’ve tried the hello world example in the class that you have mentioned but nothing appears on the display.
Which sketch do I have to choose as diagnostic sketch?

Here is the path to the I2Cexp diagnostic example (I2Cexpdiag.ino).

Here is real simple “Hello World” test code for a 20x4 I2C LCD using the hd44780 I2C library.

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

hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip


const int LCD_COLS = 20;
const int LCD_ROWS = 4;

void setup()
{
   lcd.begin(LCD_COLS, LCD_ROWS);
   lcd.print("Hello, World!");
   delay(5000);  
   lcd.setCursor(0,0);
   lcd.print("millis()        ");  // use blank spaces to overwrite old data
}

void loop()
{
   static unsigned long timer = 0;
   unsigned long interval = 1000;
   if(millis() - timer >= interval)
   {
      timer = millis();
      lcd.setCursor(0,1);
      lcd.print(millis());
   }
}

I attach the result of the test.
I have a 16x2 LCD tohugh.
Thanks

Change

const int LCD_COLS = 20;
const int LCD_ROWS = 4;

To

const int LCD_COLS = 16;
const int LCD_ROWS = 2;

For a 16x2 display.

Can be a wiring or solderng problem. Carefully examine the solder joints for cold joints and bridges. If you can, post photos of the LCD to backpack solder joints and the solder joints on the chips of the backpack.

I’ve soldered all the pins again. It looks like they weren’t soldered well enough.
Now it works!
Thanks!
One last question: I’ve tried again even the test and I’ve got as a result what you can see in the attached pic. Why does it say “no working LCD devices”?
I can run sketches and it says no working LCD?

I have seen that busy stuck message before. It think that it turned out tht there was a solder joint that was bridged by a tiny bit of wire or something. Though if the display works, I am not sure that there is anything wrong.

Are you saying that HelloWorld works but the Diagnostic fails?
That is odd since if the diagnostic fails, the LCD normally won’t work for other sketches.

If the diagnostic is reporting that BUSY is stuck, then there is a problem communicating with the LCD and that is why it reports No working LCD devices.
This needs to be resolved as it will likely cause other issues, since there is likely some issue either reading from the PCF8574, or the connections between the LCD and the PCF8574.

This is second case I’ve seen this happen recently. The other case, a few days ago, was due to a soldering issue.

Yes as groundFungus asked,
Can you post some clear close up photos of the solder connections to the LCD and also of the backpack as well?

— bill

I have to say that after some time working properly the LCD started to display strange characters. Before that the right characters were blinking while the LED backlight was always ON. Ithink I have to order new I2C modules since I have another 16x02 LCD working good with the traditional 4 data wires connection. This is the module I'm gonna buy: I2C module
Do you think it's a good cheap choice?
soldering details
PIC_1
PIC_2
PIC_3
I have to say that after the second soldering there was some short circuits between the A and K pins. that led to LED backlight flickering. I removed the cause of the short and now the backlight is on persistently but the characters displayed are strange.
Cheers

Why not buy the LCDs with the backpacks pre installed?

I don't see anything wrong in the images, but they are kind of small and the drop box site makes viewing them kind of hard on my tablet.

How to post images. Downloading images from that posting site is a pain in the rear.

Lucky-Luka:
I have to say that after some time working properly the LCD started to display strange characters. Before that the right characters were blinking while the LED backlight was always ON.

Like I said, if the diagnostic is not passing, there are issues, and you can expect strange things to happen.
But that doesn't necessarily mean that the h/w is completely broken.
There could be a minor issue that can be resolved.

Ithink I have to order new I2C modules since I have another 16x02 LCD working good with the traditional 4 data wires connection. This is the module I'm gonna buy: I2C module
Do you think it's a good cheap choice?

If that is Euros, then it looks a bit high to me.

Not sure where you are and your desired delivery timeframe,
but for getting product into the USA, the backpacks are available for $1 USD shipped, and LCD+Backpack already soldered starts at $2 USD shipped from many low cost vendors. The low cost vendors are from china and may take a while to get.
I'm also not sure how well shipping supply lines are working these days with all the virus stuff happening.

For the most part the all devices seem to work including the low cost stuff from china.
I've seen a few cases where people got a backpack with a poorly soldered PCF8574 but it could be fixed with a small touch of a soldering iron.
I'm not sure what your desired delivery time frame is, but
I would likely purchase some inexpensive ones from Ebay, with backpacks already attached.
(I have many devices that I use for testing all the different types & vendors of backpacks and they are all the cheap ones from Ebay)


For your current device

soldering details
PIC_1
PIC_2
PIC_3
I have to say that after the second soldering there was some short circuits between the A and K pins. that led to LED backlight flickering. I removed the cause of the short and now the backlight is on persistently but the characters displayed are strange.
Cheers

It sounds like you may have made some changes since you sent us the diagnostic output.
(multiple soldering)

We need to see everything as a snapshot.
photos of everything, and the diagnostic output at the time the photos are taken.
Then make no other changes until we discuss.

What is the diagnostic tool reporting now?

It looks like there may be an issue on PCF8574 pins 9 and 10.
If you look at 20200410_211738.jpg it looks like there may be a small small hair/wire laying across PCF8574 pins 9 & 10.
These pins are on the opposite corner of the chip from the little marker hole on pin 1.
In the photo, it is the upper right corner of the chip.
It looks like a small fine piece of wire. If so, that could create issues.

--- bill

One other soldering issue.
It is hard to tell but from looking at 20200410_211738.jpg as the angle and the shadows make it difficult to see but
it looks like there might be a soldering issue on pin 8 of the backpack.
In the photo count up from the bottom 8 pins. pin 8 is located about in the middle of the PCF8574 chip.

--- bill

Thanks for your kind replies

  1. The prices I posted are in Euros since I come from Italy

  2. After reading your posts I connected Arduino to the PC with the following sketch.

// Include Wire Library for I2C
#include <Wire.h>
// Include NewLiquidCrystal Library for I2C
#include <LiquidCrystal_I2C.h>

// Define LCD pinout
const int  en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

// Define I2C Address - change if reqiuired
const int i2c_addr = 0x27;

LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

void setup()
{
  // Set display type as 16 char, 2 rows
  lcd.begin(16,2);
  
  // Print on first row
  lcd.setCursor(0,0);
  lcd.print("Hello world!");
  
  // Wait 1 second
  delay(1000);
  
  // Print on second row
  lcd.setCursor(0,1);
  lcd.print("How are you?");
}


void loop()
{
}

It worked!

  1. I've tried the diagnostic sketch and I've read something regarding bad soldering in it... I closed the serial communication and I've started to write this post, then I reuploaded the diagnotic sketch and opened the serial communication again. This time it looks like everthing is ok.

4)After closing the serial communication I reopened it and I read what is present in the attached .txt file.

5)Pissed off I closed and reopened the serial communication and everything was ok

So, long story short, one time the test is passed, the next one LCD memory display test fails.
The pins are not shorted anymore though.

  1. I've tried to load the first sketch again and this is what appears... It looks like the LCD is tired too...

I think I will buy another I2C module :slight_smile:
Do you have a i2c + lcd model to suggest?

test2.txt (4.21 KB)

The issues you are seeing are consistent with soldering issues.
Given it comes and goes, I would suspect one or more cold solder joints that are sometimes making connections and sometimes not.

These devices are pretty simple and rarely fail but
debugging stuff like this requires careful attention to details and being very methodical.
I'm not sure what all you are doing as you seem to be bouncing around trying several different things and using multiple LCD libraries.

Again, there is no point in trying other things until the hd44780 library I2Cexp diagnostic tool says the h/w and the hd44780 library hd44780_I2Cexp i/o class is working.

I would recommend sticking to using the hd44780 library.

There were two potential soldering issues that I pointed out. Have you looked at them?
Please explain what all you have done to the h/w between your post #10 and your post #14 that made things a bit better.

--- bill

Lucky-Luka:
Do you have a i2c + lcd model to suggest?

"Model"?

These things are pretty generic. OK, there may be two or three variants of the display (some had an echo of the 16 pins along the bottom edge) but the basic materials will be the same. If you have a faulty display - and it happens - it will in most cases be just "the luck of the draw".

As I note Bill has just explained while I wrote this!

The same applies to the backpacks. There have been a number over the years but they seem to have whittled down to just a few presently available on eBay which I trust represents Amazon resellers and similar. The one you cite labelled "FC-113" is the presently widespread design but with three or four variants of just the lettering screen to "brand" them.


I note also one older - and oddly more expensive design which completely lacks the address jumpers and has a rather poor potentiometer! :astonished:

Please give us a picture of the display with only Vcc and ground connected - this verifies that you get the "blocks" on the first line with the correct contrast setting - as it seems to be correct already. If all "blocks" are there, it is not likely to be a display fault.

Original images "pic" 1 to 3:

groundFungus:
I don't see anything wrong in the images, but they are kind of small and the drop box site makes viewing them kind of hard on

No, they are anything but small! Click for full size!

bperrybap:
I'm also not sure how well shipping supply lines are working these days with all the virus stuff happening.

I'm not sure either, but most eBay advertised prices have at least doubled and many (Alice for one) are now advertised with ridiculous additional shipping charges. The last I received from my steady dribble of purchases was ordered March 6; March 13 yet to arrive. :roll_eyes:

There was a problem with the I2C module. Maybe I've damaged it while I've soldered it as a backpack of the LCD. Now I've changed it and the aforementioned sketch works just fine. I will not solder the I2C module as before since I don't have space problems and I don't want to waste too much time if I have to change the module in the future. The I2C module will be soldered in front of the LCD, as its position on the breadboard suggests.

I have to say that the library here suggested seems to be more difficult to use than the LiquidCrystal_I2C.h one. I don't know why you don't like it.

Thanks for everyone's help though

Lucky-Luka:
I have to say that the library here suggested seems to be more difficult to use than the LiquidCrystal_I2C.h one. I don't know why you don't like it.

Actually hd44780 with the hd44780_I2Cexp i/o class is easier to use than the LiquidCrystal_I2C library.
In order to use LiquidCrytsal_I2C:

  • You need a "LiquidCrystal_I2C" library that actually works
    (There are many out there all with the same name and some of them have bugs in them and don't work correctly, or even compile)
  • You have to know the i2c address
  • You must have the specific i2c backpack design that it is hard coded for.
    If the pin mapping on the backpack is different from what is hard coded in the library, it won't work.

As to why I prefer the hd44780 library and the hd44780_I2C i/o class:

  • It "just works" out of the box as it auto locates the i2c address and self configures the pin mapping.
  • It can easily be installed using the IDE library manager so there is no confusion about getting the correct version.
  • hd4780 does not conflict with any other LCD / "Liquidcrystal" type library.
  • User sketch code still works, without re-compiling even if lcd device is swapped for a different device that has a different i2c address or pin mapping.
  • The hd44780_I2Cexp i/o class is much faster than any of the LiquidCrystal_I2C libraries.
  • It is better maintained
  • It has API functions for the LCD API 1.0 and LiquidCrystal API compatibility.
  • It has additional features not available in other libraries like automatic line wrapping of long lines, and ability to read from LCD RAM
  • hd44780_I2Cexp i/o class includes a diagnostic tool to verify the that the library and h/w are working correctly.
  • Lots of included documentation including all API functions that can be brought up from the IDE.
  • Included documentation includes links to other LCD & chip related information and 3rd party tools
  • Better and more extensive examples

--- bill

And of course, Bill wrote it. :sunglasses:

In order to do all of those things and be as "idiot-proof" as possible.

The only obvious downside of all this is of course, that it compiles to more code than the simpler libraries. But that is not terribly likely to cause a problem short of a particularly extensive program.

Clearly the previous module was faulty.
20200411_225942.jpg
Given that it was coded to write the single string "Hello World!", there really is no plausible way a solder bridge, bad connection, faulty backpack - or simple code error - could cause it to miss a four-character group.

Poor contact with the "Zebra strip" due to assembly error or dropping the display on the ground is a possibility - it would be interesting to see this display tried again with a known working code that displays all characters on both lines since it is presently easy to swap given Lucky-Luka's recently-developed aversion to permanent soldering. :grinning: