How to use this PCF8574 board from "emall-4u"

This is labeled LCM1602-IIC.

The address and the sample code are, not surprisingly, wrong. The address of the one that I am using is 0x20, not 0x27, and you do have to set up the pins in order. My Arduino Serial board has its SCL on A0, and its SDA on A1.

I traced the connections using an ohmmeter, and here is the correct line of code. First I track all the relevant pins to the chip, then I use the chip's documentation to find out which of the P0 to P7 chips it is. It is not nearly as easy to trace the pin that controls the backlight, but there are eight possibilities, seven already traced, so it's the one that is left. I have it working and properly backlit:

LiquidCrystal_I2C lcd(lcdAddr, 2,1,0,4,5,6,7,3, POSITIVE); // addr, EN, RW, RS, D4, D5, D6, D7, Backlight, POLARITY for mall4 adapter

Just in case anyone might need the information.

This is the adapter: http://www.ebay.com/itm/390527380190?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

Which library?
Based on the constructor, I'm assuming it is fm's library but It would be useful to also say which library is used (a link to the library would be even better).
--- bill

The address of the one that I am using is 0x20, not 0x27, ...

It looks like you may be able to change the address from 0x20 to 0x27, or to any of the other six addresses in between, by dealing with the solder blobs above A0, A1 and A2.

Don

It is fm's library. https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/LiquidCrystal_V1.2.1.zip

Im also using the emall4u board. It's not working with the pins you posted. What screen are you using? Also im using a Nano-board. Wich seems to also cause problems for some people :slight_smile:

Since the backlight turns on i gather that the arduino and IIC are talking. Wich leaves 2 options. The pins are wrong or there is something wrong with the IIC-board.

Since i get two out of 4 lines filled with black blobs, im leaining against option number one...

Since i get two out of 4 lines filled with black blobs, im leaining against option number one...

Regardless of the interface used or anything else this symptom signifies that the LCD is getting power, the contrast is OK (but maybe not optimum) and the LCD controller is not initialized correctly.

Don

floresta:

Since i get two out of 4 lines filled with black blobs, im leaining against option number one...

Regardless of the interface used or anything else this symptom signifies that the LCD is getting power, the contrast is OK (but maybe not optimum) and the LCD controller is not initialized correctly.

Don

Ok. Not initializing, that could also be wrong pins or pin order in the init command right?

Ok. Not initializing, that could also be wrong pins or pin order in the init command right?

Yes, those are some of the possible reasons.

Of course if you posted a photograph of your connections and a copy of your code we could help you guess.

Don

floresta:

Ok. Not initializing, that could also be wrong pins or pin order in the init command right?

Yes, those are some of the possible reasons.

Of course if you posted a photograph of your connections and a copy of your code we could help you guess.

Don

For now im using an example code..

/* YourDuino.com Example Software Sketch
 20 character 4 line I2C Display
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/ 

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574A
#define BACKLIGHT_PIN  7
#define En_pin  4
#define Rw_pin  5
#define Rs_pin  6
#define D4_pin  0
#define D5_pin  1
#define D6_pin  2
#define D7_pin  3

#define  LED_OFF  0
#define  LED_ON  1

/*-----( Declare objects )-----*/  

LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup() 
{

  lcd.begin (20,4);  // initialize the lcd 
  lcd.setBacklightPin(BACKLIGHT_PIN,NEGATIVE);
  lcd.setBacklight(LED_ON);

}

void loop() 

{

// Reset the display  
  lcd.clear();
  delay(1000);
  lcd.home();
  
// Print our characters on the LCD
  lcd.backlight();  //Backlight ON if under program control
  lcd.setCursor(3,0); //Start at character 3 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(2,1);
  lcd.print("From YourDuino");
  delay(1000);  
  lcd.setCursor(0,2);
  lcd.print("20 by 4 Line Display");
  lcd.setCursor(0,3);
  delay(2000);   
  lcd.print("http://YourDuino.com");
  delay(8000);
} // END Loop

This code turns the baklight on and of and displays (as stated before) only blobs on line 1 and 3. I have attached images of my setup.

The display i use comes with this information:

2004A LCD Screen J204A Character Display LCD Module 20x4 5v LCD / LCM (Blue)
Description:

Type: LCM2004A
Packaging: COB
Physical size: 98 mm x sixty mm
Connection mode: conductive rubber strip
Horizon size: 76 mm x 26 mm
Interface mode: single parallel
Dot size: 0.55 mm x 0.55 mm
Backlight type: EL/LED
Character size: 29.5 mm x 47.5 mm
Display content: twenty character x 4 line
Working voltage: + 5 V / + 3.3 V
Working temperature: -10°c~ +60°c
Controller: SPLC780

The chip on the "emall-4u I2C" says PCF8574T.

Not sure what else to give you..

Edit: Well, if i try to post images the page doesn't even want to try if i hit post. So i will explain my setup.

Arduino nano V3.0 (china-board)

SDA --> Analog 4
SCL --> Analog 5

Both with pullup to 5v

The chip on the "emall-4u I2C" says PCF8574T.

Not sure what else to give you..

Did you read the stuff above the point where you joined the thread, about the I2C address?

Edit: Well, if i try to post images the page doesn't even want to try if i hit post....

What technique did you try?

Don

floresta:

The chip on the "emall-4u I2C" says PCF8574T.

Not sure what else to give you..

Did you read the stuff above the point where you joined the thread, about the I2C address?

Edit: Well, if i try to post images the page doesn't even want to try if i hit post....

What technique did you try?

Don

Have you declared the address elswhere?

/*-----( Import needed libraries )-----*/ 
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library
//Download: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move original LiquidCrystal library elsewhere, copy this in it's place

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574A 
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  7
#define En_pin  4
#define Rw_pin  5
#define Rs_pin  6
#define D4_pin  0
#define D5_pin  1
#define D6_pin  2
#define D7_pin  3

#define  LED_OFF  0
#define  LED_ON  1

/*-----( Declare objects )-----*/  
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

puttelino:
Im also using the emall4u board. It's not working with the pins you posted. What screen are you using? Also im using a Nano-board. Wich seems to also cause problems for some people :slight_smile:

If your i2c board was the same, then it should work.
This is starting to turn into a thread hyjack.
(A new thread for your issues would be better)


Since the backlight turns on i gather that the arduino and IIC are talking. Wich leaves 2 options. The pins are wrong or there is something wrong with the IIC-board.

Not necessarily. The backlight may be on by default.
They key to getting it to work, is to do what Tomki did.
Figure how how the i2c chip is wired up to the LCD.
From that, it is fairly easy to determine the proper constructor for fm's library.

With respect to initialization,
I would use the newer larger constructor like Tomki did vs using the legacy lcd.setBacklightPin() function.
fm's latest code now attempts to turn on the backlight by default before lcd.begin() returns.
The backlight will be on when lcd.begin() returns assuming the i2c address and pins in the constructor are correct

My preference is also to use the lcd.backight() and lcd.noBacklight() vs lcd.setBacklight(value)
to turn the LCD backlight on an off since those are compatible with interfaces that support dimming.
Using lcd.setBacklight(1) will be a very dim backlight on interfaces that support dimming.

The sample code you posted is not turning the backlight on and off. So if you see it flickering,
then something is wrong - more than likely incorrect pins in the constructor.

To test the backlight pin and mode in the constructor, all you have to do is
try something like:

loop()
{
    lcd.backlight();
    delay(1000);
    lcd.nobacklight();
    delay(1000);
}

But guessing is not the answer. The real solution, is trace the wires from the PCF8574 to the LCD interface
you can either to it visually or with an ohm meter.
Once you know where the wires go, then getting the constructor correct is easy.

--- bill

stcrooks:

floresta:

The chip on the "emall-4u I2C" says PCF8574T.

Not sure what else to give you..

Did you read the stuff above the point where you joined the thread, about the I2C address?

Edit: Well, if i try to post images the page doesn't even want to try if i hit post....

What technique did you try?

Don

Have you declared the address elswhere?

/*-----( Import needed libraries )-----*/ 

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library
//Download: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move original LiquidCrystal library elsewhere, copy this in it's place

/-----( Declare Constants )-----/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574A
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  7
#define En_pin  4
#define Rw_pin  5
#define Rs_pin  6
#define D4_pin  0
#define D5_pin  1
#define D6_pin  2
#define D7_pin  3

#define  LED_OFF  0
#define  LED_ON  1

/-----( Declare objects )-----
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

Oh... It's there. I just managed to delete while i cleaned the code for the forum. I will edit the post..

So i traced all the pins. Seems the thread starter has the right combination for my setup aswell. Now what?

Edit: I2C-detec finds an adress att 0x20 aswell...

This is starting to turn into a thread hyjack.
(A new thread for your issues would be better)

I originally used that term, but I am mellowing as I age and I went back and changed it to read "...where you joined the thread...".

Oh... It's there. I just managed to delete while i cleaned the code for the forum. I will edit the post..

AARRGGHH... We need to see the code that you actually used, not the code that you think you used or that you would have liked to have used. We need a copy/paste from the IDE.

Don

puttelino:
So i traced all the pins. Seems the thread starter has the right combination for my setup aswell. Now what?

Edit: I2C-detec finds an adress att 0x20 aswell...

So you are saying you have traced all the connections from PCF8574 pins to the LCD?
Can you list each of the pin numbers on the PCF8574 that connect to the LCD and then
which LCD pins they connect to?

What about the backlight? How is it wired up?
Is there a transistor? If a transistor what type, NPN or PNP and how is
is wired up to the LCD?
What does the backlight jumper do?

If it is the same as TomKi's board, then
use the newer constructor that TomKi provided that includes the backlight bit and the backlight polarity.
Then initialize it using:

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

You shouldn't use lcd.setBacklightPin() that is a legacy api function.
The constructor now contains all the needed information.

Then it should work.
If the board supports backlight control you can try turning on/off the backlight using
lcd.backlight() and lcd.noBacklight()

That should do it.
If not, then there might be a i2c communication issue.
Do you have pullups on the i2c signals?

--- bill

bperrybap:

puttelino:
So i traced all the pins. Seems the thread starter has the right combination for my setup aswell. Now what?

Edit: I2C-detec finds an adress att 0x20 aswell...

So you are saying you have traced all the connections from PCF8574 pins to the LCD?
Can you list each of the pin numbers on the PCF8574 that connect to the LCD and then
which LCD pins they connect to?

What about the backlight? How is it wired up?
Is there a transistor? If a transistor what type, NPN or PNP and how is
is wired up to the LCD?
What does the backlight jumper do?

If it is the same as TomKi's board, then
use the newer constructor that TomKi provided that includes the backlight bit and the backlight polarity.
Then initialize it using:

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

You shouldn't use lcd.setBacklightPin() that is a legacy api function.
The constructor now contains all the needed information.

Then it should work.
If the board supports backlight control you can try turning on/off the backlight using
lcd.backlight() and lcd.noBacklight()

That should do it.
If not, then there might be a i2c communication issue.
Do you have pullups on the i2c signals?

--- bill

I traced the pins to *(Pin on the chip)

BACKLIGHT_PIN 3 (7)*
En_pin 2 (6)
Rw_pin 1 (5)
Rs_pin 0 (4)
D4_pin 4 (9)
D5_pin 5 (10)
D6_pin 6 (11)
D7_pin 7 (12)

This code makes the backligt turn on and off still get blobs though...

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

#define I2C_ADDR    0x20  // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

int n = 1;

LiquidCrystal_I2C	 lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{

  lcd.begin (20,4);
  // Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home ();                   // go home

  lcd.print("SainSmart I2C test");  
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print("F Malpartida library");
  
  

  
 }

void loop()
{
  
    delay(1000);
    lcd.setBacklight(HIGH);
      delay(1000);
    lcd.setBacklight(HIGH);
}

Removing the baklight jumper kills the baklight. Seems the connect to VCC.

I have been using Malpartidas lib all along (v1.2.1). I have pullups (4k6)

puttelino,
start a new thread.
This has become a thread hijack.
The original thread was a simple "Hey, here is how to use this i2c lcd backpack".
It has now drifted into working through some sort of software/wiring/hardware issues.
I recommend that you start a new thread
and post photos of your board and show the current code you are running
so we can then proceed helping you bring up your board.

--- bill