LCD 20x4 I2C is not working well

Hello everyone, first of all, I know that there are lots of posts about this, but I have read them and I coundn't found anything to make it, al least, print a letter.

Let me introduce you to my problem, I have done a lot of research, and found an I2C Scanner (The result was 0x3F), at first I tought it was only the adress, but, apparently, it's not only that. I have tried with lots of libraries, but it was all the same, the examples don't work.

I have been working with Arduino Mega (SDA and SCL to pin 20 and 21) and with UNO (A4 and A5), the I2C module is the PCF8574AT, i have used two 4k7 pull up resistors for SDA and SCL.

I've ended up with this library and this testing code:

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

LiquidCrystal_I2C lcd(0x3F,20,4); 

void setup()
{
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
}


void loop()
{
}

Anyway, the LCD don't show anything

That library also has an example called "Custom chars" when I tried, it show only strange characters and japanese katakana characters, but that isn't what the code says it should show.

Did you also try Bill Perry's hd44780 library which comes with the IDE since (I guess) version 1.80 or so.
Using I2C backpack, you will find the examples for your device under:

examples/hd44780/hd44780examples/hd44780_I2Cexp/...

Bill's library is undoubtedly the best because it autromatically detects the LCD controller.

I found also this at YWrobot:

//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Make Display object, check and if necessary change here the i2c adress!
// origininally LiquidCrystal_I2C lcd(0x3F,16,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
// goede LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

void setup() {

lcd.begin(20,4); //initialize the lcd
lcd.backlight(); //open the backlight
lcd.setCursor(2,1); //positie 3, regel 1
lcd.print("Hello");
lcd.setCursor(10,2); //positie 5, regel 2
lcd.print("World!");
}

void loop() {
delay(1000);
}

Bill's library is undoubtedly the best because it autromatically detects the LCD controller.

In detail especially:

You don't have to worry about

  • neither the wiring of the backpack to the display itself
  • nor the I2C address

If Bill's library doesn't get your display glow - you might have to trash it :wink:

rpt007:
If Bill's library doesn't get your display glow - you might have to trash it :wink:

Not quite... There still might be hope.
There are a few backpacks that use a funky or improper transistor design for the backlight.
They are not very common, but if you get one of those, the auto detect s/w will get the backlight active level incorrect so the backlight state will be backwards and will be off by default.
on() will turn it off and off() will turn it on.
If you have one of these, you can still use it but in order for the backlight to work properly you will have to do a manual configuration similar to what you see with fm's library to tell the library all the configuration settings.

The diagnostic sketch is good for catching this potential issue.

Once the library is released at 1.0.0 (keep in mind that the code right now is just alpha code),
the library and the wiki on the github site will have documentation that describes how to handle this potential issue.

The hd44780 library doesn't actually come with the IDE but is available in the IDE library manager so it can be installed directly from the IDE GUI as long as you have an internet connection.
--- bill

Well, I have downloaded and tried with bill's library (I didn't know it, it's awesome), but I got the same, also I've tried with the I2CexpDiag example that library has, it's says its all ok, except for one thing... It said that there are no working LCD Devices, so i assume that my 20x4 LCD is not working at all...

I've loaded the "Custom Char" example and it showed that characters in the screen (in the attached image), but it's not even close to what the code says...

I think i'll test only the 20x4 LCD to see if it works or not... ¡Thank you all anyway!

Can you post the serial output from the diag sketch so I can take a look?

Along with a photo of the actual backpack.

--- bill

The CustomChars sketch in the currently released code does not look to see if the LCD initialization failed.
HelloWorld does.
If you run HelloWorld, if initialization fails, the on board LED should blink an error code.

BTW, this type of issue has typically been an issue with solder connections, either the backpack to the LCD or the backpack parts themselves, or in some cases the actual PCF chip.

I'm seeing more of these wierd issues, so I'll probably add some additional code to the diag sketch to try to help.

--- bill

I've proved almost all the examples, and yes, the board LED was blinking in the HelloWorld example.

This is the LCD:

This the I2C Backpack:

And this the serial output:

Are you using the breadboard?
How are you wiring the backpack to the Arduino?

What is the error code (how many blinks) that is showing up on the HelloWorld?

Yes i'm using a breadboard, I plug SDA and SCL to pins 20 and 21 of the Arduino MEGA, both with a 4k7 pull up resistor, and well, Vcc to 5v and GND to GND. I use a Female-female wire to the Backlight pins.

The HelloWorld does 1 blink every 2 seconds approximately.




Edit: Just added a few pics of the connection. Also, i've checked all the wires i'm using, and all of them seems to have continuity.

The external resistors on the breadboard are not needed; I would eliminate them. It will also make the wiring easier.
The backpack that you have has them on it. R8 and R9
Also, mega 2560 boards usually have them on the Arduino board.
If you are curious, you can use the diag tool to test if you have pullups on the arduino by disconnecting all the wires to the backpack/LCD/breadboard and running the diag tool.
It will tell you if detects pullups.

So when using your mega2560 board, with the resistors on the arduino board, you now have three 4.7k pullups on each i2c signal.
That reduces to around a 1.5k pullup which is pretty snappy and pushes the signal currents up near the i2c spec limits.

Try to see if works any better when you eliminate the external pullups - wire the SDA and SCL signals on the backpack directly to the mega header pins.

--- bill