PCF8575 with Arduino Uno

Hello everyone! This is my first time on the forum.

I've been trying to use an I2C port expander module for days, but without success.

I'm using PCF8575 to increase the number of digital output pins, but I can't get the module pins to switch between high and low (0 - 5V). The pins always stay high. Below is the small code I wrote.

I've tried various things in the code, including using only the Wire library, but I haven't been successful. I soldered the VCC and VDD pads to bypass the voltage regulator and obtain 5V on the output pins. When I use a multimeter to measure the voltage of the module pin, it always reads 5V.

All the tutorials I've seen show that I did everything correctly, but I'm not getting any success. I bought a new module thinking it might be a defect in the module, but that wasn't the case.

What could be wrong?

/*
 Blink led on PIN0
 by Mischianti Renzo <http://www.mischianti.org>
 https://www.mischianti.org/2019/01/02/pcf8575-i2c-digital-i-o-expander-fast-easy-usage/
*/

#include "Arduino.h"
#include "PCF8575.h"

// Set i2c address
PCF8575 pcf8575(0x20);

void setup()
{
  Serial.begin(9600);

  // Set pinMode to OUTPUT
  pcf8575.pinMode(0, OUTPUT);
  pcf8575.begin();
  
}

void loop()
{
  
  pcf8575.digitalWrite(0, HIGH);
  delay(1000);
  
  pcf8575.digitalWrite(0, LOW);
  delay(1000);
  
}

Close, just a small typo:

pcf8575.digitalWrite(0, HIGH);

should be:

pcf8575.digitalWrite(P0, HIGH);

I don't know if this will solve the problem, but pcf8575.begin() line MUST called before any other commands related to the multiplexer

Have you tested the multiplexor with i2c scanner ?

1 Like

I had already tried with 'P0' too, without success. :sleepy:

At first, I hesitated to perform an I2C address scan because the default address of this module should be 0x20. However, when I tested it, I discovered that every time I restart the Arduino, the module responds at a different address. This doesn't make sense! :rage: I decided to solder all three address pins to VCC to set it as 0x27, and now it works fine. :smiley: I can't understand the logic behind why the module responds at random addresses each time it restarts. :face_with_diagonal_mouth:

Looking at your picture you have it wired wrong. I use similar items without any problems. Try posting a simple schematic rather then your pictures and show all connections and power supplies. Also post links to the hardware devices that give technical information. You have a hardware problem, run the I2C scanner and when you get the correct port to show it should work.

The connections are right and I did exactly as in the posted photo. The Arduino was powered by the notebook's USB.

I think you read something wrong, the base address is probably 20, but the three address bits need to be set to either 0 or 1, with them not connected, you got random addresses. Some modules have built-in pullups or pulldowns, yours clearly did not. It might be obvious, or not, if you provided a link to the item you actually own.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.