Open nekromant opened 2 years ago
Hey there @esphome/core, mind taking a look at this issue as it has been labeled with an integration (esp8266
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
Hey there @esphome/core, mind taking a look at this issue as it has been labeled with an integration (i2c
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The ESP8266 arduino framework doesn't seem to support multiple I2C buses, at least the code here accesses the global twi_
functions everywhere and doesn't seem to distinguish between instances.
Would be good to catch this in validation stage already though
The problem
When specifying more than one I2C bus on a board only the last one is used. (In my case, the busses share the same SDA pin, but different SCL pins, like a poor man's i2c multiplexer. But this is not really what matters.)
It seems that internally in esphome: (See api/i2c.cpp line 19) uses one global Wire class for all transactions.
In the case of multiple busses that will be subsequently reinitialized here:
Thus Wire will work with only the last bus in array.
Possible solutions (as I see it):
When starting any transaction. (Will be less memory hungry).
So far I'm doing it in my custom component for the sake of simplicity. Not sending a PR, since I'm not sure what is the best option here.
Which version of ESPHome has the issue?
2021.9.3
What type of installation are you using?
pip
Which version of Home Assistant has the issue?
2021.7.1
What platform are you using?
ESP8266
Board
esp8266 wroom on a custom board
Component causing the issue
api/i2c
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
No response