Uncategorized

mcp23008 notes

How to stabilize the address of a component on the I2C bus?

Ask QuestionAsked todayActive todayViewed 34 times1

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

gpioi2craspberry-pi-osShareEditFollowClose 2Flagedited 1 hour agoasked 13 hours agoS.E.K.3111 silver badge44 bronze badges

  • 2You have not wired the device correctly. If you want a solution we need to see your wiring. – joan 13 hours ago
  • 1@joan I added the circuit diagram to my question. – S.E.K. 12 hours ago 
  • 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 10 hours ago    
  • 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 – Jaromanda X 9 hours ago 
  • @Jaromanda X, Ah yes, you are right, the address pins seems correctly connected. Let me suggest some troubleshooting tips to SEK later. – tlfong01 9 hours ago   
  • @S.E.K. I usually do the following: (1) Use a multi-meter to do point to point “open short” testing, to make sure if all the point to point connections are shorted, the neighboring pins supposed to be disconnected are open. (2) Change the address pin connections from G, G, G to G G Vcc and other connection patterns to see if “i2cdetect -y 1 (or 0, I forgot) shows expected hex addresses. (3) Swap another mcp23008 (Yes, I usually have more than one for swap testing. / to continue, … – tlfong01 9 hours ago   
  • 1since 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 – Jaromanda X 9 hours ago
  • (4) The bread board sockets might be loosen, causing “poor electrical contact”, so why not move to another position, use another set of jumper wires (sometimes the jumper wires, after being bent too often, broken inside, and cause intermittent “break and make” connections. (5) So you see, what I am doing is SWAP, SWAP, SWAP – swap and test anything you can swap and test. (6) Other things EE pros do but newbies won’t bother to do are “BACKUP, BACKUP, BACKUP” and “DOCUMENT, DOCUMENT, DOCUMENT”, / to continue, … – tlfong01 9 hours ago   
  • @Jaromanda X, yes, swapping only the pin 5 related wiring/connection is so called “clever swap”, done after thinking and narrowing down the possible trouble making area, opposed to “blind swap” of swapping everything without thinking, of course wasting time. – tlfong01 9 hours ago   
  • I remember when I first learned mcp23x/08/17, I actually started with mcp23s08, then swapped to mcp23008, then swapped to s17, then 017. Then I swapped from through hole chips to modules. – tlfong01 9 hours ago   
  • We need a clear photo of the connections. The photo is not good enough. – joan 3 hours ago
  • @joan I’ve just updated the photo of the connections, hope this one’s clearer… – S.E.K. 1 hour ago
  • Better, but it still doesn’t let us be sure. The connections appear correct. You appear to have all the address lines pulled to ground. An overhead view as well would be useful. – joan 57 mins ago
  • @S.E.K. (1) I would like to confirm one thing: Have you powered MCP23008 with 3V3, NOT 5V0? (2) I googled a schematic and my old posts to refresh my memory. Then I remembered that I always use a logical level converter to convert Rpi’s 3V3 signals to 5V. If you are following my photos to use 5V Vcc, without a TSX0102/4 converter, you might (a) Get I/O errors (i2cdetect -y 1 does snot show I/O errors, python does), (b) Damage Rpi. (3) References: [1] MCP23017 Inputs/Output copy – EasyEda 2018-08-26 easyeda.com/mankes/i2c-expander. /to continue, … – tlfong01 4 mins ago    Edit   
  • [2] Rpi.Org.Forum mcp23008 tlfong01 Search found 11 matches: raspberrypi.org/forums/search.php?keywords=mcp23008+tlfong01 [3] Rpi.Org.Forum mcp23017 tlfong01 Search found 178 matches: raspberrypi.org/forums/… – tlfong01 1 min ago   Edit   

Add a comment

1 Answer

ActiveOldestVotes1

Do you have pullup resistors on the I2C lines? I’d put a 10K resistor between the SCL/SDA lines and VCCShareEditFollowFlaganswered 2 hours agojkp9611 bronze badge

  • The Pi has hardwired 1k8 pull-ups to 3V3 on SDA and SCL. No more should be needed. – joan 2 hours ago 

Add a comment

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.