Mcp23017 as gpio input

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Mcp23017 as gpio input

#1 Post by waspie » 05 Nov 2017, 20:36

I'm trying to use the inputs on the mcp23107 to sense garage door proton. Previously i was using gpio pins on the esp but I'm trying to combine the function of a few controllers to 1 so i need the port expander. The switches run about 9vdc and I'm using a voltage divider with the exact same value. Low is 0v high is about 2.73vdc which was enough to change the state on the esp gpio pins but i get no response from the mcp.

Even when i jump the pin to 3.3v it does not change state. Can anybody help? Using esp mega

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Mcp23017 as gpio input

#2 Post by Shardan » 05 Nov 2017, 20:56

A bit more info would be nice, at least a screenshot of your ESPEasy configuration.
If you click the "Tool" tag and then I²C-Scan - is the MCP23017 shown in List?

Anyways: The MCP23017 has a reset pin (pin 18). This should be pulled to Vdd (pin 9) with a resistor 4.7 ... 10 KOhm.
If pin 18 is "low" the chip just doesn't show any reaction.

Regards
Shardan
Regards
Shardan

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: Mcp23017 as gpio input

#3 Post by waspie » 05 Nov 2017, 21:16

Yeah it shows up.
Screenshot_20171105-151234.png
Screenshot_20171105-151234.png (92.75 KiB) Viewed 7339 times
Screenshot_20171105-151222.png
Screenshot_20171105-151222.png (127.53 KiB) Viewed 7339 times
Reset is tied to 3.3 no resistor.

The A side outputs trigger a couple l293d chips and i get the desired response from that side.

The divider is gnd - 68k - mcp - 150k - 9vdc

Thanks for helping

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Mcp23017 as gpio input

#4 Post by Shardan » 05 Nov 2017, 21:50

Just for some testing:
Can you manually set the GPIO pin to low/high and see if you get a result?
I'm not sure to what the internal pull ups are set by ESPEasy, 68K/150K might be too high for the MCP23017 if an
internal pull up is set.

Regards
Shardan
Regards
Shardan

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: Mcp23017 as gpio input

#5 Post by waspie » 05 Nov 2017, 21:59

I tried grounding and 3.3v directly a bit ago with no response. I'll try on an empty pin and see what happens

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: Mcp23017 as gpio input

#6 Post by waspie » 05 Nov 2017, 22:02

Grounding an empty pin works. State changes to 0 then back to 1 when disconnected

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: Mcp23017 as gpio input

#7 Post by waspie » 06 Nov 2017, 00:45

Shardan wrote: 05 Nov 2017, 21:50 Just for some testing:
Can you manually set the GPIO pin to low/high and see if you get a result?
I'm not sure to what the internal pull ups are set by ESPEasy, 68K/150K might be too high for the MCP23017 if an
internal pull up is set.

Regards
Shardan
If i edit the plug-in is that something i can change or do i need to change resistors

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Mcp23017 as gpio input

#8 Post by Shardan » 06 Nov 2017, 12:16

Honestly i can't say if it is changeable by firmware - my programming knowledge is from last century literaly :oops:

For these purposes outside the house (or when machinery like pumps, motors or such are nearby) i'd prefer
a more protective way to convert down the level.
The schematic is shown in our Wiki: https://www.letscontrolit.com/wiki/inde ... _Converter
Scroll down to "precise unidirectional".

The resistor might have 330 Ohm...1KOhm, the Zener diode has 3.3V for direct connection to the ESP.
If your MCP23017 runs on 5V the ZD should have 4.7V

The advantage of this circuit: The voltage at the input pin of the ESP or MCP can not rise above the voltage of the ZD.

Regards
Shardan
Regards
Shardan

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Mcp23017 as gpio input

#9 Post by toffel969 » 06 Nov 2017, 19:14

Wow, who extended that part of the wiki so nicely? :ugeek:

Thanks shardan and grovkillen, you guys are awesome :!:
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Mcp23017 as gpio input

#10 Post by Shardan » 06 Nov 2017, 19:16

Grovkillen and me :oops:
All the "Basics" and some sensor parts of the wikie, revamped partly by grovkillen, partly by me.
Regards
Shardan

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Mcp23017 as gpio input

#11 Post by grovkillen » 06 Nov 2017, 19:36

Thanks for appreciating our work. :)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Mcp23017 as gpio input

#12 Post by Shardan » 06 Nov 2017, 19:41

+1
Regards
Shardan

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: Mcp23017 as gpio input

#13 Post by waspie » 06 Nov 2017, 20:46

all that aside :P thanks for the heads up on the pull down being too high.
i don't have any zeners handy so using a 10k as the pull down part of the divider i can now get the inputs pulled to ground rather than floating
unlike the esp gpios it seems there's no selectable pull down.

there's still a chance to kill the mcp23017, i know, but at least its in a socket so i can replace it and go to zeners if its ever an issue.
i ran it for a month straight to the esp without issue. here's to my continued luck

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests