Arduino i2c for 16x2 lcd no backlight or text after upload [solved]

Hello there!

So i got this http://www.ebay.com/itm/190884410181

Made sure about the address with i2c scanner that its 0x27.

Im using LiquidCrystal_I2C V2.0 library.

When LCD is attached to 5V only or without the basic “hello world” example i see backglight.

But when i upload the sketch the lcd backlight goes off. And still i see no text.

What could be wrong here? I2c scanner shows the address so i2c is working. ’

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

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x20 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 

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

void loop()
{
}

Code seems ok. " lcd.backlight();" should turn the backlight on but…

Device address is 0x20 not 0x27. You should solder the A0, A1 and A2 joints for 0x27.

According to I2C scanner the address is 0x27

I2C Scanner Scanning... I2C device found at address 0x27 ! doe

I did try 0x20 to be safe but no happines here.

Strange. With I2C scanner the backlight is on. But when i upload the Hello world from LiquidCrystal_I2C it stays black.

On my i2c backpack these A0, A1, A2 are not soldered to anywhere. It seems that if i solder them it will change address to 0x20. Source: http://forum.arduino.cc/index.php?topic=158312.0

Adjust the contrast with a screw on blue trimmer.

That does not affect backlight. Only contrast.

Theres an image. 4k7 pullups. LCD background only blinks on start.

Your adapter is almost identical (I don't think there are any two that are exactly the same) to one I got recently.

You do not need (or want) any external pull-up resistors as the SCL and SDA lines are already pulled up by on-board 10K resistors.

With the three address lines un-jumpered the address is 0x27 as you have already verified.

I suggest that you use the I2C library written by 'FM' and available here: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads .

This library allows you to deal with the fact that various manufacturers use different connections between the IC and the pins going to the LCD on their individual pc boards. I believe that the constructor that will work for you is:

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

Don

Edit: I think the examples provided with the library are a bit obsolete. You control the backlight with lcd.backlight(); and lcd.noBacklight();

Thanks for the reply.

First thing i notice with the new library is the name. i dont want to overwrite the original LiquidCrystal do i?

Can i just rename the new library? I actually did stumble on to that new LiquidCrystal but i had the same question on my head that can i rename it.

Can i just rename the new library?

Rename the old library.

Don

floresta:

Can i just rename the new library?

Rename the old library.

Don

I'd suggest following the installation instructions.

The reason is that if you deviate, and just rename things, now you have header file name collisions, (multiple libraries with the same header file name) and depending on which version of the IDE you have and what names you use you can end up not getting the library you are wanting. Even worse, you can end up using more than one or part of one an part of another.

--- bill

neepie: First thing I notice with the new library is the name. I don't want to overwrite the original LiquidCrystal do I?

Yes, you absolutely do want to remove the original library.

neepie: Can I just rename the new library? I actually did stumble on to that new LiquidCrystal but I had the same question on my head that can I rename it.

Just move it to somewhere else in your file system. If it is not working, you need to get rid of it.

Now - I like your breadboard, particularly how you have mounted the "backpack" and display, perhaps because it resembles what I might have here. :D I presume you have solidly soldered a pin header to the LCD which works well in this manner but would be inconvenient when you actually want to more permanently mount the backpack. As most backpacks come with a pin header mounted and most LCDs do not, the best approach is to solder a socket header to the LCD. If you then want to mount it to a breadboard, you just interpose another pin header.

I am a trifle surprised bperrybap has not directed you to his "i2cLCDguesser" sketch which is what you run to determine the "descriptor" for your particular backpack. The previous call you cited using "LiquidCrystal_I2C lcd(0x27,16,2)" is essentially obsolete as it presumes you are using a particular backpack which is now relatively uncommon. The proper call incorporates all the pin assignations and the "i2cLCDguesser" gives you the exact ones to insert.

You are of course correct against the unhelpful hecklers insofar as if the "i2cscanner" or the more sophisticated "guesser" tells you the address is 0x27, then that obviously is what it is.

Paul__B: I am a trifle surprised bperrybap has not directed you to his "i2cLCDguesser" sketch which is what you run to determine the "descriptor" for your particular backpack.

I'm actually trying to stay low for a bit as I'm working a new LCD library that should make all these types of issues go away. I really feel for the less technical users trying to get their i2c LCDs up and working and I'll have solution that makes it really easy, but it isn't quite there yet. I'm still working on it.

--- bill

Yes, you absolutely do want to remove the original library.

Please tell me why? If i do remove it, does my existing sketches with parallel lcd work?

I presume you have solidly soldered a pin header to the LCD which works well in this manner but would be inconvenient when you actually want to more permanently mount the backpack.

Actually i got 3 16x2 lcd:s which i've already soldered a header. And yes, the i2c backpack did have a nice row of headers soldered already. So i went out and test the lcd on a breadboard. Later i will of course solder the backpack to the lcd.

This brings me a question. I always used these parallel 16x2 lcd:s with 4-bit mode. So i can save few pins on arduino. Does this i2c backpack require all 16 pins attached on the lcd-backpack or can i use 4-bit mode lcd with the backpack?

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

That seems like the i2c is only using 4bit mode? Which is fine for me. Or am i wrong and i need all the 16 pins (yes, the backlight too) to run the i2c backpack correclty?

Thanks alot guys for giving me more information. Just cant wait to get home!

I will be forgetting about 4bit lcd:s and parallel mode. When i get this i2c backpack working ill be ordering more to save pins/wiring!

Just need to get this working first :)

Im off from home until end of the week. I wil be then testing more and trying that new liquidcrystal library!

If i do remove it, does my existing sketches with parallel lcd work?

Yes. *FM*s library will run your existing sketches.

Does this i2c backpack require all 16 pins attached on the lcd-backpack or can i use 4-bit mode lcd with the backpack?

You don't have to connect the four adapter pins that go to the lower four LCD data pins but all you will save by not attaching them is a tiny bit of solder.

You must use the 4-bit mode because the I2C adapter does not drive the lower four LCD data pins. The library takes care of this for you when you invoke the proper constructor.

Don

Yes. FMs library will run your existing sketches.

Righto, will change to it then. Care to shortly tell me whats new on it? Other than it runs the i2c lcd:s?

Thats good that it only supports 4bit. I do have some lcds which have the 16 pin headers. But when i learned that i dont need them all i only soldered the necessary ones to make it a bit simpler.

Finally i got to test it.

This is what worked for me.

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


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

void setup()
{
  lcd.begin(16,2);                
  lcd.home ();                   
  lcd.print("Arduino i2c ");  
  lcd.setCursor ( 0, 1 );        
  lcd.print (" Test lcd!   ");
  delay ( 1000 );
  lcd.clear();
}

void loop()
{

  lcd.home ();
  lcd.print("testtest");
  lcd.setCursor(3,1);
  lcd.print("more test");
  delay (200);
}

But what about that “POSITIVE”? I I think i cannot control the backlight with arduino or can i? Without soldering an output to jumper.

If i only use this: LiquidCrystal_I2C lcd(0x38);  // Set the LCD I2C address
I get a blinky LCD.

The backlight is dealt with by the '3' and the 'POSITIVE' in the constructor. Try turning it on and off using the information at the end of reply #6.

Don

neepie:

This is what worked for me.

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

If i only use this: LiquidCrystal_I2C lcd(0x38);  // Set the LCD I2C address I get a blinky LCD.

That seems very unlikely since you are saying both are talking to the LCD but they are using two different i2c addresses. (Details matter when trying to get something up and working)

Ignoring the i2c address issue,

When you use the constructor that only specifies the address, it says: my address is 0x38 and I want to you pick all the other values for me.

I don't recommend ever using defaults. If you don't specify everything, it is kind of like the constructor saying: "What pins would like to use, and you say, 'It doesn't matter, any pins'". Which so reminds me of the Hornitos commercial: http://www.youtube.com/watch?v=vKqJjTIZgO8

When not specified, the pin values used are for fm's LCD extra i/o board which you do not have. That is why the i2cLCDguesser sketch gives you the full constructor. So you know what you are getting.

--- bill

That seems very unlikely since you are saying both are talking to the LCD but they are using two different i2c addresses.

Actually i did have the right address while testing it. But i removed it and copied here from another sketch.

That is why the i2cLCDguesser sketch gives you the full constructor.

I tried that guesser but when it says in serial monitor to "hit enter or click send", it does nothing.

About backlight, seems like the lcd.noBacklight and lcd.backlight is working. But if i want to dim it i need to use a PWM pin instead of the jumper there.

neepie:

That is why the i2cLCDguesser sketch gives you the full constructor.

I tried that guesser but when it says in serial monitor to “hit enter or click send”, it does nothing.

Did you folllow step #6 of the instructions?
If so, I really want to know more in case there is an issue.
The few times this has come up before and I ask for more information to be able
to repeat it, the person with the issue either didn’t follow #6 or they disappear.
So have yet to actually personally see a real case of the guesser not responding to or [send].

About backlight, seems like the lcd.noBacklight and lcd.backlight is working. But if i want to dim it i need to use a PWM pin instead of the jumper there.

It may a bit more complicated, depending on the h/w design of the backpack.
The jumper typically isn’t connecting the base of the transistor to a PCF8474 pin.
If not, you will have modify the board so that the base of the transistor connects
to your Arduino pwm rather than a pin on the PCF8574.
Then you will have to make modifications to the LiquidCrystal_I2c code in order
to get setBacklight() to work or modify your sketch code
use analogWrite() as the existing LiquidCrystal_I2c code only has support for driving
PCF8574 pins.