Monitor dry door contacts in Raspberry pi/Node red

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 :slight_smile:

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.

@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.

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

1 Like

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.

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.

1 Like

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.

gCQCL
You can use PC817 or PC847 optocoupler.

1 Like

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

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 :wink:

1 Like


isolation voltage 5000V

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"

2 Likes

Thanks for sharing. 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.

Just the usual confusion around what is considered as normal :crazy_face:

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 contacts are in an open state at rest.

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 !

1 Like

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