esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
292 stars 36 forks source link

Nodemcu-32s - tca9548a - mcp23017 control problem #2790

Open stefkamarton opened 2 years ago

stefkamarton commented 2 years ago

The problem

Hy, I have an ESP32 (nodemcu-32s) and I connect tca9548 multiplexer to create virtual i2c buses.

i2c:
  - id: bus_a
    sda: GPIO14
    scl: GPIO12
    scan: true

tca9548a:
  - address: 0x72
    id: multiplex0
    i2c_id: bus_a
    channels:
      - bus_id: tca0
        channel: 0

mcp23017:
  - id: 'mcp23017_hub'
    address: 0x27
    i2c_id: tca0

switch:
  - platform: gpio
    name: "MCP23017 Pin #0"
    pin:
      mcp23xxx: mcp23017_hub
      number: 0
      mode:
        output: true
      inverted: false

I try to connect my mcp23017 throughout tca9548A but I can't send data to mcp23017. If I disconnect my mcp23017 and I connect bme280 sensor, I receive data so I think, tca9548A works well. If I connect mcp23017 to esp without tca9548A then It works well.

Can you help me?

Which version of ESPHome has the issue?

2021.11.4

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP32

Board

nodemcu-32s

Component causing the issue

i2c, tca9648A, mcp27018

Example YAML snippet

i2c:
  - id: bus_a
    sda: GPIO14
    scl: GPIO12
    scan: true

tca9548a:
  - address: 0x72
    id: multiplex0
    i2c_id: bus_a
    channels:
      - bus_id: tca0
        channel: 0

mcp23017:
  - id: 'mcp23017_hub'
    address: 0x27
    i2c_id: tca0

switch:
  - platform: gpio
    name: "MCP23017 Pin #0"
    pin:
      mcp23xxx: mcp23017_hub
      number: 0
      mode:
        output: true
      inverted: false

Anything in the logs that might be useful for us?

[D][switch:021]: 'MCP23017 Pin #0' Toggling OFF.
[D][switch:037]: 'MCP23017 Pin #0': Sending state OFF
[D][switch:021]: 'MCP23017 Pin #0' Toggling ON.
[D][switch:037]: 'MCP23017 Pin #0': Sending state ON
[D][switch:021]: 'MCP23017 Pin #0' Toggling OFF.
[D][switch:037]: 'MCP23017 Pin #0': Sending state OFF
[D][switch:021]: 'MCP23017 Pin #0' Toggling ON.
[D][switch:037]: 'MCP23017 Pin #0': Sending state ON
[D][switch:021]: 'MCP23017 Pin #0' Toggling OFF.
[D][switch:037]: 'MCP23017 Pin #0': Sending state OFF
[D][switch:021]: 'MCP23017 Pin #0' Toggling ON.
[D][switch:037]: 'MCP23017 Pin #0': Sending state ON
[D][switch:021]: 'MCP23017 Pin #0' Toggling OFF.
[D][switch:037]: 'MCP23017 Pin #0': Sending state OFF
[D][switch:021]: 'MCP23017 Pin #0' Toggling ON.
[D][switch:037]: 'MCP23017 Pin #0': Sending state ON
[D][switch:021]: 'MCP23017 Pin #0' Toggling OFF.
[D][switch:037]: 'MCP23017 Pin #0': Sending state OFF

Additional information

No response

probot-esphome[bot] commented 2 years ago

Hey there @jesserockz, mind taking a look at this issue as it has been labeled with an integration (mcp23017) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

jesserockz commented 2 years ago

Hi @stefkamarton

As far as I can see, your YAML looks correct. And as you mention the tca9548a does work with another i2c device.

There is nothing special about how the mcp23017 sends the i2c messages as it just sends them to the bus, which in this case is the tca9548a which switches channel and then forwards the bytes on.

The only thing I can suggest for the moment is to change logging to VV:

logger:
  level: VERY_VERBOSE

as that will log all of the outgoing and incoming i2c bytes (including telling the tca9548a to switch channels.

I am unable to help further as I do not have a tca9548a to test with and I was assigned to this PR because of the mcp23017 which I know work as I use them personally.

Jesse