1

When I connect the GPIO expander MCP23008 to the raspberry pi 1 model B+ via I2C, the address of the MCP23008 on the raspberry pi keeps switching between 0x20 and 0x21, and sometimes it's not even detected (see the captions below). What's wrong? How can I stop this uncontrollable change of address on the I2C? The OS is the latest raspberry pi OS desktop version.

enter image description here

enter image description here

enter image description here

Here's the circuit:

enter image description here enter image description here

20
  • 2
    You have not wired the device correctly. If you want a solution we need to see your wiring.
    – joan
    Feb 11 at 23:10
  • 1
    @joan I added the circuit diagram to my question.
    – S.E.K.
    Feb 12 at 0:32
  • 1
    @S.E.K, Ah, you need to tie the hardware address pins to either High or Low. You cannot leave them floating, which usually means High, but not for this chip. One of the manufacturer's design bug for this chip is that floating means indeterminate. This is the MCP23008/017 newbie's sorrow. Another bug is a restriction on the use of one or more of the GPIO pins.
    – tlfong01
    Feb 12 at 2:22
  • 1
    @tlfong01 - looks like pins 3, 4 and 5 are grounded though - according to the diagram - but who knows what is actually connected where, that image of the actual connections is next to useless Feb 12 at 3:15
  • 1
    since the address is flipping between 20 and 21 it's likely to be the A0 address line that isn't grounded properly - that's pin 5 Feb 12 at 3:47
1

Thanks to everyone's comments I've come to a solution. All comes down to not letting the wires float (as suggested by @Dougie). Connecting the wires in a breadboard does not guarantee that they be actually connected, so I soldered them, and that stabilized the address of the MCP23008 on the I2C bus.

0

Do you have pullup resistors on the I2C lines? I'd put a 10K resistor between the SCL/SDA lines and VCC

2
  • 1
    The Pi has hardwired 1k8 pull-ups to 3V3 on SDA and SCL. No more should be needed.
    – joan
    Feb 12 at 10:57
  • 1
    Ok, I didn't know that.
    – jkp
    Feb 12 at 15:44

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .