Configure and Test

Let's put this file right in your home directory for simplicity. The wget command makes things easy as this can be run from an internet connected Raspberry Pi.

Download: file
    $ wget https://raw.githubusercontent.com/adafruit/Adafruit_Learning_System_Guides/master/Raspberry_Pi_Sensing_Movement/Raspberry_Pi_Sensing_Movement.py
  

Running the Code

To start with, place the magnet next to the switch and cover the PIR sensor with something.

Confirm that the Pi connected to the Cobbler (or Cobbler Plus) and run the script.

The following command will start the program:

Download: file
    $ sudo python3 ./Raspberry_Pi_Sensing_Movement.py 
  

..and you should see some trace appear in the terminal, when you move the magnet, or take the cover off the PIR sensor.

A good exercise might be to place your kids in-front of the PIR sensor and see how long they can keep still!

This guide was first published on Feb 13, 2013. It was last updated on Feb 13, 2013. This page (Configure and Test) was last updated on Jul 22, 2019.