# Best input device for open close

**URL:** <https://discourse.nodered.org/t/best-input-device-for-open-close/78927>\
**Category:** General\
**Created:** [3 June 2023 15:49 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927 "2023-06-03T15:49:28Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)\
**Post date:** [3 June 2023 15:49 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/1 "2023-06-03T15:49:28Z")

</div>

Hello All,

I need a device that I can input an open/close state of a relay. Could anyone please recommend one that is easy to use? Can be ethernet or wifi.

Hope everyone is having a great day!

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [3 June 2023 15:56 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/2 "2023-06-03T15:56:13Z")

</div>

ESP devices can do that easily and they are cheap. Soldering skills may be necessary

---

<div class="post-metadata">

**Author:** ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)\
**Post date:** [3 June 2023 16:02 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/3 "2023-06-03T16:02:39Z")

</div>

Cheers, soldering no problem. Will check them out now.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [3 June 2023 16:23 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/4 "2023-06-03T16:23:24Z")

</div>

As @krambriw said, ESP devices are inexpensive and can do a lot of things.

The ESP32-S2 Mini is very inexpensive and has lots of I/O pins, analog as well as PWM.  
Oh and yes - it is WiFi enabled. Recently I've been programming my devices using MictoPython.

> [@S2 Mini based on ESP32-S2 with the same footprint as the Wemos D1 Mini](https://discourse.nodered.org/t/s2-mini-based-on-esp32-s2-with-the-same-footprint-as-the-wemos-d1-mini/75389):
>
> Apologies to everyone as this post is not directly related to Node-RED. I know many people on the Forum use the Wemos D1 Mini in their projects to collect data and send it to Node-RED via MQTT, so you may be interested in hearing about this device... This is one example (click the purple coloured one) from the WinWin shop on AE. [https://www.aliexpress.us/item/2251832465432818.html?spm=a2g0o.productlist.main.1.30d22f11HxgyCp&algo\_pvid=7fd8b1e6-e2f2-4e2b-bcad-aba951d25af7&aem\_p4p\_detail=2023021…](https://www.aliexpress.us/item/2251832465432818.html?spm=a2g0o.productlist.main.1.30d22f11HxgyCp&algo_pvid=7fd8b1e6-e2f2-4e2b-bcad-aba951d25af7&aem_p4p_detail=202302150942354527169138296900007670003&algo_exp_id=7fd8b1e6-e2f2-4e2b-bcad-aba951d25af7-0&pdp_ext_f=%7B%22sku_id%22%3A%2266484777552%22%7D&pdp_npi=3%40dis%21GBP%211.79%211.47%21%21%21%21%21%402145279016764829553308802d06cb%2166484777552%21sea%21UK%211844326759&curPageLogUid=BtNio7niwzTz&ad_pvid=202302150942354527169138296900007670003_1&ad_pvid=202302150942354527169138296900007670003_1&gatewayAdapt=glo2usa4itemAdapt&_randl_shipto=US)

---

<div class="post-metadata">

**Author:** ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)\
**Post date:** [3 June 2023 16:46 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/5 "2023-06-03T16:46:49Z")

</div>

Cheers DynamicDave. After looking at the ESP32 I realised I have a raspberry pi sitting here doing nothing and looks like I could use that to send the message to node-red on my PC?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 June 2023 17:23 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/6 "2023-06-03T17:23:38Z")

</div>

Run node red on the pi as well and get the data to the pc using mqtt.  
Or even do everything on the pi and just run the browser on the pc.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [3 June 2023 17:25 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/7 "2023-06-03T17:25:04Z")

</div>

Well two things to consider...  
(1) Make sure your inputs to the RPi are within 0V to+3V3  
Put some resistors in there to limit the current/voltage.  
(2) ESP32s or ESP8266 can be deployed at various places around your home to sense and report conditions.  
They are much cheaper than a RPi - so if you destroy one, you won't get upset.  
Whereas, if you destroy a Pi you will be heart-broken (ha, ha, ha).

PS: The ESP32 and ESP8266 will support MQTT (so very easy to transfer data around).

Here's a link to a tutorial I wrote for my IoT students about using "buttons".  
[http://resources-area.co.uk/node-red-flows/having\_fun\_with\_buttons.pdf](http://resources-area.co.uk/node-red-flows/having_fun_with_buttons.pdf)

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [3 June 2023 20:34 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/8 "2023-06-03T20:34:52Z")

</div>

To put the Tasmota firmware inside the espxxxx you can use this easy way via an web page  
[https://tasmota.github.io/install/](https://tasmota.github.io/install/)

Or if you want to use the Esphome firmware, here is the link  
[https://web.esphome.io/](https://web.esphome.io/)

Both firmware can report gpio status via mqtt

There is also [Esplink](https://github.com/jeelabs/esp-link)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 June 2023 09:47 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/9 "2023-06-04T09:47:02Z")

</div>

> [@dynamicdave](#):
>
> Make sure your inputs to the RPi are within 0V to+3V3

That is correct.  
@btbr, you indicated that you have a relay contacts input, so presumably there are no volts on it. Connect one of the relay contacts to 0V on the Pi, and the other to a GPIO Input, with something like a 4k7 pullup resistor from the GPIO to the Pi 3.3V. You will probably have to use some debounce on the input so you don't get multiple events each time it closes. If I remember correctly the GPIO node can be configured to debounce it.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [5 June 2023 05:16 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/10 "2023-06-05T05:16:45Z")

</div>

> [@Jean-Luc](#):
>
> There is also

There is also [node-red-mcu](https://discourse.nodered.org/t/tutorial-read-a-sensor-by-running-a-node-red-flow-on-an-esp32-via-node-red-mcu/77171) if you want to run Node-RED flows on such devices...

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [5 June 2023 07:13 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/11 "2023-06-05T07:13:51Z")

</div>

Very clear instructions on it. Good to know. Thanks Bart

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [6 June 2023 06:51 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/12 "2023-06-06T06:51:20Z")

</div>

As @Colin mentioned above, it is normal practice to use some resistors to protect the input pins on your microcontroller. Here are examples of "Active-High" and "Active-Low" configurations.

![Active-High](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/1498a4bc4dbf8eb85f181dd56eadafba9bf5acc8.png)

 ![Active-Low](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d8169cfd0d510e6774d08939a4aa8b316ad2cf0.png)

Further information is on my website [Share\_My\_Projects](http://www.teamwork-int.com/share_my_projects/) - Remotely Controlled Station and check-out Appendix-E where there is a detailed description on connecting buttons/switches to a microcontroller.

---

<div class="post-metadata">

**Author:** ![markost](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@markost](https://discourse.nodered.org/u/markost)\
**Post date:** [6 June 2023 08:32 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/13 "2023-06-06T08:32:35Z")

</div>

Slightly strange terminology (for me),"Active HIGH Pull-Up circuit".

Input is Active HIGH,but with pull down resistor.

GPI(O)s are pull up/down with opposite activation.

---

<div class="post-metadata">

**Author:** ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)\
**Post date:** [6 June 2023 09:15 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/14 "2023-06-06T09:15:38Z")

</div>

Thank you very much for all your replies.

Got it working on a pi4 (nearly) using the GPIO node in node red. What a great node that is. I’ve got some 4.7k resisters here somewhere so will try that configuration as gpio juts going to ground at the mo.

Just need to set the mqtt output node (pi) and the mqtt input node (pc) correctly and it should all work.

I’ve set the node server addresses as the ip of the pi and pc respectively. Not working yet but think it might be a password issue. Looks like I can test with MQTT explorer on the pc. Will give it a try later.

Thanks again for all your help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 August 2023 09:16 UTC](https://discourse.nodered.org/t/best-input-device-for-open-close/78927/15 "2023-08-05T09:16:17Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
