When I connect all A0, A1 and A2 to ground, then my device address of the MCP23017 is 0x20 (constant).

But when I disconnect the A0 from ground, then the device address is switching between 20 and 21 everytime I check with the i2cdetect command?

Why isn't the device address constantly 21?


Probably because the pin is floating.

Indeed the datasheet says of pins A0, A1, A2 "Hardware address pin. Must be externally biased."

This means you must tie each pin either low or high, you must not let them float.

  • Also check the errata (always a good idea, doubly so when microchip is involved), I have a feeling that there is a subtle trap in the write to enable hardware addressing on those parts.
    – Dan Mills
    Aug 29 '18 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.