I2cbus : problems with a PCF8574

Hi, guys! I'm attempt to work with arduino2009 connected to IOexpander 8 I/O PCF8574 via i2cbus, using the easy-to-use wire library I follow all the examples found on the net but my 8574 doens't answer

So, I keep the scope and I see this : arduino STOP che clock trasmission immediatly after sending the one-byte request.

My component address is 0x38 (as per the datasheet, with 3 address component pin to ground)

I tried shifting address to left but the arduino performs always the strange behaviour. After sending the wire request, it stops the clock trasmission to slave!!! Why this?

In this way the slave cannot sent a answer .. =( adn the wire library cannot be wrong :D

What is my error?? I post my simple code here! If you see the scope, arduino stop sending the clock after first byte trasmission :blush:

WireBegin(); Wire.requestFrom(INaddr, 1); //Nadrr = 0x38 , a Pc8574 datasheet address

while (Wire.available()) { inputs = Wire.receive(); // receive a byte as character } WireEndTransmission

Thank you un advance for any suggestions

You need to first tell it what register address you want to read, so you write to it first before reading from it.

Is that address correct? It should be 0x20 according to my data sheet.

Thank you for your fast reply!

I have a Ti PCF8574A, and the data sheet reports the address from 0x38 to 0x3F

this 8 bit expander havent’ register (It seems so from DSh…) and it respond simply with a byte (8 pin status port) if you send adress plus Read request on the last bit R/W…I cannot find any sequence (first send a register and so on the data sheet…) have you already tried to interface this component? And do you sent a register number before request a data byte??

I could try 0x20 or a 1-bit left shift byte… but
My doubt is : why does arduino stop to sent the clock SCL after first byte…?? It could be a problem, the slave cannot send anything :*

I have a Ti PCF8574A,

That is not what you said in the initial post, you said:-

connected to IOexpander 8 I/O PCF8574 via i2cbus

have you already tried to interface this component

Yes I used it in this project;- http://www.thebox.myzen.co.uk/Hardware/Transistor_Tester.html I was driving it through Processing:- 1) Directly with a USB to I2C interface 2) Through an arduino from processing

Wire.begin(); should be done only once in the setup function. These are the routines I read and write that chip:-

void gpio_write(int address, int data) {
  //  Send device address
  Wire.send(data );    //  send byte

int gpio_read(int address) {
  int data = 0;
  //  Connect to device and request one bytes
  Wire.requestFrom(address, 1);
   while(Wire.available())    // slave may send less than requested
    data = Wire.receive(); // receive a byte as character
  return data;

thank you again and sorry for my mistake writing the component reference. Today afternoon I'll try again following your code. A tip: must I write the address directly (0x38) or it is necessary a shift due to 7 bit i2cbus first byte format? It is not reported on the library reference, so I think to put it directly without any shift.


The address of 0x38 is the right one to use.

On this page, about half-way down, I have an I2C scanner:


Run that to find your slave address. If you don't get anything at all, stop right there and check your wiring. If you get an address, that is the one to use.

If that doesn't help, post your code, not just (retyped) snippets of it. Put it inside [ code ] tags using the "#" button.