MCP23017 pin remap

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

MCP23017 pin remap

#1 Post by Smotek7 » 10 May 2023, 09:50

Hello,
I have a board with 2x MCP23017. In terms of hardware, the physical outputs are not very organized.
MCP23017 is already in the core.
Is there a way to remap it so that the pin numbers fit in the http command?
e.g
/control?cmd=MCPGPIO,1,0
to make GIPO 15
I don't mind that I will have to create a device or rules for each pin.
I have ESP32 or I have 32 devices.
I searched the forum but couldn't find it.
Thank you

TD-er
Core team member
Posts: 8754
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MCP23017 pin remap

#2 Post by TD-er » 10 May 2023, 10:39

Not sure I do understand what you're asking.

The mcp (and pcf) pins enumerate based on the set I2C address of the expander
See: https://espeasy.readthedocs.io/en/lates ... al-mcpgpio

If you need to simply have 'numbers' or 'labels' based on their purpose, instead of these non-informative numbers, you can transform it in rules.

Code: Select all

on switchBackDoorLight do
  // Pin 123 is the light at the backdoor
  mcpgpio,123,%eventvalue1%
endon
To set the pin to "1", you simply send an event like this:

Code: Select all

event,switchBackDoorLight=1

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 113 guests