Board with PCF8575, leds only blink , do not turn on

Hello,
I have two cards with PCF8575

https://www.ebay.com/itm/New-Open-Smart-PCF8575-IO-Expander-Board-Module-I2C-to-16IO-For-Arduino-WT/162553164976?hash=item25d8ec74b0:g:TQYAAOSwyWZZQPwL,

When I turn on the leds they only stay on for a brief moment, then they turn off.

With library it’s the same thing.

With the shunt done (5V) or not (3.3V).

I’ve been around this for a week and I don’t know what’s wrong.

MOERATOR EDIT : inappropriate aside removed

Thanks.

#include <Wire.h>

const byte address = 0x20;

void setup()
{
Wire.begin();

// all ports as output
pf8575_write ( word (B11111111,B11111111) );

// Set P1, P0
pf8575_write ( word (B00000000,B00000011) ); // P1 e P0
}

void loop()
{

}

void pf8575_write (word data)
{
Wire.beginTransmission (address);
Wire.write ( lowByte (data) );
Wire.write ( highByte (data) );
Wire.endTransmission();
}

When I turn on the leds they only stay on for a brief moment, then they turn off.

How have you connected the LEDs? Please post a schematic. With this chip, LEDs plus series resistors would be connected between Vcc and the output pin. This is because the pins can sink enough current for LEDs but cannot source very much current. If the LEDs are placed between the pins and ground, they will light only very dimly. And with your code they would light only for a very short flash and then off because that is what your code is written to do.

Please modify your post and put the code tags around your code. Read the forum guide to find out how and what other things you must and must not do. The moderators have intervened once already, so you must take care not to break other rules.

PaulRB:
And with your code they would light only for a very short flash and then off because that is what your code is written to do.

Would be interesting to play with a software I2C implementation and deliberately pause the Ack. :grinning:

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

This may help

Thanks.. Tom... :slight_smile:

It already works.
The problem was in fact the connection of the leds.
I have seen several schemes on the net, and they are connect to GND.

like in this site, where the led is connected to GND:

I will read the rules to try to understand how it works.

Thank you all.

jpau:
I have seen several schemes on the net, and they are connect to GND. like in this site, where the led is connected to GND:
Arduino and PCF8575 I/O expander examples - Arduino Learning


Wow!

I mean, just wow!

A site called “Arduino Learning”, with this article at least written by a complete fool without the electronics knowledge to comprehend a datasheet.

I have not investigated that site, but at this rate it begins to sound like another “instructables”. :astonished:

jpau:
I will read the rules to try to understand how it works.

OK, let me explain - and you can check the datasheet.

The PCF8574/5 uses a clever interface based on “open-drain” protocol. There is no actual “INPUT” or “OUTPUT” mode. It provides a “weak pull-up” which is the current that is lighting your LEDs dimly when they are connected to ground. If you write the register (there is really only one per 8 bits) with a zero (LOW) in a particular bit, then that pin is strongly pulled down sufficient to nicely light - up to say, 15 mg (“Absolute maximum” of 20 mA should be avoided) - a LED if it (and its resistor) are connected to Vcc (5 V).

If you at any time write the register with a “1” (HIGH) then while the I2C command is in progress, that pin is strongly pulled HIGH, resulting in a brief flash of a LED connected to ground as you have seen.

Paul__B:
“Absolute maximum” of 20 mA

50mA. (But there is a 100mA total limit for the chip, so only 5~6mA per pin if 16 LEDs attached). The 20mA limit is something to do with protection diodes on the pin, I think.

Paul__B:
If you at any time write the register with a “1” (HIGH) then while the I2C command is in progress, that pin is strongly pulled HIGH, resulting in a brief flash of a LED connected to ground as you have seen.

Interesting, what page does it say that on? I was putting the brief flash down to the OP’s code, which sets all pins to input and then immediately to output. With LEDs connected between the pins and ground, a brief dim flash would occur for the brief time they are set to input.

PaulRB:
50mA. (But there is a 100mA total limit for the chip, so only 5~6mA per pin if 16 LEDs attached). The 20mA limit is something to do with protection diodes on the pin, I think.

OK, mis-read that.

PaulRB:
Interesting, what page does it say that on? I was putting the brief flash down to the OP's code, which sets all pins to input and then immediately to output. With LEDs connected between the pins and ground, a brief dim flash would occur for the brief time they are set to input.

Section 8.1, page 12, second paragraph.

Well of course the port is set to input at default on power-up. In that code, you would have weak pull-ups (0.1 mA) while the Arduino is booting, a rather brief flash of 1 mA as it is written HIGH and then off.

At power on, the I/Os are high. In this mode, only a current source (IOH) to VCC is active. An additional strong pullup to VCC (IOHT) allows fast-rising edges into heavily loaded outputs. This device turns on when an output is written high and is switched off by the negative edge of SCL.

Ah, yes.

But on inspection of the specs, it is only 1 mA. :roll_eyes: