Simple switch help

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
dinki
Normal user
Posts: 11
Joined: 17 Aug 2016, 20:04

Simple switch help

#1 Post by dinki » 16 Jan 2017, 15:46

Guys, can someone point me to a schematic for connecting a simple switch (I want to use a reed switch) and how to configure it? Do I just connect one side of the switch to GPIO and the other to ground? Do I need to set up the GPIO as an input? Do I need invert/pull up enabled?

I've played with this a while and I just can't get it working. I've made a few temp/humidity nodes but I am having a world of problems with what I thought would be simple. Any help is GREATLY appreciated! Thanks

paulymorph
New user
Posts: 8
Joined: 13 Jun 2016, 05:24

Re: Simple switch help

#2 Post by paulymorph » 18 Jan 2017, 01:39

I've set this up with a reed switch. Here's my settings page from the ESPeasy.

http://imgur.com/a/OKmSO

I have it set up to send MQTT messages to my broker so when i bring a magnet close to the switch, it closes and fires an MQTT message to my broker and another when I pull the magnet back.

That may/may not help you depending on what you're trying to do...

Hope this helps

dinki
Normal user
Posts: 11
Joined: 17 Aug 2016, 20:04

Re: Simple switch help

#3 Post by dinki » 18 Jan 2017, 19:07

paulymorph wrote:I've set this up with a reed switch. Here's my settings page from the ESPeasy.

http://imgur.com/a/OKmSO

I have it set up to send MQTT messages to my broker so when i bring a magnet close to the switch, it closes and fires an MQTT message to my broker and another when I pull the magnet back.

That may/may not help you depending on what you're trying to do...

Hope this helps

Thank you for this. Can you tell me how you have the switch wired? I know one side is going to the GPIO pin, but the other is connected to ground?

paulymorph
New user
Posts: 8
Joined: 13 Jun 2016, 05:24

Re: Simple switch help

#4 Post by paulymorph » 21 Jan 2017, 03:14

Correct. One side to whichever GPIO pin you choose, the other to ground. It's just completing the circuit when the reed switch closes when the magnet gets close to the switch.

dinki
Normal user
Posts: 11
Joined: 17 Aug 2016, 20:04

Re: Simple switch help

#5 Post by dinki » 29 Jan 2017, 23:24

I'm thoroughly confused! I've got a node mcu and I can get it to read GPIO16 as a switch by connecting that pin (D0) to ground. It will show a 1 for the switch value. I cannot get this to work for any other pin other than GPIO16! Any idea what is going on?

Also, GPIO pins 1,3,4,5 are all greyed out and I cannot select them as input. Why is this so? Any help is most appreciated!

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Simple switch help

#6 Post by costo » 30 Jan 2017, 01:24

dinki wrote:I'm thoroughly confused! I've got a node mcu and I can get it to read GPIO16 as a switch by connecting that pin (D0) to ground. It will show a 1 for the switch value. I cannot get this to work for any other pin other than GPIO16! Any idea what is going on?

Also, GPIO pins 1,3,4,5 are all greyed out and I cannot select them as input. Why is this so? Any help is most appreciated!
GPIO 1&3 are used for TX-RX. If you go to Tools-Advanced and remove the mark at Enable Serial Port, this will disable the Serial Port and enable the use of gpio 1&3 for other uses.

You have gpio4&5 probably reserved for I2C bus. If you remove the gpio for SDA and SCL in the hardware page this will free these gpio´s for other uses.

dinki
Normal user
Posts: 11
Joined: 17 Aug 2016, 20:04

Re: Simple switch help

#7 Post by dinki » 11 Mar 2017, 19:29

I'm back at this and still confused. Shouldn't I be able to use all available GPIO pins as inputs? I've removed the reservations for serial communications and i2c and freed those pins. Unfortunately I've found that only some of them work as inputs as when I connect them to ground most do nothing and some will show that the switch is closed but never open when the path is broken.

I really don't understand. I'm using a nodemcu esp12 with a ton of pins. I need five of them as simple inputs for my reed switch contacts and I cannot get five reliable ones out of all these pins. What could I be doing wrong?

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

Re: Simple switch help

#8 Post by toffel969 » 22 Mar 2017, 18:08

Did you activate the pullup-resistors? I have a setup with 8 working input pins, so its definitly possible. Are you refreshing the webpage as you are checking if input state changed? because it will not change unless you refresh.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

jojocardee
New user
Posts: 5
Joined: 31 Mar 2017, 05:42

Re: Simple switch help

#9 Post by jojocardee » 03 Apr 2017, 10:30

closed but never open when the path is broken.
ดาวน์โหลด จีคลับ

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: Simple switch help

#10 Post by TungstenE2 » 28 May 2018, 09:34

Hi all,

same problem here. I am on the latest mega build.

Trying to connect a reed switch. None of the GPIOs I have tried are changing state. Also did a page refresh.
Tried several setting combinations. Reed is working, tested with multimeter.

Any idea how to get this working? PIR was working before with no problem.

thx

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

Re: Simple switch help

#11 Post by TD-er » 28 May 2018, 22:39

TungstenE2 wrote: 28 May 2018, 09:34 Hi all,

same problem here. I am on the latest mega build.

Trying to connect a reed switch. None of the GPIOs I have tried are changing state. Also did a page refresh.
Tried several setting combinations. Reed is working, tested with multimeter.

Any idea how to get this working? PIR was working before with no problem.

thx
Do you pull-up the GPIO pin connected to the reed switch?
And is it connected between the GPIO pin and GND?

TungstenE2
Normal user
Posts: 123
Joined: 03 Apr 2018, 21:46

Re: Simple switch help

#12 Post by TungstenE2 » 29 May 2018, 17:36

strange, got it working now.

Internal PullUp: enabled
Inversed Logic: enabled

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 37 guests