Configure and Test

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.

Download: file
$ wget https://raw.githubusercontent.com/adafruit/Adafruit_Learning_System_Guides/master/Raspberry_Pi_Power_Control/Raspberry_Pi_Power_Control.py
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:

Download: file
$ sudo python3 ./Raspberry_Pi_Stepper_Motors.py 

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 Feb 18, 2013. This page (Configure and Test) was last updated on Jul 18, 2019.