Door sensor implementation in python

Hi,

I am trying to implement a very simple door sensor (like the ones in this link https://medium.com/conectric-networks/playing-with-raspberry-pi-door-sensor-fun-ab89ad499964) 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(https://github.com/NVIDIA/jetson-gpio) 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?

Regards,
Alberto

Hi,

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.