Configure and Test

There are lots of ways to get the sketch from the listing below onto your Raspberry Pi. Perhaps the easiest is to connect to your Pi using SSH (See Lesson 6) opening an editor using the command below:

Download: file

.. and then pasting in the code , before saving the files using CTRL-x.

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

Run the program as superuser using the command:

Download: file
sudo python

..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!

PIR sensors and the Pi 3 sometimes don't get along - if you're having false trigger reports, make sure the PIR Sensor is far away from the Pi 3
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 Jun 23, 2016.