Door sensor implementation in python


I am trying to implement a very simple door sensor (like the ones in this link which is monitored with a python script. I have found some examples for RPi but not for Jetson, so I have used a simple code using Jetson GPIO sampples( and I have connected the door sensor to pins 16(output) and 18(input)

However it does not work as output is very unstable and it does not recognizes properly the output. I am using a Jupyter Notebook and the printouts in the input pin do not make sense.

Is there any simple example on how to connect and manage this?



I can’t answer this due to no experience on this use case, may other developers to provide suggestions.

You may test those two pins at command shell.
GPIO 232 for PIN 16, GPIO15 for PIN 18

# echo 232 > /sys/class/gpio/export
# echo output >  /sys/class/gpio/gpio232/direction
# echo 1 > /sys/class/gpio/gpio232/value
# echo 0 > /sys/class/gpio/gpio232/value

I would recommend that you test voltage up and down first.