Page 1 of 1

Simple switch help

Posted: 16 Jan 2017, 15:46
by dinki
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

Re: Simple switch help

Posted: 18 Jan 2017, 01:39
by paulymorph
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

Re: Simple switch help

Posted: 18 Jan 2017, 19:07
by dinki
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?

Re: Simple switch help

Posted: 21 Jan 2017, 03:14
by paulymorph
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.

Re: Simple switch help

Posted: 29 Jan 2017, 23:24
by dinki
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!

Re: Simple switch help

Posted: 30 Jan 2017, 01:24
by costo
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.

Re: Simple switch help

Posted: 11 Mar 2017, 19:29
by dinki
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?

Re: Simple switch help

Posted: 22 Mar 2017, 18:08
by toffel969
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.

Re: Simple switch help

Posted: 03 Apr 2017, 10:30
by jojocardee
closed but never open when the path is broken.
ดาวน์โหลด จีคลับ

Re: Simple switch help

Posted: 28 May 2018, 09:34
by TungstenE2
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

Re: Simple switch help

Posted: 28 May 2018, 22:39
by TD-er
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?

Re: Simple switch help

Posted: 29 May 2018, 17:36
by TungstenE2
strange, got it working now.

Internal PullUp: enabled
Inversed Logic: enabled