Get the Code

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.

$ wget
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.

Running the Code

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

To start with, cover the PIR sensor with something, so that it is not activated until you are ready.

The following command will start the program:

$ sudo python3 ./ 

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.

This guide was first published on Feb 18, 2013. It was last updated on Jun 15, 2024.

This page (Configure and Test) was last updated on Mar 08, 2024.

Text editor powered by tinymce.