Troubleshooting an i2c 16x2 LCD - no data seen

Hi All,

i am trying to troubleshoot my PCB which has 16x2 LCD on an i2c bus. Not very good at it.

Any help would be appreciated.

The code does work when I used a prebuilt one from eBay. I've replaced the I/O expander, the transistor and checked SDA and SCL for continuity, all looks good but still nothing seems to be working. The back light just blinks and goes OFF and the first row in the LCD just shows thick blocks leaving the second row blank.My I/O expander reads as PCF8547AT.

My Display initialization code is as follows:

#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
hd44780_I2Cexp lcd;

anishkgt:
i am trying to troubleshoot my PCB which has 16x2 LCD on an i2c bus. Not very good at it.

Right, so you built your own PCB. From where did you get that circuit or is it your own invention? Otherwise put, how did you know which connections to make between the PCF8574 and the LCD?

anishkgt:
The code does work when I used a prebuilt one from eBay.

So you have tested it with one.

anishkgt:
I've replaced the I/O expander, the transistor and checked SDA and SCL for continuity, all looks good but still nothing seems to be working. The back light just blinks and goes OFF and the first row in the LCD just shows thick blocks leaving the second row blank.My I/O expander reads as PCF8547AT.

What does "reads as PCF8547AT" mean?

anishkgt:
My Display initialization code is as follows:

#include <hd44780.h>

#include <hd44780ioClass/hd44780_I2Cexp.h>
hd44780_I2Cexp lcd;

OK, I gather you are - correctly - using bperrybap's hd44780_I2Cexp library - and that is how you identify the PCF8547. Well, if you are doing that, you will need to use one of the connection arrangements which it recognises, which are based on the known library of these interface boards. If you made up your own connection plan or copied it wrongly from another, it may not work.

He will likely come past and look at your schematic to verify this.

In the meantime, you may care to correct a blunder which has been inherited by less-than-competent designers of many of these boards. Do not connect the potentiometer which connects to Vo pin 3, to 5 V - either leave that end of the potentiometer unconnected or better, connect it back to the wiper. This is not your present problem at all (because all the boards in use with this error do work), but it will make contrast setting easier and save 500 µA of current. You should of course do this where possible, on all the devices you have.

initiall i started with the circuit from here. This was advised by TerryKing228 on his website. So followed it.

It worked on my previous revision of the board but for some reason it does not seem to be working now.

Does the I2C expander (PCF8574) show up in an I2C scanner?

The hd44780 library comes with a diagnostic sketch. It is in the examples for the hd44789I2Cexp ioclass examples. Load and run that sketch and post the results.

Here is the output


Serial Initialized

I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool

hd44780 lib version: 1.0.1

Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000

SDA digital pin: 18 A4
SCL digital pin: 19 A5

Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - STUCK LOW
Checking for I2C pins shorted together - Shorted


ERROR: SDA and SCL shorted together


I2C bus not usable

Not sure why the SCL lines reads low at boot up. When i reset manually via the reset button it reads HIGH on both pins.

Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000

SDA digital pin: 18 A4
SCL digital pin: 19 A5

Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
Checking for I2C pins shorted together - Not Shorted

Scanning i2c bus for devices..
i2c device found at address 0x20
Total I2C devices found: 1

Scanning i2c bus for all lcd displays

My schematic is as follows, the only difference from the previous is i've added pullup resistors to the SDA and SCL lines.
Capture.PNG

I noticed a couple of things.
The pin mapping you are now using is different than before
Your current mapping is:

RS P4
RW P5
EN P6
D4 P0
D5 P1
D6 P2
D7 P3
BL P7
BL active Level  HIGH

This is the pin mapping for the ElectroFun LCDxIO board with an added NPN transistor for backlight control.

No other backpack uses that pin mapping.
While it should work, I haven't tested it with a NPN transistor (active HIGH).
There may be an auto detect issue there.

The pin mapping you showed in the IB schematic in the other thread is:

RS P6
RW P5
EN P4
D4 P0
D5 P1
D6 P2
D7 P3
BL P7
BL  Active Level HIGH

This pin mapping is fairly common and is used in several backpacks like those labeled
mjkdz or GY-I2CLCD.


Note that these two pin mappings are not the same.
The RS and EN pin assignments are flipped.

In looking at post #4 there may be some kind of wiring/soldering issue.
When using an AVR based Arduino, the only way I can think of to get a reported short between SDA and SCL is a wiring issue or a soldering issue.

The schematic in the original post has pullups shown.
So I don't understand your comment in post #6

My schematic is as follows, the only difference from the previous is i've added pullup resistors to the SDA and SCL lines.

Am I missing something? I don't see any difference in the two schematics.

In post #5 the diag output was cut off.
The missing portion of the diagnostic contains useful information about the detected pin mapping.


Can you post some photos of your board?

Given pre-made backpacks are so inexpensive, unless this is part of a larger PCB for a project, why not use an off the shelf backpack?

--- bill

These are just prototypes. I may use the pre-made ones with another PCB that would hold the buttons. This design i just had the pull-up resistors added in the schematic which was not there in the previous.

First schematic:

Second schematic:
Capture.PNG

The illegibility of the second prevents me from figuring out what the extra four pins added to the interface socket do, if indeed anything, and The pull-ups are shown in both.

You have apparently ignored my correction regarding the contrast potentiometer.

What about the missing diagnostic output?
Can you post that?

here power the main PCB and then connect the LCD and it shows SDA and SCL are pulled up


Serial Initialized

I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool

hd44780 lib version: 1.0.1

Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000

SDA digital pin: 18 A4
SCL digital pin: 19 A5

Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
Checking for I2C pins shorted together - Not Shorted

Scanning i2c bus for devices..
i2c device found at address 0x20
i2c device found at address 0x24
Total I2C devices found: 2

Scanning i2c bus for all lcd displays
No working LCD devices

Now i leave the LCD connected and reset the board and i get SCL - Stuck LOW


Serial Initialized

I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool

hd44780 lib version: 1.0.1

Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000

SDA digital pin: 18 A4
SCL digital pin: 19 A5

Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - STUCK LOW
Checking for I2C pins shorted together - Shorted


ERROR: SDA and SCL shorted together


I2C bus not usable

Interface Board.pdf (20.6 KB)

Paul__B:
First schematic:

Second schematic:
Capture.PNG

The illegibility of the second prevents me from figuring out what the extra four pins added to the interface socket do, if indeed anything, and The pull-ups are shown in both.

You have apparently ignored my correction regarding the contrast potentiometer.

I've not ignored your correction on the contrast pot. I've not left any pin floating one connected to 5v and the other pin to GND. The sweep is connected to pin Vo

So it appears that you have two custom PCBs.

  • a main processor board
  • an i/o board with the PCF8574 and the LCD.
    A 10 pin cable between them.

A few more questions.
Where does the AVR and LCD get is power?
Is it always from mains? from USB? or can it from either mains or USB?

Are you using auto reset with a bootloader to program the AVR or are you using ISP programming?
The reason I ask is that auto reset can hold the reset down on the AVR for a bit of extra time at power up.
If that isn't there, then the AVR can start running before the 5V supply is stable and all the way up to 5v.
This could cause issues on the i2c lines.
Actually this is a normal occurrence but auto reset tends to hold off the AVR for a few extra milliseconds which can allow the 5v supply to rise up a bit more during this time period.
Also the AVR fuse settings can affect how long the AVR holds off at powerup before starting.

How long is the 10 pin cable between the two boards?

A potential issue is that the 5v power supply used by the AVR and the LCD may not be stable before the AVR is off and running.
This is quite common including on typical Arduino boards.
I do have an added delay to account for this potential in the library but the delay in the diag code is only 5ms before it starts probing the I2C signals which likely is not enough in certain environments.

Have you looked at the 5v supply voltage going to the AVR and LCD to see if there is a long rise time before it reaches 5v?
I've seen some power supplies take many 10s of milliseconds to stabilize up to full voltage.

As a test could you put a small tweak in the I2CexpDiag code?
Change line 289 in setup() from a delay(5) to delay(500)
That should be more than enough time to guarantee that the 5v supply voltage is all the way up.

--- bill

Where does the AVR and LCD get is power?

Always from the mains.

Are you using auto reset with a bootloader to program the AVR or are you using ISP programming?

Yes it uses arduino Bootloader and sketches are uploaded via the USB.

How long is the 10 pin cable between the two boards?

5 to 10cm

Have you looked at the 5v supply voltage going to the AVR and LCD to see if there is a long rise time before it reaches 5v?

Nope never had to, I could have look though.

As a test could you put a small tweak in the I2CexpDiag code?

Change it to 500

and the SCL pin still shows STUCK LOW


Serial Initialized

I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool

hd44780 lib version: 1.0.1

Reported Arduino Revision: 1.8.5
CPU ARCH: AVR - F_CPU: 16000000

SDA digital pin: 18 A4
SCL digital pin: 19 A5

Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - STUCK LOW
Checking for I2C pins shorted together - Shorted


ERROR: SDA and SCL shorted together


I2C bus not usable

It takes 10ms to reach 5v when powered by the mains.

anishkgt:
It takes 10ms to reach 5v when powered by the mains.

Ok. That might be an issue with the 5ms delay in setup() but shouldn't be an issue if you bumped it to 500ms.

The code currently reports "Shorted" if it reads a LOW on the SCL pin when the pullup is enabled.
So you can ignore the "Shorted" message.
This will be fixed in the next release of the library such that it will only test for shorts when there is not a pin stuck low.

The questions becomes why is the SCL pin (Arduino digital pin 19) reading as low when the Internal AVR pullup is enabled?
I also can't figure out why two i2c slaves show up at addresses 0x20 and 0x24 (from post 11)

What voltage do you see on the SCL / Arduino digital pin 19?

--- bill

SCL reads 0.020v with the LCD connected and 5.0v when disconnected. Could it be because the traces are not far enough from each other or could there be some interference.

These readings where taken with my sketch with internal pullups enabled and pullup resistors on the LCD as well.

anishkgt:
I've not ignored your correction on the contrast pot. I've not left any pin floating one connected to 5v and the other pin to GND. The sweep is connected to pin Vo

So you didn't actually read what I stated then? :astonished:

OK, I do realise you are having troubles getting your board to work and I admit this is not a big problem, certainly not anything to do with your present problem, so you looked at it and your mind was entirely elsewhere, nothing "sank in". :cold_sweat:

anishkgt:
SCL reads 0.020v with the LCD connected and 5.0v when disconnected. Could it be because the traces are not far enough from each other or could there be some interference.

These readings where taken with my sketch with internal pullups enabled and pullup resistors on the LCD as well.

That is a problem.
It kind of looks like something is shorted like maybe a bad trace or perhaps something is not connected properly to create a short.
Look closely at the traces that go between the PCF8574 SCL pin 14 through the resistor as it connects to VCC.

--- bill