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, cover the PIR sensor with something, so that it is not activated until you are ready.

Run the program as superuser using the command:

Download: file
sudo python

Uncover the PIR sensor and you should see a message saying 'POWER ON' and the little LED on the Powerswitch Tail should light, then turn itself off after 20 seconds.

Now this is all working, you can try attaching a lamp or some electrical appliance to the Powerswitch Tail.

Do not write code that turns the power on and off very rapidly. Many kinds of appliance, including lamps will be damaged by high frequency switching. This type of setup should turn things on for a few seconds minimum.
This guide was first published on Feb 18, 2013. It was last updated on Feb 18, 2013. This page (Configure and Test) was last updated on May 04, 2015.