[solved] LCD I2C problem printing text

Hello, I have an arduino uno and a I2C LCD-display. My problem is that I can get the lcd display to blink but not to write text! Have already found out that my adress is 0x3F and this is my I2c version. I have also installed the NewLiquidCrystal v1.3.4 library and i dont get anny errors when uploading the code (found the code online).

I DO KNOW ABOUT THE POTENTIOMETER and have tried turning it both ways with no luck. Any ideas? :confused:

#include <Wire.h>  // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup(){
  Serial.begin(9600);  
  lcd.begin(16,2);  
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  lcd.backlight();

  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(0,1);
  lcd.print("Hello, you!");
  delay(4000);  
}


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  {
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(Serial.read());
      }
    }
  }
}
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

Are you sure that the I2C expander to LCD wiring is in accordance with the constructor?

I have been using the hd44780 library on all of my LCD projects lately. The library will auto detect the I2C address and the expander to LCD wiring. Very easy to use with lots of examples. In my opinion, much better than any other LCD library (and I have tried most all of them).

groundFungus:

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

Are you sure that the I2C expander to LCD wiring is in accordance with the constructor?

I have been using the hd44780 library on all of my LCD projects lately. The library will auto detect the I2C address and the expander to LCD wiring. Very easy to use with lots of examples. In my opinion, much better than any other LCD library (and I have tried most all of them).

No i am not sure at all, but i have modified the code out of an example software sketch. Can you see whats wrong?

I have looked at the hd44780 library but there are not so many tutorials as it is for LiquidCrystal I2C. I also struggle to find example-codes that works. Could you help me with a simple/basic code to write text on my LCD I2C screen?

Here is the Hello World example from the hd44780 library (in the examples: ioclass, hd44780_I2Cexp, HelloWorld). The example was loaded to my Uno with a 16x2 display attached and works fine.

If this does not work, there is an I2Cexpdiag sketch in the same location that may help to find the problem.

One "gotcha" with the hd44780 library is that there is a class called "I2Clcd" that seems to be for your display. It is not. That class is for display controllers that communicate directly via I2C, not through an expander. I2Cexp is the class for your display.

// ----------------------------------------------------------------------------
// HelloWorld - simple demonstration of lcd
// Created by Bill Perry 2016-07-02
// bperrybap@opensource.billsworld.billandterrie.com
//
// This example code is unlicensed and is released into the public domain
// ----------------------------------------------------------------------------
//
// This sketch is for LCDs with PCF8574 or MCP23008 chip based backpacks
// WARNING:
// Use caution when using 3v only processors like arm and ESP8266 processors
// when interfacing with 5v modules as not doing proper level shifting or
//  incorrectly hooking things up can damage the processor.
// 
// Sketch prints "Hello, World!" on the lcd
//
// If initialization of the LCD fails and the arduino supports a built in LED,
// the sketch will simply blink the built in LED.
//
// NOTE:
// If the sketch fails to produce the expected results, or blinks the LED,
// run the included I2CexpDiag sketch to test the i2c signals and the LCD.
//
// ----------------------------------------------------------------------------
// LiquidCrystal compability:
// Since hd44780 is LiquidCrystal API compatible, most existing LiquidCrystal
// sketches should work with hd44780 hd44780_I2Cexp i/o class once the
// includes are changed to use hd44780 and the lcd object constructor is
// changed to use the hd44780_I2Cexp i/o class.

#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 & config exapander chip

// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;

void setup()
{
int status;

 // initialize LCD with number of columns and rows: 
 // hd44780 returns a status from begin() that can be used
 // to determine if initalization failed.
 // the actual status codes are defined in <hd44780.h>
 // See the values RV_XXXX
 //
 // looking at the return status from begin() is optional
 // it is being done here to provide feedback should there be an issue
 //
 // note:
 // begin() will automatically turn on the backlight
 //
 status = lcd.begin(LCD_COLS, LCD_ROWS);
 if(status) // non zero status means it was unsuccesful
 {
 status = -status; // convert negative status value to positive number

 // begin() failed so blink error code using the onboard LED if possible
 hd44780::fatalError(status); // does not return
 }

 // initalization was successful, the backlight should be on now

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

void loop() {}
1 Like

If this does not work, there is an I2Cexpdiag sketch in the same location that may help to find the problem.

Thanks, tried to run your code but nothing happened. I also uploaded the I2CexpDiag file in excamples and here is what i got in the serial monitor:

********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 0.9.3
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000
--------------------------------------------------------------------
 A4: digital pin: 18
 A5: digital pin: 19
SDA: digital pin: 18
SCL: digital pin: 19
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
--------------------------------------------------------------------
Scanning i2c bus for devices..
 i2c device found at address 0x3F
Total I2C devices found: 1
--------------------------------------------------------------------
Scanning i2c bus for all lcd displays
 LCD at address: 0x3F | config: P01245673H | R/W control: Yes
Total LCD devices found: 1
--------------------------------------------------------------------
LCD Display Memory Test
Display: 0
 Walking 1s data test:	
	Compare error: addr: 0 read 33 != wrote 1
	Compare error: addr: 0 read 33 != wrote 2
	Compare error: addr: 0 read 37 != wrote 4
	Compare error: addr: 0 read 3B != wrote 8
	Compare error: addr: 0 read 33 != wrote 10
	Compare error: addr: 0 read 33 != wrote 20
	Compare error: addr: 0 read 73 != wrote 40
	Compare error: addr: 0 read B3 != wrote 80

	Compare error: addr: 40 read 33 != wrote 1
	Compare error: addr: 40 read 33 != wrote 2
	Compare error: addr: 40 read 37 != wrote 4
	Compare error: addr: 40 read 3B != wrote 8
	Compare error: addr: 40 read 33 != wrote 10
	Compare error: addr: 40 read 33 != wrote 20
	Compare error: addr: 40 read 73 != wrote 40
	Compare error: addr: 40 read B3 != wrote 80

	Compare error: addr: 10 read 33 != wrote 1
	Compare error: addr: 10 read 33 != wrote 2
	Compare error: addr: 10 read 37 != wrote 4
	Compare error: addr: 10 read 3B != wrote 8
	Compare error: addr: 10 read 33 != wrote 10
	Compare error: addr: 10 read 33 != wrote 20
	Compare error: addr: 10 read 73 != wrote 40
	Compare error: addr: 10 read B3 != wrote 80

	Compare error: addr: 50 read 33 != wrote 1
	Compare error: addr: 50 read 33 != wrote 2
	Compare error: addr: 50 read 37 != wrote 4
	Compare error: addr: 50 read 3B != wrote 8
	Compare error: addr: 50 read 33 != wrote 10
	Compare error: addr: 50 read 33 != wrote 20
	Compare error: addr: 50 read 73 != wrote 40
	Compare error: addr: 50 read B3 != wrote 80
FAILED
 Address line test:	
	Compare error: addr: 0 read 33 != wrote 0
	Compare error: addr: 1 read 33 != wrote 1
	Compare error: addr: 2 read 33 != wrote 2
	Compare error: addr: 3 read 33 != wrote 3
	Compare error: addr: 4 read 37 != wrote 4
	Compare error: addr: 5 read 37 != wrote 5
	Compare error: addr: 6 read 37 != wrote 6
	Compare error: addr: 7 read 37 != wrote 7
	Compare error: addr: 8 read F3 != wrote 8
	Compare error: addr: 9 read F3 != wrote 9
	Compare error: addr: B read F3 != wrote B
	Compare error: addr: C read FF != wrote C
	Compare error: addr: E read FF != wrote E
	Compare error: addr: F read FF != wrote F
	Compare error: addr: 10 read 33 != wrote 10
	Compare error: addr: 11 read 33 != wrote 11
	Compare error: addr: 12 read 33 != wrote 12
	Compare error: addr: 13 read 33 != wrote 13
	Compare error: addr: 14 read 37 != wrote 14
	Compare error: addr: 15 read 37 != wrote 15
	Compare error: addr: 16 read 37 != wrote 16
	Compare error: addr: 17 read 37 != wrote 17
	Compare error: addr: 18 read F3 != wrote 18
	Compare error: addr: 19 read F3 != wrote 19
	Compare error: addr: 1A read F3 != wrote 1A
	Compare error: addr: 1B read F3 != wrote 1B
	Compare error: addr: 1C read FF != wrote 1C
	Compare error: addr: 1D read FF != wrote 1D
	Compare error: addr: 1E read FF != wrote 1E
	Compare error: addr: 1F read FF != wrote 1F
	Compare error: addr: 20 read 33 != wrote 20
	Compare error: addr: 21 read 33 != wrote 21
	Compare error: addr: 22 read 33 != wrote 22
	Compare error: addr: 23 read 33 != wrote 23
	Compare error: addr: 24 read 37 != wrote 24
	Compare error: addr: 25 read 37 != wrote 25
	Compare error: addr: 26 read 37 != wrote 26
	Compare error: addr: 27 read 37 != wrote 27

	Compare error: addr: 40 read 73 != wrote 40
	Compare error: addr: 41 read 73 != wrote 41
	Compare error: addr: 42 read 73 != wrote 42
	Compare error: addr: 43 read 73 != wrote 43
	Compare error: addr: 44 read 77 != wrote 44
	Compare error: addr: 45 read 77 != wrote 45
	Compare error: addr: 46 read 77 != wrote 46
	Compare error: addr: 47 read 77 != wrote 47
	Compare error: addr: 48 read FB != wrote 48
	Compare error: addr: 49 read FB != wrote 49
	Compare error: addr: 4A read FB != wrote 4A
	Compare error: addr: 4B read FB != wrote 4B
	Compare error: addr: 4C read F3 != wrote 4C
	Compare error: addr: 4D read F3 != wrote 4D
	Compare error: addr: 4E read F3 != wrote 4E
	Compare error: addr: 4F read F3 != wrote 4F
	Compare error: addr: 50 read 73 != wrote 50
	Compare error: addr: 51 read 73 != wrote 51
	Compare error: addr: 52 read 73 != wrote 52
	Compare error: addr: 53 read 73 != wrote 53
	Compare error: addr: 54 read 77 != wrote 54
	Compare error: addr: 55 read 77 != wrote 55
	Compare error: addr: 56 read 77 != wrote 56
	Compare error: addr: 57 read 77 != wrote 57
	Compare error: addr: 58 read FB != wrote 58
	Compare error: addr: 59 read FB != wrote 59
	Compare error: addr: 5A read FB != wrote 5A
	Compare error: addr: 5B read FB != wrote 5B
	Compare error: addr: 5C read F3 != wrote 5C
	Compare error: addr: 5D read F3 != wrote 5D
	Compare error: addr: 5E read F3 != wrote 5E
	Compare error: addr: 5F read F3 != wrote 5F
	Compare error: addr: 60 read 73 != wrote 60
	Compare error: addr: 61 read 73 != wrote 61
	Compare error: addr: 62 read 73 != wrote 62
	Compare error: addr: 63 read 73 != wrote 63
	Compare error: addr: 64 read 77 != wrote 64
	Compare error: addr: 65 read 77 != wrote 65
	Compare error: addr: 66 read 77 != wrote 66
	Compare error: addr: 67 read 77 != wrote 67
FAILED
--------------------------------------------------------------------
No working LCD devices

Does it mean that the LCD itself is broken?

Does it mean that the LCD itself is broken?

That would be my conclusion, sorry. The only other thing that I can think of is to examine the backpack for cold/bad solder joints or bridges.

I ran the same test on the setup from before and it was wholly successful.

I have looked at the hd44780 library . . .

You really should just install it and try it out. Just search out some of the posts with LCD and I2C in the title and you'll soon find out why.

Don

You really should just install it and try it out.

The OP did. See the results of the I2CexpDiag sketch in reply#4. Maybe you will see something that I did not. It looks like the expander chip is OK, but the display controller is not.

ArduinoBeginner01:
Does it mean that the LCD itself is broken?

Possibly, but usually that type of error is caused by poor or bad electrical connections between the i2c backpack and the LCD module.

It looks like the data bits controlled by DB6 and DB7 are stuck high.

Did you solder the backpack to the LCD module yourself?
Look very closely at the soldering to see if any of the pins are bridged together, or have solder that is not fully melted.

Can you post a couple of photos so we can see the solder connections on the LCD backpack and the LCD module?

--- bill

Can you post a couple of photos so we can see the solder connections on the LCD backpack and the LCD module?

No i did not solder on the backpack myself, it was delivered with solder on. I think the solder-job look ok and I cant find any bad connections:


The solder on the header pins on the backpack and the LCD module look ok.
So that probably is not the issue.

A few other things to look at/for.
See if you can see under the backpack to make sure it is not touching the metal frame tab on the LCD module.

It is hard to tell from the photo fcjz8m.jpg but some of the solder connections on the PCF8574 chip do not look so good. In fact the soldering of the pins on the right side of the chip don't look as good/nice as the ones on the left side.

In my previous post I mentioned DB6 and DB7 being stuck. That was wrong, it is actually DB4 and DB5.
Given the pin mapping selected by the library that will map to PCF8574 bits 4 and 5 which are PCF8574 pins
9 and 10.

In the photo fcjz8m.jpg, pin 9 is the bottom right corner.
Again it is hard to tell in the photo, but that pin does not look like it is soldered properly if at all. It looks like it is offset a bit and not even in the solder.
The pin above that is pin 10, it also looks like it has a soldering issue like it is sitting on top of the solder rather than being in it.

I would look very closely at those pins. If those two pins were not soldered, they could cause the issue you are seeing.
If there is an issue there, you will need resolder them.
You will want to use an iron with a small pointy tip so that you can press down on the pin a bit to get the solder to stick to it.
Take the soldering iron and lightly and carefully touch it to the pin to remelt the solder to make sure the solder is sticking to the pin.
Maybe even lightly/carefully scratch the pin a little bit with a knife/pocket knife to clean and score it to make the solder stick to it. Or clean the pins with a bit of alcohol and a cutip. If you use the alcohol to clean the pins, make sure they are fully dry before soldering them.

--- bill

I tried to heat all pins up and resolder the worst ones, but without results. Still same error. I ordered a new one now and hope that one would work. I am very happy for all the help I got from you!

While you wait for your new one to come in, maybe we could try a few more things on your current device?
I've not actually seen case of one of these types of devices with an LCD with a bad internal memory with stuck bits like that yet.
I have seen at least one or two other cases of a PCF8574 that wasn't soldered to the backpack correctly.

The stuck bits looks more like the PCF8574 P4 and P5 pins are not connected to anything.

Can you post a closeup photo of the PCF8574 chip so we can look at the pins and the soldering?

--- bill



Was this what you ment?

ArduinoBeginner01:
Was this what you ment?

Not really. I was asking for a close up of the PCF8574 chip to look at the pins you said you re-soldered.
However, the PCF8574 chip can be seen in photo id664y.jpg
It doesn't look like you re-soldered pins 9 and 10. They look the same as in photo fcjz8m.jpg
If you did solder them, it doesn't look like it was good enough to get the solder to flow and stick to the pins.
I attached a close up image that shows the two pins.

In your latest photo, it still looks like Pin 9 is offset, and pin 10 looks like it is on top of the solder rather than it in.
These two pins need to be re-soldered.

So like I said before, you should re-solder pins 9 and 10 of the PCF8574 chip.

pin 9 is the upper left pin of the chip in photo id664y.jpg with pin 10 the pin vertically below it a little to the right of capacitor C1.
pin 9 is the lower right pin of the chip in photo fcjz8m.jpg with pin 10 being the pin vertically on top of it a little to the left of capacitor C1.

id664y.jpg

So like I said before, you should re-solder pins 9 and 10 of the PCF8574 chip.

Did what you said and now it works! Thank you very much!

ArduinoBeginner01:
Did what you said and now it works! Thank you very much!

???
In post #10 I said to re-solder PCF8574 chip pins 9 and 10 and then in post #11 you said:

ArduinoBeginner01:
I tried to heat all pins up and resolder the worst ones, but without results. Still same error. I ordered a new one now and hope that one would work. I am very happy for all the help I got from you!

But then in post #13 the PCF8574 chip pins 9 and 10 didn't look like they were re-soldered.
Now you said you soldered those two pins and it is working.
Details really matter.
What pins were you really re-soldering the first time?

--- bill

What pins were you really re-soldering the first time?

I first re-soldered the 16 big pins between the lcd board and the backpack board because some of them looked bad. First i didnt understood what chip you where talking about but figured it out when you posted the picture :wink:

There is only 1 chip on that backpack. :wink:

Hi, Friends,

I tried to do this project few times using various method. But I can not succeed.​ Black boxes are displayed instead of text. I adjusted contrast, Address etc and checked all connections. But my LCD panel and Arduino are working. Black light can control. Please help.

Hemantha.