Hi. I recently purchased a couple of these I/O expander modules, and I think they might be faulty, unless they work differently to what I'm used to.
VDD outputs 3.3V, so far so good, but if I load a simple sketch setting one of the pins to OUTPUT and writing it HIGH, it outputs only in the ~0.4V. The most I've read from one of them once was 1.4V. That doesn't sound right. Either they are faulty, or I burned them somehow, right?
If I get one that works, wouldn't it be the expected output 3.3 as well? if I need to make it an INPUT pin, I need to connect it to 3.3 I assume, not the VCC from the arduino?
f you have one that uses the PCF8575C and not the plain PCF8575, then it only works with 5V.
It's a PCF8575TS. I just did another test and the pins properly read INPUT with 3.3V. It's just that the OUTPUT seems to be broken, as I've set pin 0 to OUTPUT and digitalWrite HIGH, the rest of them to INPUTS (which as mentioned, work in reading HIGH when shorting them with VDD), then shorted P0 with any other pin, and it doesn't read HIGH. And why should it, if it's not even outputting 1V.
Do you think I might have burned the board while testing?
Not sure what you mean
1. PCF8575 works with 2.5 V to 5.0 V .
2. PCF8575C works with 4.5 V to 5.0 V.
If you used these kind of expanders before and are familiar with how they work, then I would have to say they are probably damaged or were bad when you got them.
No, I've never worked with them before.
So far I found out (with some guidance) the following:
- Setting the pins as INPUT_PULLUP does nothing. They need to be set up as INPUT only.
- If I connect an INPUT pin to VDD (3.3V) it reads 1, but if I connect it to 5V it reads 0.
- If I set a pin as OUTPUT and write it HIGH, and then connect that to an INPUT pin, the INPUT pin reads 0
I can't get an INPUT pin to read anything from any other pin, and that is unfortunately precisely what I need, as I intend to use this I/O expander for a button matrix.
I think you should post you code using code tags
I would expect that if I connect P0 with P1 to 7, any of those would read high, but all it does is read 10000000. It only reads 1 if I connect that pin to VDD (for instance if I connect pin 1 to VDD the below code will read 11000000)
#include "Arduino.h"
#include "PCF8575.h"
// Set i2c address
PCF8575 pcf8575(0x20);
void setup()
{
Serial.begin(115200);
// Set pinMode to OUTPUT
pcf8575.pinMode(P0, OUTPUT);
pcf8575.pinMode(P1, INPUT);
pcf8575.pinMode(P2, INPUT);
pcf8575.pinMode(P3, INPUT);
pcf8575.pinMode(P4, INPUT);
pcf8575.pinMode(P5, INPUT);
pcf8575.pinMode(P6, INPUT);
pcf8575.pinMode(P7, INPUT);
pcf8575.begin();
pcf8575.digitalWrite(P0, HIGH);
}
void loop()
{
Serial.print(pcf8575.digitalRead(P0));
Serial.print(pcf8575.digitalRead(P1));
Serial.print(pcf8575.digitalRead(P2));
Serial.print(pcf8575.digitalRead(P3));
Serial.print(pcf8575.digitalRead(P4));
Serial.print(pcf8575.digitalRead(P5));
Serial.print(pcf8575.digitalRead(P6));
Serial.println(pcf8575.digitalRead(P7));
delay(1000);
}
Which library are you using?
I don't see pinMode in my library?
Can you show us with a schematic how it's wired?
I think you should have the begin call before the pinMode calls
There's no schematic, there's nothing wired but the VCC, GND, SDA and SCL to the arduino, and those are properly wired. At this point I'm just using a jumper wire to connect two pins together and see In the Serial monitor the response.
I'll try that, but this is one of the library's example lighly modified. In that example the begin is after the pinMode as well.
Yeap, that didn't work.
Which arduino are you using?
It's a knock-off with the Pro Micro layout, but the Leonardo bootloader, so the IDE reads it as a Leonardo.
I don't think you can connect in this way because you are shorting the pins.
It should be connected as a button with a resistor between the output and GND then the input pin goes in the middle.
Did you run scanner program to check that the PCF8575 is found at address 0x20?
Unless you accidentally shorted an output set to HIGH to ground when you were debugging and damaged the IC, I don't see why it is not working.