Go Down

Topic: 20x4 I2C LCD Display setup (Read 288 times) previous topic - next topic

perigalacticon

I bought a 20x4 I2C LCD Display and tried to make it work but it has not worked correctly.  Is there someone who has experience with these that can help me make it work?

I used the "NewLiquidcrystal" library with I2C address 0x3F upon advisement from the seller, and tried the examples from this webpage:  https://arduino-info.wikispaces.com/LCD-Blue-I2C.  It appears the board fits the description of "I2C LCD DISPLAY VERSION 3" so I tried this example.  The lcd.backlight() and lcd.noBacklight() commands work but no characters will display.  I have adjusted the contrast extensively while the sketch is running and there are no legible characters displayed.  I currently believe the problem is with the lcd declaration statement:

Code: [Select]
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

I have tried many variations of this statement per other forum posts including other pin numbers, declaration formats, and I2C addresses but I only have seen non-text characters.

If there is anyone that has been able to get one working could you please advise as to the correct setup?  I attached photos of the LCD.


bperrybap

I would recommend my hd44780 library package.
It includes a diagnostic sketch that can test the i2c signals and h/w for any possible issues.

It is available in the IDE library manager so it can quickly and easily be installed from the IDE gui using the library manager.
With other i2c LCD libraries you must specify the address. Most libraries are also hard coded to work with backpacks that use a specific pin mapping between the PCF8574 chip and the hd44780 LCD display and if your backpack doesn't use that pin mapping, it won't work.
A few libraries, like fm's NewLiquidCrystal library allow the sketch to configure the PCF8574 pin mappings and backlight control.
If the pin mappings are not specified correctly, it will not work.
The hd44780 library can auto detect everything, the i2c address, the pin mappings, and the backlight control.
You can read more about it here: https://github.com/duinoWitchery/hd44780

The hd44780 github page contains information about the library including installation instructions.
Use the IDE library manager to install it as it is easier and faster than trying to do it manually or using the zip install.
Also, by using the IDE library manager it ensures that the library is installed properly not to mention that you will also get the latest tested version of the library.

The library package includes support for several different h/w i/o interfaces used to communicate with the LCD module.

Each i/o interface has its own i/o class and its own set of examples.
The examples for each i/o class are grouped together in a directory by the name of the i/o class.
While all the examples are always available regardless of which h/w you actually have, using an example for an i/o class that is for different h/w will not work.
It will compile but obviously will not work.
The i/o class you will want to use for that backpack which contains an i2c i/o expander chip is hd44780_I2Cexp
That i/o class includes a diagnostic sketch (I2CexpDiag) which will test the i2c signals and internal RAM of the LCD module to verify that the the library is properly communicating with the LCD module.
It is useful to first run this sketch to verify that the library is properly talking to your backpack and LCD module.
Read the instructions in the sketch for how to run it and what to expect on the serial monitor.

After running the diagnostic sketch, you can run and look at other sketches for the hd44780_I2Cexp i/o class like the HelloWorld sketch to see what header files need to be included and how to declare the lcd object.


The hd44780 library contains additional capabilities not available in other libraries like
- return status to tell if API functions are not working correctly (usually do to i2c communication issues)
- ability to enable automatic line wrapping
- ability to read the display RAM or LCD status
- faster than other libraries as Arduino can run in parallel with LCD commands/instructions

I would recommend first running the diagnostic skech I2CexpDiag to verify that everything is working, then you can run and look at the other examples included in the hd44780_I2Cexp i/o class (like HelloWorld) to see the what header files need to be included and how to declare the lcd object.

--- bill

perigalacticon

Ok Thanks.  This is what I got when I ran I2CexpDiag:

Code: [Select]

********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 0.9.0
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.3
CPU ARCH: AVR - F_CPU: 16000000
--------------------------------------------------------------------
 A4: digital pin: 18
 A5: digital pin: 19
SDA: digital pin: 18
SCL: digital pin: 19
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
--------------------------------------------------------------------
Scanning i2c bus for devices..
 i2c device found at address 0x3F
Total I2C devices found: 1
--------------------------------------------------------------------
Scanning i2c bus for all lcd displays
No working LCD devices

perigalacticon

The IC has the following information:

pcf8574at
A11727
1

bperrybap

The IC has the following information:
The specific part type doesn't matter.
I would like to know the hd44780 library error/status/blink code from HelloWorld which will provide a bit more information about what is failing.

--- bill

bperrybap

#5
Aug 12, 2017, 06:19 pm Last Edit: Aug 12, 2017, 06:19 pm by bperrybap
That failure is very very unusual. There appears to be some sort of h/w issue going on.
Can you run the hd44780_I2Cexp HelloWorld and tell me the error code?
It should blink out an error code number between 1 and 6

--- bill

perigalacticon

When I run the hd44780_I2Cexp HelloWorld sketch the LCD backlight turns on and nothing is displayed.  Nothing is printed on the serial monitor.  The red led on the PCF8574AT board turns on and stays constant on there is no blinking.

bperrybap


--- bill
When I run the hd44780_I2Cexp HelloWorld sketch the LCD backlight turns on and nothing is displayed.  Nothing is printed on the serial monitor.  The red led on the PCF8574AT board turns on and stays constant on there is no blinking.
I assume you mean that the red led on the backpack is always on vs turning on when HelloWorld runs.

HelloWorld doesn't print anything on the Serial port.

What the Arduino LED? I'm wanting to get the error/status/LED code from the Arduino.

--- bill

perigalacticon

#8
Aug 12, 2017, 08:18 pm Last Edit: Aug 12, 2017, 08:33 pm by perigalacticon
The red led on the backpack turns on when the LCD is connected to power and stays on constant until unpowered.  After uploading the hd44780_I2Cexp HelloWorld sketch the led on pin 13 of the Uno blinks approx once every 1-2 seconds until unpowered.

bperrybap

The red led on the backpack board turns on when the LCD is connected to power and stays on constant until unpowered.  After uploading the hd44780_I2Cexp HelloWorld sketch the led on pin 13 of the Uno blinks approx once every 1-2 seconds until unpowered.
"approx once" ?? Do you really mean exactly once?

The code blinks a status code a fixed number of times with .1 second on and .2 second off followed by a 1.5 second delay and then repeats.

based on the status code of 1, the PCF8574 chip is either not responding properly and the library code couldn't identify it as a PCF8574 chip, or there are i2c errors happening.

About the only thing I can think of at this point is checking for solder issues.
Look carefully at all the solder connections on the PCF8574 chip and on the header for the LCD module.

Also, verify that the backpack is connected properly. i.e. pin 1 of the backpack is going to pin 1 of the LCD.

--- bill



bperrybap

The first photos were ok, but not clear enough to see the fine details.
can you post a couple more clear closeups of the backpack and also the soldering of the to the LCD so I can take a look at it?

--- bill

perigalacticon

#11
Aug 13, 2017, 01:25 am Last Edit: Aug 13, 2017, 01:34 am by perigalacticon
I tried an I2C OLED display with the same wires and it works.  It appears assembled correctly, I went over the pins with my solder iron, the photos aren't great but I don't see any solder bridges.  Also, when I run HelloWorld it blinks once repeatedly, when I run I2Cexpdiag it blinks twice repeatedly.


bperrybap

The 359 photo is awesome very clear and all the soldering to the LCD module 16 pin header is great.
The clarity of the 360 photo not so much.
How is the soldering of the PCF8574 chip itself? Look very careful at all the connections on the backpack.

Do you have any sort of datasheet for that specific LCD module?
It is a bit odd with the dual 16 pin connections.

Just grasping at straws:
Unlikely but , maybe the LCD module pinout is not standard?
I can't see any pin 1 designator for the LCD module pins that were soldered.
Is it possible that pin 1 on the LCD module is on the other end rather the end where the i2c header is?

--- bill

perigalacticon

I touched up the soldering on the backpack with my soldering iron and checked with a high power magnifying glass I think everything's ok there.  I am going to return the display to the seller.  That's 3 items I've bought for Arduino recently from ebay that have not worked!  Thanks for your help.

Go Up