Hardware Reference
In-Depth Information
Closed relay output as you can either change it later, or simply reverse the relay logic
by boolean inverting the GPIO.output second parameter.
Run a 16-gauge black copper wire to the common of each relay and tie them all to-
gether to the black wire of the power cord. Run another 16-gauge black copper wire
from the Normally Open (or only remaining connector if only two per relay) to each of
the brass screws on the outlets. You can use a metallic silver marker on the ends of
each of the black wires to indicate the channel number (1-4), so it will be easy to run
it to the correct outlet. Be sure to label the outlets so you later remember which one
is controlled by each channel.
Run a ground wire from the ground screw on each outlet (usually green) to the ground
wire of the power plug. Check your wiring to make sure it is correct with no loose or
frayed wires. Once you are sure everything looks good, screw the outlet into the box
and screw on the outlet box cover. If you are using this for control of outdoor lighting,
you should place the setup box in an area out of the elements, such as in a garage,
under a porch, or even inside the house, and then run the wires to each of the outlets.
Install the Software
First, install the GPIO control library and Python tools. Pidora includes python-
rpi.gpio by default, but you'll need to install python-devel manually:
$ su -c 'yum install python-devel'
On Raspbian, you'll need to install both python-rpi.gpio and python-devel :
$ sudo apt-get install python-dev
$ sudo apt-get install python-rpi.gpio
Then add the following code (which you can also download from this topic's GitHub
repository) to any directory:
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
DELAY = 1
#
# GPIO signals for the 4 relays
#
# Note that there are enough GPIO signals to control multiple
# 4-channel boards from the same RPi
#
# Name the channels and note of the colors of your wires for reference
Search WWH ::




Custom Search