PCF8574A not working with I2C Library

Hello, community,

I have had success using the PCF8574 chip using the I2C Library to display characters on both the 16x2 and 20x4 LCD's.

I'm having difficulties getting the PCF8574A up and running with the same library.

The library I'm using is this one: https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

Any advice, please?

Where is your code?

Did you set the correct address?

Hello, used the I2C Scanner, changed the address but no luck - not sure if the A-revision of the chip is any different from its predecessor.

Anything specific I should look for in the datasheet?

jzl:
Anything specific I should look for in the datasheet?

It's NOT a predecessor. Look like you didn't even read the introduction... :wink:

The PCF8574 and PCF8574A are identical, except for the different fixed portion of the slave address.

So if you did change the address to some magic other address (and that's really the address of the A version) it should just work. Unless the library does not support the address (but that would be veeeeeerrryyy weird of the library to limit the addresses and it seems to just use any address you pass) or you didn't connect it right.

Thank you for the reply.

With all the above mentioned checked, I might have a faulty chip.

It is very unlikely that your chip is faulty.

  1. check the soldering of the backpack on the LCD module.

  2. check the wiring to your Arduino e.g. good Dupont cables

  3. install hd44780 library via the IDE Library Manager

  4. run the diagnostic sketch

David.

I agree with david_prentice.

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

Install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.

In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results.

Is the display the only thing on the I2C bus?

septillion:
So if you did change the address to some magic other address (and that's really the address of the A version) it should just work.

This is far from being correct.
Even when the i2c address is correct, there is no guarantee that "it should just work" since the library must also know how the PCF8574 i/o expander chip is wired up to the LCD module and not all backpacks use the same wiring/pin mapping.
That is why newLiquidCrystal LiquidCyrstal_I2C i/o class has pin mapping information in the constructor.
The pin mapping information in the constructor is how the user tells the library how the i/o expander chip is wired up to the LCD module.
Get that incorrect and it will not work. While it is not difficult to come up with the correct pin mapping information, many people struggle with it as they lack the technical skills to do it.

This is main reason I created the hd44780 library with the hd44780_I2Cexp i/o class.
When using the hd44780_I2Cexp i/o class, it should "just work" as the library will auto locate the i2c address and then auto detect the pin wiring used between the PCF8574 and the LCD module.

The library also includes a diagnostic sketch, I2CexpDiag, which should be run first to verify that all the s/w and h/w are properly functioning.

--- bill

bperrybap:
This is far from being correct.
Even when the i2c address is correct, there is no guarantee that "it should just work" since the library must also know how the PCF8574 i/o expander chip is wired up to the LCD module and not all backpacks use the same wiring/pin mapping.

True, I did assume the same wiring. (S)He didn't write about backpacks so at most I expected a "straight" module aka (s)he has control over the connections.

If you can't guarantee the connections are the same of curse all beds or off.

But granted, I like your library :slight_smile: Besides the great functions it luckily doesn't use the fricking LiquidCrystal name because that library is just cloned TO MUCH under the same name... :smiley:

bperrybap:
Even when the i2c address is correct, there is no guarantee that "it should just work" since the library must also know how the PCF8574 i/o expander chip is wired up to the LCD module and not all backpacks use the same wiring/pin mapping.

Thank you very much for the replies.

How does one check the wiring/pin mapping?

jzl:
How does one check the wiring/pin mapping?

By examining at the traces on the backpack PCB to see which Px pin on the PCF8574 connects to which LCD module pin and then looking at the Px pin that connects to a transistor to see if that transistor is active high or active low typically from using either an NPN or PNP transistor.

--- bill

septillion:
Besides the great functions it luckily doesn't use the fricking LiquidCrystal name because that library is just cloned TO MUCH under the same name... :smiley:

There was no luck involved....
--- bill

Hehe, I'm glad for that (which is the word I should have used :wink: )

jzl:
Diagram of how the PCF8574P is connected:

That diagram shows the LED plus and minus pins interchanged (NPN transistor to ground is "LED +").

hmmm.
Seems like a post is missing/has been removed.
--- bill

I have removed my previous post, due to me being a noob and not counting the pins according to the datasheet.

I have in the meantime managed to get the LCD working.

I have read this post: Serial LCD I2C Module–PCF8574 | alselectro

The post explains in detail what each pin does and where it's connected to etc.

I used my multimeter in continuity mode to trace the pins from the chip to where they are connected to the LCD, as per bperrybap.

I have found one exception with using the PCF8574A:

I have to specify the backlight pin.

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

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7);  // Set the LCD I2C address
#define BACKLIGHT_PIN 3


void setup()
{  
  Serial.begin(9600);
  emon1.voltage(A0, VOLT_CAL, 1.7);
  emon1.current(A1, 6.5);
  lcd.begin(16,2);  
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  pinMode(8, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(2), IntTrig, CHANGE);

}

I have also noticed that my text on the LCD seemed to be chopped off - it turns out it was a dry joint on the pin to the LCD.

Thanks to all for the advice. SOLVED.

A couple of things.

If you are going to use that library, I would recommend using the full constructor. i.e.

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

While you may have seen setBackLight(pin, level) in examples you found out on the internet, it is an obsolete method and has been for many years.
The preferred way to configure backlight control with that library is by using the full constructor.
When done that way, the backlight will be on when begin() returns.

setbacklight(dimlevel) doe not take a HIGH or LOW as an argument.
It takes a dimlevel value 0-255 to set brightness. Using HIGH (dimvalue of 1) happens to work with the LiquidCrystal_I2C i/o class as i2c backpack h/w does not support dimming so any dimvalue over 0 will turn the backlight on with full intensity.
If you did that with some other i/o class and h/w you could end up with a very dim backlight.

I'm still curious why you decided not to use the hd44780 library.

--- b ill

bperrybap:
I'm still curious why you decided not to use the hd44780 library.

--- b ill

Two reasons:

  1. I've used the previous library before.
  2. The examples on the recommended library seemed too much to navigate through (menus within menus) and I'm too lazy to read haha

I will use it for my next project.

Thanks for all the advice.

jzl:
2. The examples on the recommended library seemed too much to navigate through (menus within menus) and I'm too lazy to read haha

Likely, you spent more time reading that web page and probing the backpack than the few minutes it would have taken to read about the hd44780 library and the hd44780_I2Cexp i/o class which auto detects everything for you.... :wink:

--- bill