Detecting wire contact

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ajocius
Posts: 83
Joined: Mon Feb 19, 2018 6:31 am

Detecting wire contact

Post by ajocius » Wed Feb 28, 2018 10:59 am

This might be very simple and that is why I do not find code example...

I have magnet based contact sensor, that has two wires. Those sensors are typically used to check if doors/windows are close. Has two wires and I measure resistance between them with multimeter. It is infinity when there is no contact and close to zero when sensor gets contact.

How do I check with MP code if sensor contact is ON or OFF? It is on ESP32 board that I am trying to sense it. Should I connect one wire to 3,3V and another to analog or digital port? or two digital ports? How can I detect sensor status in code?

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: Detecting wire contact

Post by cefn » Wed Feb 28, 2018 12:16 pm

Your reed switch magnet sensor is basically equivalent to a button, so you could follow this guide...

https://learn.adafruit.com/micropython- ... tal-inputs

Post Reply