Now that we know how a PIR sensors works, let's go ahead and hook it up with our BeagleBone board to detect motion.
First of all, take three berg wires and connect the PIR sensor to the BeagleBone board, as per the following circuit diagram:
As shown in the preceding circuit diagram, connect the PIR sensor's Vcc to the 5V pin on the BeagleBone board, the output pin of PIR to GPIO60 on the BeagleBone board, and the ground pins on both with each other.
Then, we will turn on the BeagleBone board and log in to the Linux shell to start coding it.
Create a new Python program using sudo nano TestPIR.py
:
Type in the code shown in the following screenshot:
Once you have typed in the code, you can go ahead and save it using Ctrl + X.
Have a look at the comments in the code to get an idea of how it works. We are setting up GPIO_60
as INPUT PIN
, reading the RISING edge from the output coming from the PIR sensor, and printing out text saying Movement Detected every time we...