problem interfacing LCD using I2C bus (Solved :) )

hi,
i was trying to interface 16x2 LCD to the Arduino using I2C bus, but despite all the efforts was unable to Display “Hello world” example.

informations:

  1. i’m using pfc8574AP, the circuit is theone demonstrated herehttp://dangerousprototypes.com/2009/08/13/bus-pirate-hd44780-character-lcd-adapter/

2)A2,A1,A0 is connected to ground .so have assigned the address as 0x38 w.r.t the datasheet
3) have connected pull-down resistors of 4.7K (as per the instruction on various forums)

4)code used is:

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

LiquidCrystal_I2C lcd(0x38,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Hello, world!");
  Serial.begin(57600);
}

void loop()
{
}

(code tags fixed by moderator - you were pretty close!)

need help in getting this thing working.

thanks,
Sushant

Isn't there usually a part where you define the pins you are using with the library?

I didn't see any software or links to software at dangerous prototypes

Oh, I2C = so you are connected to SCL/SDA?
You need this too then:
Wire.begin(address);

Check this too

http://arduino.cc/playground/Code/LCDi2c

"09-14-2009 Mario added support for using a standard HD44780 compatible LCD using the PCF8574 . The new library named “LiquidCrystal_I2C” and can be found here Arduino Playground - HomePage "

Just quickly... I2C needs pullups not pulldowns

Also i'm looking at the TI datasheet for the PCF8574 and it suggests that the full address is not 0x32 (32 is actually the decimal value from the table)

According to page 4 it should be combined with the read write.

If I was you I'd forget the LCD for the moment and just connect the PCF8574 to some LED's. Once you get the address and the communication worked out connect it to the LCD.

Looking more at the datasheet the address almost seems to differ when you want to read or write to the device? Damn confusing the way it's written but you get that with some datasheets.

For a write the address could actually be 0x40 and for a read it could be 0x41.

Worth trying.

Something like this should give you alternating LED's

	Wire.beginTransmission(0x40);
	Wire.write(0xAA);
	Wire.endTransmission();

Finally the arduino shouldn't need pullups. The internal ones are enabled by default and are usually sufficient.

"the arduino shouldn't need [I2C] pullups. The internal ones are enabled by default and are usually sufficient."

Barely. If you want decent rise times on the edges you need the 4.7K pullups. I missed the reference to 4.7K pulldowns. See what you expect to see sometimes.
If you looked at the signals with a 'scope you would really appreciate the difference.

I don't have a scope so I simply rely on whether it works or not.

For arduino I didn't need them. For the attiny85 10k pullups worked nicely.

sushant:
hi,
i was trying to interface 16x2 LCD to the Arduino using I2C bus, but despite all the efforts was unable to Display "Hello world" example.

informations:

  1. i'm using pfc8574AP, the circuit is theone demonstrated herehttp://dangerousprototypes.com/2009/08/13/bus-pirate-hd44780-character-lcd-adapter/

2)A2,A1,A0 is connected to ground .so have assigned the address as 0x38 w.r.t the datasheet
3) have connected pull-down resistors of 4.7K (as per the instruction on various forums)

LiquidCrystal_I2C lcd(0x38,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

When you look at the datasheet http://www.nxp.com/documents/data_sheet/PCF8574.pdf on page 10 you can see that the device-adress is 7 bits long.
Starting from A0,A1 and A2, then 0,0,1,0. So your adress is somewhere between b0100000 and b0100111 or between 0x20 and 0x27.
So if you set A0 - A1 low this is 0x20. You declare it as being 0x38. I assume the comment was not edited by you, so the original code adressed the device with A0 - A1 set high...

actually i wrongly wrote "pull down" instead of pull-up.

ReSiStAnCe:
When you look at the datasheet http://www.nxp.com/documents/data_sheet/PCF8574.pdf on page 10 you can see that the device-adress is 7 bits long.
Starting from A0,A1 and A2, then 0,0,1,0. So your adress is somewhere between b0100000 and b0100111 or between 0x20 and 0x27.
So if you set A0 - A1 low this is 0x20. You declare it as being 0x38. I assume the comment was not edited by you, so the original code adressed the device with A0 - A1 set high...

the chip i'm using is PCF8574 AP and the datasheet gives below value for the address:

For PCF8574A the addressing is:

A2 A1 A0 Dec Hex
L L L 56 0x38
L L H 57 0x39
L H L 64 0x40
L H H 74 0x4A
H L L 75 0x4B
H L H 76 0x4C
H H L 77 0x4D
H H H 78 0x4E

the chip i’m using is PCF8574 AP and the datasheet gives below value for the address:

For PCF8574A the addressing is:

A2 A1 A0 Dec Hex
L L L 56 0x38
L L H 57 0x39
L H L 64 0x40
L H H 74 0x4A
H L L 75 0x4B
H L H 76 0x4C
H H L 77 0x4D
H H H 78 0x4E

My bad. You are right.
The table however should be 0x39,0x3A,0x3b etc… ending with 0x3F

sushant:
the chip i’m using is PCF8574 AP and the datasheet gives below value for the address:

For PCF8574A the addressing is:

A2 A1 A0 Dec Hex
L L L 56 0x38
L L H 57 0x39
L H L 64 0x40
L H H 74 0x4A
H L L 75 0x4B
H L H 76 0x4C
H H L 77 0x4D
H H H 78 0x4E

The TI sheet I looked at didn’t have the A version.

Are you using the NXP chip?

If so check the datasheet again, Page 9 specifically, and see that it tells you to include the LSB which you needed to do anyway and haven’t, as you can see on pages 10 and 11.

Your address should be 0b01110000 = 0x70 = 112

Edit: i’m wrong. Wire adds the LSB

The LSB from this byte is the R/W bit and has nothing to do with the adress off the device. You do have to send it though..

ReSiStAnCe:
The LSB from this byte is the R/W bit and has nothing to do with the adress off the device. You do have to send it though..

It has everything to do with the address value that you send to a library that expects an 8 bit address.

Lets see you use the wire library beginning with the transmission of a 7 bit address followed by the transmission of a single read/write bit.

...

m12lrpv:

ReSiStAnCe:
The LSB from this byte is the R/W bit and has nothing to do with the adress off the device. You do have to send it though..

It has everything to do with the address value that you send to a library that expects an 8 bit address.

Lets see you use the wire library beginning with the transmission of a 7 bit address followed by the transmission of a single read/write bit.

...

The device DOESN'T expect an 8 bit adress. It expects a BYTE. This byte is made up of the 7 MS bits which determines the device adress and the lsb which indictates wether you are writing or reading to/from the device.

So if you want to write to the device 0x38, the first byte you (or rather the wire-library) send is b01110000 (0x70). For reading the same device you send b0111001 (0x71)

I may not know the wire library inside out, but I sure know how to read and interpret a datasheet..

The OP wants to get his circuit working.

I'm trying to get the OP's circuit working and have observed that the OP is obviously having trouble translating the address information in the datasheet into the values he needs to send to the arduino libraries.

You're trying to argue semantics for no gain other than to perpetuate the confusion suffered by the OP. Why are you doing that? It achieves nothing positive and makes you look silly to a global audience.

"Arduino... separating programmers and electrical engineers like never before..."

i used the I2C scanner from herehttp://arduino.cc/playground/Main/I2cScanner, the scan suggests that device is connected at 0x38 but still i'm not getting any display on the LCD using this address?

sushant:
i used the I2C scanner from herehttp://arduino.cc/playground/Main/I2cScanner, the scan suggests that device is connected at 0x38 but still i'm not getting any display on the LCD using this address?

Can you please post the code you're using to drive the LCD?

Have you tried connecting LED's to the PCF8574AP instead of the LCD. These will give you a better visual indicator that the PCF8574AP is functioning as expected before moving onto the debugging the LCD.

sushant:
i used the I2C scanner from herehttp://arduino.cc/playground/Main/I2cScanner, the scan suggests that device is connected at 0x38 but still i'm not getting any display on the LCD using this address?

Have a look in this folder: \Arduino-1.0\libraries\LiquidCristal_I2C\info
It has a nice picture called schematic_diagram. The examples in the library are based on this schematic.
One significant difference with the example you started off is the connection of E , RS and R/W to the PCF.

So, please wire your display as in the schematic and have another go. Forget about the backlight for now, just connect to Vcc and GND (with a resistor of course)