1
\$\begingroup\$

I want to have a sensor to let me know if a door is locked or not. I've placed two wires inside the lock mechanism of the door, so when the door is locked the continuity test on the multimeter make a sound, if is unlocked it doesn't make a sound (no continuity).

I've tried to replicate that with a NodeMCU. I have follow the same example as a push button,

3V3 -> BUTON Pin 1 |-| Button Pin 2 -> 10k Ohms -> GND 
                                    -> D7 (Digital 7 GPIO)

schematic

simulate this circuit – Schematic created using CircuitLab

This works fine with the switch button, but when I replace the switch button with the wires on the door, nothing happen.

I checked the Ohms on both cases, the switch on rest have 10M Ohms, and when pressed have 0.4 Ohms.

The door when is closed have continuity with 16 Ohms, when is open it doesn't have anything (no continuity, no ohms, open circuit).

What I am missing here ? Another question, if a person touch the door (has metal on it) it can catch a spark or anything ? It's safe ?

The final goal is mimic the behaviour of the multimeter.

EDIT: Looks like some alligator cables I was using were in a bad shape. I've replaced but still it doesn't work. After checking everything and trying again, it is WORKING!

I will try to start solder some cable to proper connect each other without using alligators.

Video with this working: https://youtu.be/a3UFyRAJedA Cables: https://imgur.com/a/2ByPSY6

\$\endgroup\$
  • \$\begingroup\$ What's the voltage between D7 and ground when the door is open and closed? Is there any other connection to the metal door? What's the power source? \$\endgroup\$ – user253751 Sep 18 '18 at 23:39
  • \$\begingroup\$ What do you mean by "when is open don't anything"? Is the resistance infinite or zero? Did connect both wires from the door to the NodeMCU? What voltages do you measure at pin 7 with the pushbutton? With the door? \$\endgroup\$ – Elliot Alderson Sep 18 '18 at 23:39
  • \$\begingroup\$ @immibis 0.678v in both cases. I am powering the NodeMCU (3.3V) with a power bank for now. \$\endgroup\$ – David Magalhães Sep 18 '18 at 23:52
  • \$\begingroup\$ @ElliotAlderson I've fixed the test. When is closed, there is continuity with 16 Ohms. When it's open don't exists anything. With the push button I have 0.674v when not pressed, and 3.24v when pressed. So the door is create to much resistance for the voltage to flow ? \$\endgroup\$ – David Magalhães Sep 18 '18 at 23:52
  • 1
    \$\begingroup\$ @DavidMagalhães if you'd like you can use a magnetic reed switch which would be the typical solution for this type of door security. They are simple and relatively inexpensive. \$\endgroup\$ – K H Sep 19 '18 at 1:23
1
\$\begingroup\$

Based on what you explained, it should work. Two wires touching is the same as a push button. 16 Ohms may not be a good connection for carrying a load, but a GPIO like this is not affected by that. The voltage divider created by this would put 3.29V at the GPIO, enough to trigger the pin as high/on/1.

So the only thing we can assume is that either there is a physical issue, or the issue is in your code.

You say With the push button I have 0.674v when not pressed, and 3.24v when pressed. I suspect you have the internal pull-up enabled. Try disabling it. You have an external pull-down, so you they can conflict.

Update: Based on OP's comment, it was (likely) a bad physical connection.

\$\endgroup\$
  • \$\begingroup\$ It isn't simple 2 wires touching. The two wires touch the metal on the door, and that makes the continuity. I will check on the internal pull up. \$\endgroup\$ – David Magalhães Sep 19 '18 at 0:29
  • 1
    \$\begingroup\$ @DavidMagalhães I strongly recommend you to replace your "two wires touching metal" with microswitch like this one \$\endgroup\$ – Maple Sep 19 '18 at 0:51
0
\$\begingroup\$

Since you get the same voltage (0.674V) with the door open and with the door closed, but with the button pressed you get about 3.3V, my bet is that the door isn't wired correctly. Double check all the connections. Make sure you test the wiring from the circuit board to the door and back again (it should measure not many ohms).

Another question, if a person touch the door (has metal on it) it can catch a spark or anything ? It's safe ?

Yes, if it's battery powered then it's safe for sure, as far as electric shocks are concerned. Batteries can explode if short circuited but that's a different matter. If your power bank is good quality it will have some sort of electronic circuit breaker in it, so it won't explode.

If it was mains powered, if your power source is safe then it's still safe. I've heard that some power supplies can have problems with static build-up or leakage current (not dangerous amounts), in which case it might help to ground the circuit.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.