LCD I2C 20x4 doesn't work

Hi, I have a problem, I have an LCD I2C 20x4 for arduino mega, i can switch on the LCD but it doesn't appears any text.
here is my code:

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

#define I2C_ADDR 0x3F // Define I2C Address where the SainSmart LCD is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{

// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.begin (20,4);
// Position cursor and write some text
lcd.home (); // go to the first line, first character
lcd.print("");
lcd.setCursor ( 0, 1 ); // go to the 2nd line
lcd.print("
");
lcd.setCursor ( 0, 2 ); // go to the third line
lcd.print(" hello world!");
lcd.setCursor ( 0, 3 ); // go to the fourth line
lcd.print("****");

}

void loop()
{

}

sketch_feb02a.ino (927 Bytes)

Is there a contrast control on the LCD board ?

UKHeliBob:
Is there a contrast control on the LCD board ?

yeah, i increased the contrast and it appeared some strange letters and symbols

yeah, sometimes appears a contrast on the LCD Board

Slowly, turn the contrast pot to CW and then CCW to see if there is any character (s) that has really appeared on the LCD. Keep the contrast value approximately in the middle of the pot.

Please read this link for possible cause of non-functionality of your I2C LCD.

  1. It was my understanding that lcd.begin (20,4); should be the first lcd method called.
  2. Are you sure that those are the correct pin assignments for your device?
  3. Are you sure that is the correct I2C address for the lcd. Nick Gannon has posted code to list the I2C addresses?
  4. Do the I2C lines have pullup resistors ?

GolamMostafa:
Slowly, turn the contrast pot to CW and then CCW to see if there is any character (s) that has really appeared on the LCD. Keep the contrast value approximately in the middle of the pot.

Please read this link for possible cause of non-functionality of your I2C LCD.

i tried, it appears some strange symbols

stowite:

  1. It was my understanding that lcd.begin (20,4); should be the first lcd method called.
  2. Are you sure that those are the correct pin assignments for your device?
  3. Are you sure that is the correct I2C address for the lcd. Nick Gannon has posted code to list the I2C addresses?
  4. Do the I2C lines have pullup resistors ?

i tried 1,2,3 and nothing...
I don't use resistors in I2C, should I?

Please post the backside photograph of your I2C LCD. Is it similar to the following?


Figure-1: 8574 IO extender based 16x2 LCD

GolamMostafa:
Please post the backside photograph of your I2C LCD. Is it similar to the following?


Figure-1: 8574 IO extender based 16x2 LCD

is bigger because it's 20x4 but the I2C component is the same

If the IO extender is the same, then the deviceaddress should be in the range: 0b0100000 - 0b0100111 (0x20 - 0x27). There is now way for it to be 0x3F (0111111). Probably, you have the wrong Library installed (please read this link).

The lcd object contains three arguments LiquidCrystal_I2C lcd(deviceAddress, 20, 4); ant not like this:LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin) which contains 8 arguments.

There is now way for it to be 0x3F (0111111).

There are 2 "flavors" of the PCF8574. The PCF8574 has the address range 0x20 to 0x27, the PCF8574A address range is 0x38 to 0x3F.

jordibullo:
i tried 1,2,3 and nothing...
I don't use resistors in I2C, should I?

I don't understand this at all. I can understand the concept of trying 1) since that is just moving a line of code but trying "2) Are you sure that those are the correct pin assignments for your device?" makes no sense. How can you 'try' to check the pin assignments?

How did you 'try' "3) Are you sure that is the correct I2C address for the lcd. " ? did you run Nick Gannon's little sketch to see what your I2C address is? If so, what was the result. I have two different piggy back boards for these LCD displays with different I2C addresses and different PCF8574 pin usage.

I'm not sure I believe " i tried 1,2,3 and nothing..." !

Edit: One of my piggy back boards looks identical to yours and it most definitely does not have I2C address 0x3F
! Neither does the other one.

This Library works fine with my PCF8574 based IO Extender which is attached with I2C 16x2 LCD. The OP can try installing this Library!