MCP23017 stopped to work after HA update to 0.115

Well I am using quite different instalation because I have HA in docker on Raspian.
So I have easy access to my shell :slight_smile:

Basically You need to access to shell command on your Raspberry.
I have no access to my system now but there is the addon on HA, which allows you to have shell access. It is called SSH & Web Terminal

There you need to type the: i2cdetect -y 1
It may be you need to install two dependences:
sudo apt-get install -y python-smbus
sudo apt-get install -y i2c-tools

at least second one provides i2cdetect

Hope this helps a bit.

Finished to reinstall but still nothing:
always
“ValueError: No Hardware I2C on (scl, sda) = (3, 2)”

At this point I don’t know what to do.
I express a few questions dictated by “despair”:

The instructions to enable I2C are clear and so I wrote them but I ask you if the words are capitalized like
— new folder called CONFIG

and those in lower case type
— new folder called modules
should they be written like this?

At the end of the instructions is this sentence:
–The I2C devices should now be present under /dev.–

but on the hassio SD I don’t have this / dev but a folder called “overlays” where inside there are a lot of .dtbo files including some for the MCP27013.

I reiterate that the chips all work.
I am really considering giving up.

This is all you have to do in /boot/config.txt file
You can do it removing your SD card from RPI and put to PC/MAC and edit file simple by adding this line at the end of file.

Another question - to which pins you connect?
From that link it must be connected to physical pin: 2 and 5: (GPIO2 and GPIO3)
https://www.raspberrypi.org/documentation/usage/gpio/

I use the GPIO Header downloaded from the official RPI website:
Pin 03 -> GPIO02 (SDA1)
Pin 05 -> GPIO03 (SCL1)

I reloaded three times from scratch.
The GPIOs all work as both “switches” and “binary sensors”. I also connected a DHT22 with no problems.
sure there is something that escapes me.
Unfortunately I tried with SSH and WEB Terminal but it doesn’t read and I don’t know how to install the dependencies you suggested.
This is getting absurd !!!

By now I believe the I2C ports are compromised. Maybe they received a 5volt spike during testing, I don’t think there is any other explanation.

MCP23017 can by supplied with 3.3V than you are fine with RPI
Are you convinced your expanders are fine?

I have connected couple of them - no problems.

Edit:
I saw couple post ago your statement:
“3 mcp is with address 20. and reset is correctly set.”
I hope you are connecting only one chip in one time? Otherwise it will not work - the same addresses.
/I am sorry I know it is obvoius/.

The chips I use work correctly with a pcb running a wemos d1 and esphome.
I only use one chip to test it and A0, A1, A2 are connected to ground. Reset pin a + vcc. I don’t use INTERRUPT.

I tried to power MCP23017 with both 3v3 and 5v.

I remember that I had challenge with this as in the manual to enable I2C using USB stick it was stated that this folder has to have name “/modules” - the slash “/” at the beginning of the name “modules”.
From Windows laptop I was not able to make it. Was trying different options as I do not have linux machine either. At the end it was possible to do it on Mac laptop (putting USB stick to Mac and renaming the folder to /modules .
Then applying this configuration via Supervisor and restarting Pi was working fine.

There might be some info on this topic as well: MCP23017 I/O Expander - #20 by Maco65

Hi, thanks for your help.
So are you telling me I need to call the “/ modules” folder?
How did you manage to write the “/” character with Windows?

@fraygon - I am sorry but now I am confused.
I am 100% sure I have use method with USB stick and I did not remove SD card from RPi.
This method is mentioned in few places (like this) but now on the official Home Assistant page is not described. :frowning:
With current description (adding data directly on SD card) there seem to be no need to add slash “/” in front of the “modules” folder.

What comes to my mind now is that if you trying to adjust folders using Windows computer - it might be a challenge as I do not think Windows file system can read Lynux one (used by RPi)…
Here is some info: I2c not working on the Pi4

I saw the link you sent me.
Have all users using RPI4 for HA failed to activate the I2C function?
It seems strange to me: the forum would be jammed with requests.

I am perplexed. If RPI4 is truly not compatible, my entire home automation project needs to be reviewed. I created my pcbs to have states and commands from expanders.
In order not to abandon HA I would have to migrate to esphome.

A disaster!!!

I am not sure if this can help you but when I go to Supervisor, System and then under three vertical dots select Hardware, under the gpio i can see the following:

gpio:
  - gpio26
  - gpio17
  - gpio22
  - gpiochip0
  - gpio10
  - gpiochip504

I guess gpiochip0 is my MCP23017. Or under gpiochip504 - not sure which. I have only one connected at this point.

alleluia!!! :smiley: :smiley: :smiley:
i managed to get my expander to work.
I’m not sure what happened because I reinstalled hassio a dozen times.
After reading the various forum posts I also deleted the file in
“/config/home-assistant_v2.db” and after reboot the entities I had written in configuration.yalm magically appeared.

I don’t really understand what happened but I’m happy with it. I took three snapshots for safety.
And now on with the tests.
Thanks to all who have helped and endured me: you are magnificent. :smiling_face_with_three_hearts:

Great News !

home-assistant_v2.db file is the main HA database. Strange if this was the reason…
Ideally it would be good if you have any suspicion what was the problem… just for others.

I wish you knew what happened. The attempts were frantic and continuous. Sorry I’m not useful.
Even now I have problems, yesterday I was driving both inputs and outputs. Today only inputs: switches don’t want to know.
Also I always have to restart when it gets confused.
At least it gives a sign of life!

OK. I have also observed once a while strange behaviour. Was planning with some support to adjust the integration to more effective. I believe I will have a time to work with this in next weeks. Will see. If you have any string evidence related to root cause or problems with this chip then please share it.

Certainly. In my home automation this chip will be very present.
Do you think it is better to open any new topic or continue with this one?

I believe there is already topic relevant: https://community.home-assistant.io/t/re-mcp23017-chip-settings/239458

Hi Maciek,

The link seems not to work.

BTW I am using 4 MCP23017 - after a lot of workaround solutions they are quite usable.
I have two problems which are really annoying:

  1. During every restart of HA the state of all switches goes off - I didn’t find solution for that
  2. What is worse sometimes during restart the switches can generate strange behavior like sudden turn on/off and some of them are stuck (hang) /not all/. Which causes I can’t use them until next restart. The same for sensors.
    The work around is the external python script I run every HA restart to initialize MCP

I believe there is already topic relevant: https://community.home-assistant.io/t/re-mcp23017-chip-settings/239458

the link does not open

  1. During every restart of HA the state of all switches goes off - I didn’t find solution for that
  2. What is worse sometimes during restart the switches can generate strange behavior like sudden turn on/off and some of them are stuck (hang) /not all/. Which causes I can’t use them until next restart. The same for sensors.
    The work around is the external python script I run every HA restart to initialize MCP

He does strange things to me too. I have to reboot twice for it to be fully operational. The first reboot properly enables me the binary_sensor ports. The second reboot also enables the switches.
To remedy the bad boot states I am attempting to start the chip after reboot via a physical timer chip.
This integration is making me sweat a lot!

Apologies, I have pasted wrong link. Here is correct one: MCP23017 chip settings - #18 by Peerke

Will comment your input in this topic mentioned above.