Another i2c LCD issue 4 x 20 with i2c backlight

Hi All I bought this LCD
http://www.ebay.com/itm/281141014288?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

I am using a Sainsmart Mega 2560

I have found the i2c scanner and verified that it responds on i2c address 0x27. (confirms no stupid wire error)

I have tried LCD library that was linked via wiki via the ebay listing as well as the one referenced in the code snippet

I get no chars on display or no backlight. It acts 100% dead except for the i2c scanner which does detect it.

All I can think of is the magic numbers for the LCD connections are wrong.

Any ideas??
Also I was unsure if the Ardunio could power this off usb or not so I added a wall pwr supply that is rated 5 volt 1 amp, although to be honest I tested the 5v/ ground right at the LCD I2c board and saw 4.8 volts

1 more minor question. There is a shunt jumper on the i2c board labeled LED, any idea that is, I was guessing it was full backlight, and a POT could replace shunt for brightness control.

Here is a snippet of code

/* YourDuino.com Example Software Sketch
20 character 4 line I2C Display
Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
Connect Vcc and Ground, SDA to A4, SCL to A5 on Arduino
terry@yourduino.com */

/-----( Import needed libraries )-----/
#include <Wire.h> // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
//#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_I2C.h>

/-----( Declare Constants )-----/
/-----( Declare objects )-----/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol

/-----( Declare Variables )-----/
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

void setup() /----( SETUP: RUNS ONCE )----/
{
Serial.begin(38400); // Used to type in characters

lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines, turn on backlight

// ------- Quick 3 blinks of backlight -------------
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(150);
lcd.noBacklight();
delay(150);
}
lcd.backlight(); // finish with backlight on

//-------- Write characters on the display ------------------
// NOTE: Cursor Position: Lines and Characters start at 0
lcd.setCursor(3,0); //Start at character 4 on line 0
lcd.print("Hello, world!");
delay(100);

Serial.print("Ready ");

}

void loop()
{
}

Maybe the answer is in here.

I have an I2C 16x2 lcd that looks dead until it receives the lcd.backlight(); command.
It runs with the attached library. If you would rather download yourself you can do it here:
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

I don't know if this is relevant but you could look at this post about the pins:
http://forum.arduino.cc/index.php?topic=105823.0

LiquidCrystal_V1.2.1.zip (485 KB)

My suspicions at this point is that this isn't another issue. It is the same/most common issue.
My guess is that the library is using a PCF8574 to hd44780 pin wiring that is incorrect.
The sketch is more than likely incorrectly configuring the library for the wiring that the i2c backpack uses.

highflier:
All I can think of is the magic numbers for the LCD connections are wrong.
The numbers are not "magic". They tell the library how the PCF8574 output port pins
are wired up to the HD44780 interface and backlight.

Any ideas??
Also I was unsure if the Ardunio could power this off usb or not so I added a wall pwr supply that is rated 5 volt 1 amp, although to be honest I tested the 5v/ ground right at the LCD I2c board and saw 4.8 volts
It won't be a power issue.

1 more minor question. There is a shunt jumper on the i2c board labeled LED, any idea that is, I was guessing it was full backlight, and a POT could replace shunt for brightness control.
The jumper override s/w control of the backlight. Depending on the
circuitry it will either force the backlight on or force it off.
It can't be used for backlight brightness control.

That thread that MAS3 linked to is all over the map and I don't think that
it is very useful.
Stick with fm's library and get the constructor wiring pins correct.
You have a few choices. You can look at the board and determine how it is wired
(best solution), or you can just "guess" kind of what has been done so far.
You can make a few more guesses - there are other wiring configuations
noted on Terry's "LCD-Blue" site.

Or you could try running my guesser tool from this thread:
http://forum.arduino.cc//index.php?topic=157817.msg1235230#msg1235230

In the bigger picture, guessing how to wire things up is not a good strategy,
as incorrect guesses can cause damage to circuits.
That is why the best solution is to look at the board and see where the PCF8574 P0-P7 pins
are connected. That will give the exact answer without having to guess.
It only takes a minute or so.
If there pins that have traces that go under the chip, you can use a ohm meter.

--- bill

raschemmel:
I have an I2C 16x2 lcd that looks dead until it receives the lcd.backlight(); command.

As long as you fill in the full constructor, which includes backlight information, that should not be the case.
The last thing that begin() does is call backlight() to turn on the backlight for you.
So if the full constructor is filled in, the backlight will be on when begin() returns.
Perhaps you not filling in the backlight pin and polarity in the constructor
and using the obsoleted setBacklightPin() ??

--- bill

I just Googled the number T313S06 that is visible on the backpack and "Arduino", found that thread and a remark (on i think page 3) that the issue was resolved.

If (or rather when) you find the solution, please post it here so others can benefit from it too.

I think you're right. I think it turns on with the Begin command and not the backlight statement.
I'll check it when I get home. In any case , the backlight is s/w controlled , one way or another, so even
with power it is dark unless you run the right program. That is generally what I was trying to convey.

raschemmel:
I think you're right. I think it turns on with the Begin command and not the backlight statement.
I'll check it when I get home. In any case , the backlight is s/w controlled , one way or another, so even
with power it is dark unless you run the right program. That is generally what I was trying to convey.

Actually, this brings up an interesting point.
The jumper.
On some boards, the jumper forces the backlight on, and on some it forces the backlight off
and on some it enables/disables s/w control.
So the worst case scenario is to have a backpack that forces the backlight off with the jumper installed
used on inverse LCD (dark background with light pixels). With that combination, you can be using
the correct pins and backlight polarity in the constructor, yet you will never see anything because
the backlight is being forced off by the jumper.

So if the constructor is correct, and the backlight is not working, it may require removing
the jumper.

My recommendation, is that once it is working. Do an experiment to determine
what the jumper on the backpack does and make a note of it and then leave it
in or remove it as needed/desired.

--- bill

I'll do the same thing with mine tonight.

I am also having a problem with my 20x4 LCD with serial backpack. All I can get it to do is flash the backlight for about half a second but nothing shows up on the screen. This is the code that is supposed to work with this lcd

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



#define BACKLIGHT_PIN     13

LiquidCrystal_I2C lcd(0x27);  // Set the LCD I2C address

//LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE);  // Set the LCD I2C address


// Creat a set of new characters
const uint8_t charBitmap[][8] = {
   { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
   { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
   { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
   { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
   { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
   { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
   { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
   { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
   
};

void setup()
{
  lcd.backlight(); 
  int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

  // Switch on the backlight
  
  
  lcd.begin(20,4);               // initialize the lcd 

   for ( int i = 0; i < charBitmapSize; i++ )
   {
      lcd.createChar ( i, (uint8_t *)charBitmap[i] );
   }

  lcd.home ();                   // go home
  lcd.print("Hello, ARDUINO ");  
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print (" FORUM - fm   ");
  delay ( 1000 );
}

void loop()
{
   lcd.home ();
   // Do a little animation by writing to the same location
   for ( int i = 0; i < 2; i++ )
   {
      for ( int j = 0; j < 16; j++ )
      {
         lcd.print (char(random(7)));
      }
      lcd.setCursor ( 0, 1 );
   }
   delay (2000);
}

I removed the shunt jumper for the backlight and the backlight went off and the voltage at pin-15 of the
lcd went from +5Vdc to 0V. I don't know how that works because I looked in the library file and couldn't
find any reference to any specific pin numbers so I don't know how the backpack controls the backlight.
I put the jumper back on.

This is the code I was running that displays "hello world".
My advice to rnguyenvn1995 is that if you can't even display any text on your lcd that your
first priority should be doing just that and you should just change the lcd.begin statement in MY
code to lcd.begin(20,4); and try running that instead of using some program that does animation.
Get it to display "Hello World" first and then worry about animation...

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

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 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()
{
}

raschemmel:
. . .
This is the code I was running that displays "hello world".
My advice to rnguyenvn1995 is that if you can't even display any text on your lcd that your
first priority should be doing just that and you should just change the lcd.begin statement in MY
code to lcd.begin(20,4); and try running that instead of using some program that does animation.
Get it to display "Hello World" first and then worry about animation...

 //DFRobot.com

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

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 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()
{
}

That's a good idea, but how do you change something (lcd.begin) that isn't there in the first place?

Don

Guys,
Lets stick to the original thread and to solving highflier's issue.
highflier was using fm's library (which is what I recommend using).
Everything up to rnguyenvn1995's post and then raschemmel's followup response to
nguyenvn1995 post was about getting highflier's board up and running using fm's library.
Lets not muddy up the waters by looking at a different board
or at alternate libraries.
It is derailing the original thread.


When it comes to using i2c on PCF8574 i/o exanders talking to hd44780 based displays,
the only library that I use and that I recommend is fm's.
The reason is that there are too many other libraries out there.
Most work, but none of the other libraries allow the sketch to
configure the library to match the wiring of the backpack.
This is very problematic since different backpacks use different wiring
and so there is no way to make a library that "just works" with every backpack.
The other libraries hard code the wiring rather than allowing the sketch
to configure the wiring. This means that they will either work or not work,
with a given backpack and if they don't don't work,
you have to go in and modify library code because they are hardcoded for a particular pin wiring.
Making things more complicated, most of them all have same name and or use
the same header file name
so unless you look at the actual library code you don't really know which one you have
or what wiring it is hardcoded to.
(i.e. you can't tell what wiring the library is using by looking at the sketch)
Even further, they tend to use a different initalization process in the sketch from the
LiquidCrystal library that comes with the Arduino IDE.

This is where fm's library outshines all the others.
Not only does it use the same intialization API functions & sequence in
the users sketch as the standard LiquidCrystal library API, but it also allows
configuring the PCF8574 pin wiring by simply filling in the pin information
into the users lcd object constructor.
With fm's library all you have to do is configure the library by
filling in the constructor.
After that, everything in the sketch will work just like the standard
LiquidCrystal library.

In my view, it simply is not worth using anything but fm's library.
Anything else and you are rolling the dice as to it working or not,
and in order to fix those other libraries when they don't work,
you have to even more knowledge than how the PCF8574 pins are wired up to the HD44780 interface
as you will also have to re-work the code to hard code it to your particular wiring.
It would be much easier to just fill in the pin wiring information
into the LiquidCrystal_I2C constructor for fm's library.

The other benefit to using fm's library is that you may have more than one i2c backpack
and they may not have the same wiring. With fm's library, you simply adjust the constructor,
(which can be done on a sketch by sketch basis)
with the other libraries, you will have to go in and modify the library code and then it only works
for the one backpack, until you go in and modify it again.

And this is why I won't any other library other than fm's.

--- bill

raschemmel:
I removed the shunt jumper for the backlight and the backlight went off and the voltage at pin-15 of the
lcd went from +5Vdc to 0V. I don't know how that works because I looked in the library file and couldn't
find any reference to any specific pin numbers so I don't know how the backpack controls the backlight.
I put the jumper back on.

Was it really 0v or just not +5v? i.e. "open".
Look closer at your backpack to see how it is wired.
All will be revealed if you look and see how it is wired up.
Almost all the boards have a transistor for backlight control
that is controlled by a PCF8574 output port pin.
The transistor can be a NPN or PNP (that is why the polarity option is in fm's library).

I've seen jumpers wired up different ways.
Depending on how it is wired, it can do different things:

  • force backlight on
  • force backlight off
  • enable s/w control (which can be positive or negative polarity)

Look closely at your board, it is only a 2 layer board and all the traces are visible
so usually you can see all the wiring of the board including how the backlight and jumper
are wired up.

For anybody using fm's library, I encourage you determine what you jumper does (if you have one)
The best method is to look at the board and see how it is wired in.
Other than that you will need to experiment to determine what it does.
i.e. make sure that
backlight() turns on the backlight and noBacklight() turns it off.
If not, you should change the jumper.
It sould be fairly obvious after some quick testing.

--- bill

OK, I am making headway.

The real issue is the backlight, and the contrast pot, By using a flashlight and shining it on the LCD front, while turning the POT I was able to see my text.
So I got he pot set good, so that when Flashlight is used the border around the chars is consitant.

By using the flashlight I can also see the backlight command turn the border around the chars from clearish to blueish.

However that is the good news the bad news is that even when I turn out the lights in the room and do not use the flashlight it looks dead, I can not see any chars or any flashing of the backlight.
Like wise in a lit room, I was just mentioned above to give a perpective of how minumil the back-light is.

The shut removed disables the backlight, The begin() command does set backlight on. (if you change to NEGETIVE) on the constructor it will rerverse the back-light bit and of course start you with it off.

The shut reads 4.8 volts when Backlight is off and 4.4 volts when backlight is on.

I was not expecting anything great but I expect to read the display indoors without a flash light

Any ideas what is wrong or what I should try?

Highflier

highflier:
The shut removed disables the backlight, The begin() command does set backlight on. (if you change to NEGETIVE) on the constructor it will rerverse the back-light bit and of course start you with it off.

I'm not understanding this. Is the backlight working or not?
earlier I thought you said the backlight was not working, now it sounds like it is.

The shut reads 4.8 volts when Backlight is off and 4.4 volts when backlight is on.
shut? what is "shut"?

I was not expecting anything great but I expect to read the display indoors without a flash light

Any ideas what is wrong or what I should try?

Highflier

In going back and looking at the photo of the product on the ebay listing,
it looks like there is no transistor on the board.
Is there anything on the bottom of the board (the side facing the LCD)?

There is also a set of pads on the board by the jumper that I can't make
out what it is. If they are just pads or if there is a resistor there.

While you can often get away using a PCF8574 pin to directly drive
a backlight on a 16x2 display, the backlight on a 4x20 uses too much current.
If the board has a pcf8574 pin wired up to the jumper which is then
connected to the Anode (pin 15 of the LCD) then that definitely won't work and
could damage the PCF8574.

I would highly encourage you to stop using the board until you do some
investigative work.

You will need to figure out the wiring of the board.

Most importantly you will need to figure how the backlight is wired
and where the jumper goes.

Questions:
1)Can you post a clear up close macro shot of your board so we can
see the traces, particuarly around the jumper?
It needs to be very clear (in focus) with plenty of light so we can see all the traces.

  1. are there any components on the bottom of the backpack PCB?
    (The side that faces the LCD PCB)

3)Does the top wire of the jumper header go to pin 15 on the LCD?
4) Is there anything soldered in square between the 2 solder pads to the right of the jumper header?

  1. where does the lower wire of the jumper header go?
    does it connect to the lower pad in the square?

Depending on those answers, we can look further.

Don't dispair. Worst case, even if the board is a bad design and can't support s/w backlight
control, the board can be re-wired to have the backlight on all the time.

--- bill

Bill,
Thanks for your help..

see inline responses

n going back and looking at the photo of the product on the ebay listing,
it looks like there is no transistor on the board.
Is there anything on the bottom of the board (the side facing the LCD)?

There is also a set of pads on the board by the jumper that I can't make
out what it is. If they are just pads or if there is a resistor there.

While you can often get away using a PCF8574 pin to directly drive
a backlight on a 16x2 display, the backlight on a 4x20 uses too much current.
If the board has a pcf8574 pin wired up to the jumper which is then
connected to the Anode (pin 15 of the LCD) then that definitely won't work and
could damage the PCF8574.

I would highly encourage you to stop using the board until you do some
investigative work.

You will need to figure out the wiring of the board.

Most importantly you will need to figure how the backlight is wired
and where the jumper goes.

Questions:
1)Can you post a clear up close macro shot of your board so we can
see the traces, particuarly around the jumper?
It needs to be very clear (in focus) with plenty of light so we can see all the traces.
Maybe I can do better in daylight but for now this is the best I could manage. (attached)

  1. are there any components on the bottom of the backpack PCB?
    (The side that faces the LCD PCB)
    Really hard to see that side of the PCB, But I would say no unless it is a very thin surface mount part.

3)Does the top wire of the jumper header go to pin 15 on the LCD?
it goes to the pin labeled 'A', which is 15.

  1. Is there anything soldered in square between the 2 solder pads to the right of the jumper header?
    Not on top, maybe on the underside that I can not see.

  2. where does the lower wire of the jumper header go?
    does it connect to the lower pad in the square?
    Not sure I got you on this.. but here is what I think you want to know.
    It appears 1 side of jumper goes to Pin15 on the LCD
    The other side of jumper goes to VCC (top right pin) of the I2C chip

Depending on those answers, we can look further.

Don't dispair. Worst case, even if the board is a bad design and can't support s/w backlight
control, the board can be re-wired to have the backlight on all the time.
Yea, well it was not that costly, and if it is a bad board maybe I will get a credit or a new one.

Now lets see if can figure out how to attach images.. sorry if first post does not get them as I am new to this forum.

--- bill

Sorry missed a few things.

Shut= shunt typo sorry.

Black-light, It does not appear to be working.. unless you shine a flash light on the LCD then you can tell a difference in the reflection when I in code tell back-light on and off. But again not visible even with lights out without use of a flashlight

Voltmeter shows N/C between the 2 pads to the side of the shunt. One pf the pads seems to be connected to the chip side of I2C the shunt.

Highflier

My LCD works extremely well when I unsoldered the backpack and just hooked it up with LiquidCrystal library. They are good screens just I cannot seem to get mine to work with the I2C backpack.

Details, even the very smallest ones are very important at this point since
there is no "getting close" or "probably" at this point.
Missing or incorrect information creates confusion.

rnguyenvn1995, was your board 100% EXACTLY the same as highflighers?
And when I say 100% I mean 100%.
If so, and you still have it, are there any components on the back of the PCB?
Can you post clear macro photos of it? (both sides of the board)

highfligher,
you are going to have to figure out where the jumper and pad connections really go.
note: I still recommend that you don't power up the backpack as it is not
needed go gather this information.

The exact wiring must be figured out so we must be 100% sure
of the wiring of the jumper and the pads.

You said that the top of the jumper goes to pin 15 or the Anode of the LCD.
That is good. So we know where that goes, but does it go anywhere else?

But then on the bottom wire of the jumper you said:

The other side of jumper goes to VCC (top right pin) of the I2C chip

What exactly do you mean by "top right pin"?
In the photo you attached above, the top right pin of the IC as it is oriented in the photo
is not VCC, it is ground. (The ic locator is at the bottom in the photo)
It is VERY important to get these details exactly correct.
Use a PCF8574 datasheet to look at the pinout of the chip and reference the pin numbers
as well as the signal names.
Pin 1 is A0, Pin 8 is VSS (ground) and pin 9 is P4, and pin 16 is VDD (+5v)

Here are some additional questions:
(Again no need to power the device at this point)

  1. Did you run the i2cLCDguesser sketch that I recommended?
    Did the backlight ever turn on or blink during the test?

  2. What constructor were you using when you could see the expected text
    using the flashlight?

  3. Is there anything on the bottom of the PCB?
    Take another look at the bottom side of the PCB of this backpack, get a flashlight
    and verify if there is a part under there or not. If there is, it will be small surface
    mount transistor. You should be able to see if anything is there if you angle the board so
    you can look straight along the edge of the PCB.
    (I'm guessing that there is a transistor on the bottom unless some of the other information is incorrect)

3)Are you using a ohm meter to test the connectivity? Or just eye balling it?
Remember that in order to figure these out using an ohm meter
you must remove the jumper.
My recommendation is to use an ohm meter/continuity meter to see
where the jumper wires and pads go.
It should shouldn't take more than a minute or so
to tell where the jumper wires and pads go using an ohm meter.

You will want to check the connections to see if they go to VCC, GND or P3
or between the jumper and the pad.
We need to know where the 4 connections go.

  • Top jumper wire (appears to go to LCD pin 15 - does it go anywhere else?)
  • Bottom jumper wire (unknown at this point)
  • top pad (unknown at this point)
  • bottom pad (unknown at this point)

Here is my guess at this point.
I'm assuming that the backpack is not a bad design in that there is a transistor
on the bottom. I'm also assuming that P3 is connected to the base of that transistor,
If that is the case, then there will be transistor and a resistor soldered to the bottom
of the board.
Now it is possible that the jumper pad is for that resistor, which means that
without that resistor the backlight won't work.

All that said, we still need to know where the jumper wires and pads go.
So you will need to verify where they go before we can know how proceed.

--- bill