Remove these ads by
Signing UpStep 1: Get all the parts
- An Arduino
- 4 standard wall outlets
- A four bay plastic outlet box for old construction
- An 8 channel relay board
- A three prong appliance cord
- A four bay outlet face plate, or the laser cut version attached (Red cut, Blue etch)
- 8 half inch #6 machine screws, 4 matching nuts
- 4 one and a half inch #4 machine screws with nuts and one inch nylon stand-offs
- Some wire, 10 female and male header pins, solder, etc.
Tools needed:
- A soldering iron
- A multimeter
- A drill
- A screwdriver
- Wire cutters
I got all the materials from Home Depot and Amazon. In total, it cost about $50.00 for all the parts.
This is a really simple project, but it does require experiences with drills and soldering. There are great tutorials on instructables for these tools if you do not already have these skills.
PLEASE NOTE: Working with AC power is dangerous. Don't hurt yourself, and don't blame me if you do.
arduinlay.pdf301 KB
















































Visit Our Store »
Go Pro Today »



Great technique , What is next??
- Phil
First, I don't note any electrical isolation between the outlet terminals and the back of the relay board. There is a potential for deadly 120v AC to arc across the gap, through the arduino, through your attached PC, and through YOU!
Add a non-conductive plastic/rubber barrier between outlets and relay board. Add a second one between relay board and Arduino. Better yet, figure a way to avoid having the Arduino inside the electrical box.
Second: You could turn your project into a DMX-controlled relay. Take a look at my instructable on just that subject.
http://www.instructables.com/id/DMX-Ardweeny-Node/
Best,
Michael
Kudos to all though - great ible, great comments
in response to the question of what to fuse, neutral or hot:
In regards to residential wiring code and best practices, you NEVER fuse or breaker the neutral.
Reasons for this are because:
1) If the fuse burns or breaker trips on the neutral side, the entire circuit is still live, meaning someone troubleshooting the circuit can be electrocuted by a seemingly dead circuit. (this is also why switches should always be on the hot side as well, you don't want to turn off a lamp and electrocute yourself changing the bulb - the shell will still be live if you switch the neutral rather than the live)
2) 2 prong appliances use the neutral as a ground because they are tied together in the main circuit panel. (ground is sort of a backup neutral)
3) If there is a short to an external ground (ie through the casing and into structure or people) the electrical path will bypass the fuse or breaker; meaning it won't stop the flow of electricity.
If the external path has enough resistance to keep the current flow below the main circuit breaker's amp rating, it also won't trip, causing electrocution and/or fires.
Always put fuses and breakers on the live(hot) side so that the entire circuit is dead when they blow.
i.e. Think of plumbing a sink, you don't put your cut off on the drain because that just stops the water from leaving the sink.
I know most transistors switch negative, but they are part of a logic circuit, not a safety device/circuit cut off.
Old school electricians used to "switch" the neutral. The best I could determine from talking to the old guys I learned from - the idea was to make the switch last longer. This was from early on in the days of "knob and tube" wiring when electricians were also working on radios and all other electronics.
At that time, the majority of trained electricians were trained in everything electrical and the rules were not separated as much as they are now.
"text" : "serial c 115200"
to
"text" : "serial g 115200"
and it is working now. I am still getting a doesn't understand "reset" message though.
If I try to change or set the port through MAX it stops working.
pin3 is $3 and $4
pin4 is $5 and $6
pin5 is $7 and $8
pin6 is $9 and $0
pin7 is $A and $B
pin8 is $C and $D
pin9 is $E and $F
I didn't write this sketch. I just made a few mods. All credit goes to the original author.
/*
Web Server Demo
thrown together by Randy Sarafan
Allows you to turn on and off an LED by entering different urls.
To turn it on:
http://your-IP-address/$1
To turn it off:
http://your-IP-address/$2
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Connect an LED to pin D2 and put it in series with a 220 ohm resistor to ground
Based almost entirely upon Web Server by Tom Igoe and David Mellis
Edit history:
created 18 Dec 2009
by David A. Mellis
modified 4 Sep 2010
by Tom Igoe
*/
#include <SPI.h>
#include <Ethernet.h>
boolean incoming = 0;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02 };
IPAddress ip(192,168,1,111); //<<< ENTER YOUR IP ADDRESS HERE!!!
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.begin(9600);
}
void loop()
{
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
//reads URL string from $ to first blank space
if(incoming && c == ' '){
incoming = 0;
}
if(c == '$'){
incoming = 1;
}
//Checks for the URL string $1 or $2
if(incoming == 1){
Serial.println(c);
if(c == '1'){
Serial.println("ON");
digitalWrite(2, HIGH);
}
if(c == '2'){
Serial.println("OFF");
digitalWrite(2, LOW);
}
if(c == '3'){
Serial.println("ON");
digitalWrite(3, HIGH);
}
if(c == '4'){
Serial.println("OFF");
digitalWrite(3, LOW);
}
if(c == '5'){
Serial.println("ON");
digitalWrite(4, HIGH);
}
if(c == '6'){
Serial.println("OFF");
digitalWrite(4, LOW);
}
if(c == '7'){
Serial.println("ON");
digitalWrite(5, HIGH);
}
if(c == '8'){
Serial.println("OFF");
digitalWrite(5, LOW);
}
if(c == '9'){
Serial.println("ON");
digitalWrite(6, HIGH);
}
if(c == '0'){
Serial.println("OFF");
digitalWrite(6, LOW);
}
if(c == 'A'){
Serial.println("ON");
digitalWrite(7, HIGH);
}
if(c == 'B'){
Serial.println("OFF");
digitalWrite(7, LOW);
}
if(c == 'C'){
Serial.println("ON");
digitalWrite(8, HIGH);
}
if(c == 'D'){
Serial.println("OFF");
digitalWrite(8, LOW);
}
if(c == 'E'){
Serial.println("ON");
digitalWrite(9, HIGH);
}
if(c == 'F'){
Serial.println("OFF");
digitalWrite(9, LOW);
}
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
}
Adding DMX wouldn't cost that much. Just a MAX485 or sn75176 chip for about $1, a cheap .1 uf cap, and a $5 5-pin XLR connector (though you could use something cheaper).
One cool thing to add would be an ethernet shield and use the arduino as a client.
jgmrequel ideas are also awesome!
Some mods I would suggest or add myself:
1. if you are going for light loads, add replaceable fuses to each outlet or pair of outlets. Heavy loads, maybe a circuit breaker blade. Not only is the protection good for human life, but it could also protect electronics and minimize part replacement if a circuit or relay gets overloaded.
2. I'm a fan of measurements - perhaps you can take a Kill-A-Watt and integrate it into the power input, measure how much power goes through your box, integrate it with the Arduino to send measurements back to the program (like with the Tweet a Watt, but without the wireless).
3. If you have the room, perhaps you can integrate the Arduino power supply into the box itself, drawing power when the box is plugged in (and giving one less cable coming out).
4. Add an LED to each outlet so you can see which is live without having to look at the computer screen.
5. Since you still have all those analog pins, perhaps a variation is to add swtiches to outlets and add ammeter circuits to your outlets so that the Arduino can monitor current draw - plug in your phone to a charger, push a button to switch on the outlet. The moment the current draw is steady state (over a minute or two) at the level the charger would be at without the phone, arduino switches the outlet off and sounds a notification itself to let you know its done.
(roots through parts bins, grabs 4 channel relay shield and small power strip, warms up soldering iron . . .)
You must remember, we are dealing with high tension wiring.
Thanks anyway, nice thought.
Another option is larger but still very industrial looking. Use two 4" double gang square boxes and a single/1 gang box joined with 1/2" X 3/4" long pipe nipples. Use the two square boxes to hold the receptacles and the single gang with a blank cover for the Arduino. Run stranded wire inside the boxes. The neat little push connectors are now widely available at the Home Centers (or Amazon) and are much easier and quicker than fooling with wire nuts for ganging your wires.
Option "B", although it wouldn't look as "cool," would be to add your Arduino to a large housing surge protector. That would give you surge protection as well as a UL approved housing, strain relief, a circuit breaker, and outlets spaced for some wall warts.
1. Im not sure what kinda loads your switching, but 18g wire is really way too small for line voltage apps. Especially since all your neutrals (colds) and grounds are wired in series.
2. Those screw terminals on outlets arent designed for more than one wire or for stranded wire. A better way would be to wire each outlet separately and then tie them all to the incoming line.
Finally FYI on those app cords the neutral or cold wire is marked by ribs on the insulation if its not already white.