I found the docs for the MCP23017 as a GPIO expander while looking through the docs. I need a few more total pins than a normal ESP32 has between communications and GPIO so the expander seems perfect.
It seems to work in polling mode, but I can't seem to make it work in interrupt mode.
i2c:
- id: exp_bus
sda: GPIO05
scl: GPIO17
frequency: 100kHz
scan: true
mcp23017:
- id: 'mcp23017_hub'
i2c_id: exp_bus
address: 0x20
open_drain_interrupt: false
interrupt_pin: GPIO18
binary_sensor:
- platform: gpio
name: "MCP23017 Pin A0"
pin:
mcp23xxx: mcp23017_hub
number: 0
mode:
input: true
#pullup: true
inverted: true
interrupt: CHANGE
I'm supplying power to the MCP23017 with 3.3v so it's my understanding based on the docs that I don't need a pull-up resistor as I don't want/need to use open drain mode. But when configured this way the initial state of the GPIO on the A0 pin persists indefinitely no matter how much I change the input. It's the same for the rest of the pins but I left them out for brevity.
Looking at the build logs, I don't feel like this is a good sign:
INFO GPIO binary_sensor 'MCP23017 Pin A0': Pin is not an internal GPIO, falling back to polling mode.
INFO GPIO binary_sensor 'MCP23017 Pin A1': Pin is not an internal GPIO, falling back to polling mode.
INFO GPIO binary_sensor 'MCP23017 Pin A2': Pin is not an internal GPIO, falling back to polling mode.
INFO GPIO binary_sensor 'MCP23017 Pin A3': Pin is not an internal GPIO, falling back to polling mode.
INFO GPIO binary_sensor 'MCP23017 Pin A4': Pin is not an internal GPIO, falling back to polling mode.
INFO GPIO binary_sensor 'MCP23017 Pin A5': Pin is not an internal GPIO, falling back to polling mode.
INFO GPIO binary_sensor 'MCP23017 Pin A6': Pin is not an internal GPIO, falling back to polling mode.
INFO GPIO binary_sensor 'MCP23017 Pin A7': Pin is not an internal GPIO, falling back to polling mode.
But, when I look at the run logs I see something that's closer to right:
[08:33:33.973][C][mcp23017:039]: MCP23017:
[08:33:33.974][C][mcp23017:152]: Interrupt Pin: GPIO18
[08:33:34.015][C][gpio.binary_sensor:016]: GPIO Binary Sensor 'MCP23017 Pin A0'
[08:33:34.034][C][gpio.binary_sensor:152]: Pin: 0 via MCP23XXX
[08:33:34.035][C][gpio.binary_sensor:061]: Mode: polling
Maybe this should say Mode: interrupt since there's a way for it to be interrupt-able?
Did I miss something? Is the pull-up resistor required either way, even though I'm supplying 3.3v to the MCP23017? Any help is greatly appreciated.