My end goal is to have 8 outlets that I can turn off and on. This post will show you one outlet.
Parts List
- 4 Gang Plastic Electrical Box at Home Depot $4
- 15 Amp Outlet at Home Depot - $1
- 8 Channel Relay
- Power cord - had one laying around
- Arduino and some male to female wires
- Misc tools - Wire cutters, screw driver, etc
Helpful Article
There are tons of articles out there on how to hook up a relay to an Arduino, however it seemed most were lacking detail. I finally stumbled on this awesome article and was able to adapt it to the 8 Channel Relay: http://www.circuitbasics.com/build-an-arduino-controlled-power-outlet/
Specifically this image. I spent a ton of time trying to find something like this.
The pic above is what I ended up with.
- Hot wire (black) from power cord is wired to common (middle terminal) on the relay.
- Connect hot wire (black) into NO terminal of Relay and connect it to hot terminal (gold) on your outlet.
- Ground wire (green) from power cord connects to Ground (green screw) on outlet
- Neutral wire (white) from power cord connects to Neutral (silver screw) on outlet
- From Digital Out 7 on Arduino to IN1 on Relay module. IN1 is the first channel
- From VCC on Relay to 5V on Arduino
- From GND on Relay to GND on Arduino
You will want to make sure your connections look cleaner than the above screen shot. I went back and cleaned them up and added some electrical tape reduce the risk of a short and or shock.
Arduino Code
You can test the relay before adding the juice, to make sure your wiring is correct. This script will turn the relay on wait a little bit, then turn it off. It will cycle through like this in a loop so you can test it out.
From here you can get more advanced and trigger the relay based off other conditions such as sensor output, etc.
This is my first step towards working with Christmas light automation. I am also working on an Amazon Dash Party Button hack that I will blog about shortly.
0 comments:
Post a Comment