interfacing Arduino with LCD using PCF8574T [SOLVED]

This post would be a follow-up of this. Now after connecting all nothing seems to be happening.

The LCD just shows black blocks. What am i missing here or is it in the code ?

Check the contrast maybe? It was one of the porblems I have just had fixed with my lcd screen. Btw there is also a display section in the forum where is more probable that someone that knows better displays helps you

What am i missing here or is it in the code ?

What i2c lcd library and code are you using?

#include <PinChangeInterrupt.h>
#include <Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // Library
#include <EEPROM.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
Servo myServo;

This is part of my on going project which i had started here Now after having the components placed as per the chematic nothing seems to be happening except black solid blocks on the first line.

How do you know that 0x27 is right I2C address??

See THIS PAGE and go to the bottom to find the I2C scanner.

This is how I read the connections from your pcf8574 to the lcd

LCD
RS P4
RW P5
EN P6
D4 P0
D5 P1
D6 P2
D7 P3
BL P7
BLlevel LO

#include <LiquidCrystal_I2C.h> // Library
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

The constructor you are using appears to be from the F.Malpartida newLiquidCrystal library LiquidCrystal_I2C class with

LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw,
                                     uint8_t Rs, uint8_t d4, uint8_t d5,
                                     uint8_t d6, uint8_t d7, uint8_t backlighPin, 
                                     t_backlighPol pol = POSITIVE )
{
   config(lcd_Addr, En, Rw, Rs, d4, d5, d6, d7);
   setBacklightPin(backlighPin, pol);
}

If so, then the constructor would be

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

I’m not totally sure about the PNP transistor and the backlight with the NEGATIVE, so you can try the POSITIVE which seems to be working with the incorrect constructor.

so is it the constructor that needs to be changed and nothing on the components ? but with what respect ?

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

@anishkgt, do not cross-post. Threads merged.

anishkgt:
so is it the constructor that needs to be changed and nothing on the components ? but with what respect ?

cattledog fully explained it in post #6.
(Although the backlight polarity should be POSITIVE for that backlight circuit)
When using that library, the constructor tells the library how the PCF8574 pins are wired to the LCD.
They must match each other, yours do not so you have told the library that the PCF8574 is wired up to the LCD differently than it actually is.
You can either change the h/w to match what you put in constructor or you can change the constructor to match the way you built the h/w.

You probably should go back and re-read post #6.

Seems like alot of work to go through when you can get a pre-built i2c backpack delivered to your door for less than $1 USD and the hd44780 library can auto locate the i2c address and auto configure the pin mappings.
But hey, to each his own....

--- bill

bperrybap:
Seems like alot of work to go through when you can get a pre-built i2c backpack delivered to your door for less than $1 USD and the hd44780 library can auto locate the i2c address and auto configure the pin mappings.
But hey, to each his own…

What $1 !

Those boards cost £1 delivered in the UK.

Thank you all, i guess my MUC is not working as it should be. The bootloader is burned but uploading a sketch i get this error

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Users\georget\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\1.0.4/avrdude.conf"

Using Port : COM6
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega328
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 6.6
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e951f (probably m328)
avrdude: reading input file "C:\Users\georget\AppData\Local\Temp\arduino_build_610588/SPWv3_MCU.ino.hex"
avrdude: writing flash (16680 bytes):

Writing | avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

I guess i have bad MUC, will have to do a new board and start things from there.

ok i got the MUC to work again, seemed to have some bad joints and during my Chinese hot gun blower just failed. Need search for a better branded one this time.

So i was reading post 6 and after a while i've managed to make sense out of it. I only had to change the address to 0x3A and as per the schematic the constructor seems to be correct but the display is just showing a set of black solid blocks.

To check if it was the PCB i just hooked the I2C lines to an LCD with a pre installed interface and that seems to show the characters. So i am guessing it would the schematic but which one ? all i can see now is no backlight and black blocks instead of characters.

I only had to change the address to 0x3A and as per the schematic the constructor seems to be correct but the display is just showing a set of black solid blocks.

Did you run the i2c scanner program to confirm the 0x3A?

If so,I think you’re saying that this constructor derived from the schematic did not produce text.

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

Here’s my recommendation.

Modify the sketch to use the hd44780 library available through the library manager. Even though you have an unusual constructor, I think that library will auto configure for the display. It would also be wise to run the diagnostic sketch in the library examples-- I2CexpDiag.ino.

If you load this library, the setup of the correct class for your sketch will include

#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip

anishkgt:
To check if it was the PCB i just hooked the I2C lines to an LCD with a pre installed interface and that seems to show the characters. So i am guessing it would the schematic but which one ? all i can see now is no backlight and black blocks instead of characters.

It is YOUR board and a design that you have made. At least that is the impression you have given me when you said this in the other thread:

anishkgt:
... i have an interface board so incorporating the backpack into my UI makes it easier to mount the lcd in a housing.

So you should know how you wired it up since it is your design.
I gave lots of technical information and several suggestions how to resolve your issues in the other thread.
This appears to be going nowhere.
I'm out.

--- bill

cattledog:
Did you run the i2c scanner program to confirm the 0x3A?

If so,I think you’re saying that this constructor derived from the schematic did not produce text.

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

Here’s my recommendation.

Modify the sketch to use the hd44780 library available through the library manager. Even though you have an unusual constructor, I think that library will auto configure for the display. It would also be wise to run the diagnostic sketch in the library examples-- I2CexpDiag.ino.

If you load this library, the setup of the correct class for your sketch will include

#include <Wire.h>

#include <hd44780.h>                      // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip

For the 16x2 display with the extension board test passed successfully and the address is 0x3A, as in the schematic the A0 A1 A2 Pins are grounded so did the same on the one with the extension board to see what the address.

Next i test my pcb but all it showed was


Serial Initialized

I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool

hd44780 lib version: 0.9.1

Reported Arduino Revision: 1.8.5
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…
Total I2C devices found: 0
No I2C devices found

With the three address pins grounded, the address should be 0x20 or 0x38.

Your problem at this point is why the pcf 8574 is not being seen on the i2c bus. You are going to need to trouble shoot all the connections from the sda/scl pins on the processor to the sda/scl pins on the 8574.

To check if it was the PCB i just hooked the I2C lines to an LCD with a pre installed interface

Where did you pick up the i2c lines?

Terry King in an earlier post has linked to a more simple i2c bus scanner which you can use.

Until you see an address for the pcf 8574 on a i2c bus scanner you can go no further.

A2A1A0 PCF8574 PCF8574A
L L L 20 (hexadecimal) 38 (hexadecimal)
L L H 21 (hexadecimal) 39 (hexadecimal)
L H L 22 (hexadecimal) 3A (hexadecimal)
L H H 23 (hexadecimal) 3B (hexadecimal)
H L L 24 (hexadecimal) 3C (hexadecimal)
H L H 25 (hexadecimal) 3D (hexadecimal)
H H L 26 (hexadecimal) 3E (hexadecimal)
H H H 27 (hexadecimal) 3F (hexadecimal)

hank you Cattledog,Yes it was the i2c lines hat were swapped. Corrected it and the back light comes on and the diagnostic sketch also worked.

Characters displayed are not correct. What would that be ? I checked he p0-P7 pins and they seem to be correct in code and he schematic as well.