# Monitor dry door contacts in Raspberry pi/Node red

**URL:** <https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983>\
**Category:** General\
**Created:** [25 February 2022 14:35 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983 "2022-02-25T14:35:55Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![kvramji](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kvramji/32/59005_2.png) [@kvramji](https://discourse.nodered.org/u/kvramji)\
**Post date:** [25 February 2022 14:35 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/1 "2022-02-25T14:35:55Z")

</div>

I have been working on getting dry contacts into the pi and getting the status be displayed on Node red. But for some reason, i am not seeing the GPIO state stay high when the contact is closed. I have injected a 3.3V from an external board which is powered by 9V DC and dropped down to 3.3V with a LD111733 voltage regulator.

Checking with the multimeter, i can see that the wire which connects to the GPIO gets 3.3V constantly. But i see that the GPIO state keeps fluctuating between high and low as soon as i connect the wire to the GPIO.

Any help would be appreciated 🙂

---

<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:** [25 February 2022 15:45 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/2 "2022-02-25T15:45:50Z")

</div>

Have you got something like a 4.7k resistor down to 0v from the pin as a pulldown? It should be right at the pi to reduce pickup.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [25 February 2022 16:06 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/3 "2022-02-25T16:06:34Z")

</div>

@Colin's suggestion should be one of the first things you do in a live circuit. However, you can pull up or down as you want just to expand on that. If you are pulling down or up in a test, wiring directly to +V or GND, that should not be a factor. Though if you are using an external power source it can be a bit touchy to be sure that the ground plane is the same on the pi as well on whatever pwr source you use. Also, make sure you use a pin that is capable of input. The pi has some that are used for some exotic functions that don't lend themselves well to input. Try changing to a different pin and testing. FYI, I've hit that same problem before and changing pins seems to have always worked for me even when the pin appears to be a valid input.

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)\
**Post date:** [25 February 2022 20:55 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/4 "2022-02-25T20:55:04Z")

</div>

Turn gpio internal pull-up on and connect switch to ground.

---

<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:** [25 February 2022 22:14 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/5 "2022-02-25T22:14:10Z")

</div>

That is not advisable if it is being fed directly from a 3.3v supply with no series resistor. Also it is much better to use an external pullup/down of lower impedance.

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [25 February 2022 22:53 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/6 "2022-02-25T22:53:00Z")

</div>

How long are your wire runs? When we moved into the house circa 1980 I made a wired alarm system with CMOS logic, worked well until a severe thunderstorm destroyed it about six years later.

I rebuilt it with what might seem to be excessive input protection for the digital inputs, and did the logic with an old Rockwell AIM "FORTH" computer, which evolved to became an old IBM XT, and finally a Beaglebone in 2014, as I added features. All survived multiple thunderstorms and two hurricane direct hits.

If you are interested, I can post a photo of the hand drawn schematic of the input protection circuit, there is one on each input.

Simple pull-up/pull-down/series resistors are fine for "short" runs but if you get much over 50' in an area with frequent thunderstorms you will likely need better, to protect the digital inputs and prevent false triggers from transients.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [25 February 2022 23:13 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/7 "2022-02-25T23:13:25Z")

</div>

I'll agree with @wb666greene but if you are still on a breadboard it's probably not applicable. It's probably time to see what you got. Post a photo, draw a schematic but to provide further help we'll need more info.

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)\
**Post date:** [26 February 2022 06:21 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/8 "2022-02-26T06:21:44Z")

</div>

![gCQCL](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6f220febd8c207c2c294ab29945e210aff457459.gif)  
You can use PC817 or PC847 optocoupler.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [27 February 2022 16:53 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/9 "2022-02-27T16:53:12Z")

</div>

@wb666greene yes please post I would like to see what you did 😉

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [27 February 2022 16:59 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/10 "2022-02-27T16:59:44Z")

</div>

I have an alarm system running on wemos D1, it has no protection on inputs and has worked well for a couple of years. And while I see this would be a good option, it would be cheaper to just replace the ESP if it blew up 😉

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)\
**Post date:** [27 February 2022 22:42 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/11 "2022-02-27T22:42:33Z")

</div>

![s-l1600](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/1/41477b36dbbbf07f8f9c39d92bdfba38a23a33bd.jpeg)  
isolation voltage 5000V

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [27 February 2022 22:44 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/12 "2022-02-27T22:44:34Z")

</div>

![magnetic_switch_interface](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/c/7cf7f8a99ea540a14dbe249682880934d4311d3e.jpeg)

Originally the V+ was 5V, changed it to 3.3 when the computer changed from an old IBM-XT to the Beaglebone. Been running since the early 80s.

Blowing up the the system is not the only issue, transients just killing a DIO bit or two could give you a false sense that all was well when it wasn't.

Normally a bigger issue is electrical storms causing false alarms, any false alarm is unacceptable to me. The magnet switches on the doors get a lot of use, the ones on some windows only get "tested" about once a year for "spring cleaning" while other are opened and closed regularly for "fresh air".

Edit:  
The MOV is a "Metal Oxide Varistor"

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)\
**Post date:** [27 February 2022 23:02 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/13 "2022-02-27T23:02:34Z")

</div>

Thanks for sharing. Better use NC (Normally Closed) switch, because open long wires works as antenna and get signal from environment.

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [28 February 2022 15:40 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/14 "2022-02-28T15:40:09Z")

</div>

> [@iiot2k](#):
>
> Better use NC (Normally Closed) switch, because open long wires works as antenna and get signal from environment.

No you want a Normally Open switch because the magnet holds it closed until the door or window the magnet is attached to is opened, assuming the secure state is door or window closed.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [28 February 2022 16:57 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/15 "2022-02-28T16:57:50Z")

</div>

Just the usual confusion around what is considered as normal 🤪

# Definition of 'normally-open'

## normally-open in Electrical Engineering

(nɔrməli oʊpən)

adjective

(Electrical engineering: Circuits, Electrical power, Computing and control)

Normally-open [switch](https://www.collinsdictionary.com/dictionary/english/switch) [contacts](https://www.collinsdictionary.com/dictionary/english/contact) are in an open state at [rest](https://www.collinsdictionary.com/dictionary/english/rest).

---

<div class="post-metadata">

**Author:** ![kvramji](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kvramji/32/59005_2.png) [@kvramji](https://discourse.nodered.org/u/kvramji)\
**Post date:** [1 March 2022 05:18 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/16 "2022-03-01T05:18:00Z")

</div>

Wow, this community is awesome !  
To summarize what i have done, i did use the pull-up resistor feature of the GPIO pin node in node red and it seems to latch on to the state of the door. It works now as expected. @iiot2k thanks for your suggestion !

---

<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:** [15 March 2022 05:18 UTC](https://discourse.nodered.org/t/monitor-dry-door-contacts-in-raspberry-pi-node-red/58983/17 "2022-03-15T05:18:18Z")

</div>

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