MCP23017 GPIO PIN CONFIGURATION

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
vuhams
New user
Posts: 4
Joined: 08 Jun 2017, 10:07
Location: India

MCP23017 GPIO PIN CONFIGURATION

#1 Post by vuhams » 08 Jun 2017, 10:40

Hi,
MY DESIGN
In my project i used MCP23017 and i connected 8 switches from port 1 to 8, and i connected relay driver ULN2003 to drive 12v relay from the port 9 to 16. The hardware am using is ESP-12E with espeasy firmware 2.0.10 (latest). ESP-12E I2C is GPIO4 and GPIO5

PROBLEM
1. Relay connected with MCP will not respond as quick when i pressed the switch.

OBSERVATION
I checked the source of the firmware and came to a conclusion that, i have to configure 9-16 as OUTPUT.

REQUEST
So, I request everyone to help me
1. to configure MCP 1 - 8 PORT as INPUT and 9 to 16 as OUTPUT.
2. how to make MCP GPIOs respond as fast i press the switch

REFERENCES
ESPEASY Rules
On SW1#Switch=1 do
If [RL1#Switch]=1
mcpgpio,9,0
else
mcpgpio,9,1
Endif
Endon

On SW2#Switch=1 do
If [RL2#Switch]=1
mcpgpio,10,0
else
mcpgpio,10,1
Endif
Endon

On SW3#Switch=1 do
If [RL3#Switch]=1
mcpgpio,11,0
else
mcpgpio,11,1
Endif
Endon

On SW4#Switch=1 do
If [RL4#Switch]=1
mcpgpio,12,0
else
mcpgpio,12,1
Endif
Endon

On SW5#Switch=1 do
If [RL5#Switch]=1
mcpgpio,13,0
else
mcpgpio,13,1
Endif
Endon

//-END of RULES-

ESPEasy Devices

Task : 1
Device : Switch input - MCP23017
Name : SW1
Port : 1
GPIO: GPIO-4 GPIO-5
Values: Switch: 0

.
.

Task : 5
Device : Switch input - MCP23017
Name : SW5
Port : 5
GPIO: GPIO-4 GPIO-5
Values: Switch: 0

Task : 6
Device : Switch input - MCP23017
Name : RL1
Port : 9
GPIO: GPIO-4 GPIO-5
Values: Switch: 0

.
.

Task : 10
Device : Switch input - MCP23017
Name : RL1
Port : 13
GPIO: GPIO-4 GPIO-5
Values: Switch: 0

//-END OF DEVICE LIST-
___________________________
HAM Callsign: KD0NER

User avatar
budman1758
Normal user
Posts: 303
Joined: 15 Apr 2017, 05:13
Location: Riverside CA USA

Re: MCP23017 GPIO PIN CONFIGURATION

#2 Post by budman1758 » 09 Jun 2017, 08:38

Hello.
You do not need to define a task for the relay side of this unless you need to "read" the status of the relay. A task for the switch is enough to make it work. You will find yourself running out of tasks at 12 which is not enough for the MCP23017.

What kind of switch? Momentary or spst?
How long is it taking for the relay to react?
Are you also controlling the relays remotely?

I'm working on a project similar to yours using the MCP23017 also. Controlling remote lights with pushbutton switches and reaction time is at most a second or two. Works quite well.
"The glass is twice as big as it needs to be".

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 24 guests