Instructables
Picture of Arduilay
Arduilay is an 8 channel AC relay box for use with Arduino, Max/MSP, Processing, etc.  I designed this system as an alternative to the USB>DMX 4 channel relay option.  While DMX gives you dimming control, the setup is easily 5 times as expensive as this simple relay box.
 
Remove these adsRemove these ads by Signing Up

Step 1: Get all the parts

Picture of Get all the parts
To make this relay box you will need:

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

Step 2: Snip the outlets

I wanted individual control of each outlet, versus both outlets being powered on at once.  To do this, you have to cut the tab between the GOLD screws on all the outlet pairs.  The GOLD screws are on the hot side, the SILVER screws are on the neutral side.  It should say this on the bottom of the outlet pair.Use your wire cutters to snip this tab.  You can use a multimeter to make sure the connection is broken.  The cold side tab can remain intact as we will be wiring them all together anyway.
1-40 of 60Next »
TerryKing7 months ago
Hi,
More technical information about this type relay board, and pointer to schematics
on the ArduinoInfo.Info WIKI HERE: http://arduino-info.wikispaces.com/ArduinoPower#4-8
redman887 months ago
how do you make the faceplate
JAnwyl7 months ago
How do you do step 6 with a larger wire?
KDodman JAnwyl7 months ago
If you look closely at what hes done in step 11, you will see he went to larger wire, and connected each relay with its own lead to the fuse. Other than that looks like everything else is the same
KDodman7 months ago
I have a question about fuses. I recently was using a setup much like this to run some aquarium equipment, one of my pumps died and blew the solid state relay it was on, caused a fire, of which we luckily got put out on time before the whole house went up. Anyways, my question about fuses, I am going to rebuild the system using your instructable, but I would like to add a fuse to every relay, would a PICO FAST 1.5A 125V AXIAL Fuse work.

I dont know a whole lot about fuses and breakers, so I've done abit of searching and it looks like a 65w 110ac pump would be around .5 amps. So I'm thinking a 1.5 would do just fine, as the SSRs I was using, also from sainsmart, are good for 2 amps. I'm sure not sure those little pico fuses would work, I picked them cause they look easy to use in a tight space.

If anyone out there has an opinion on weather or not this is a good idea I'd love the help.
ld33001 year ago
Great Project! Looks nice!
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).
trainwizard ld330010 months ago
How could it be turned into a DMX receiver using the MAX485 chip, .1 uf cap, and XLR connector? Would love to add that in myself!
ld3300 trainwizard10 months ago
Here is one example of coding: http://www.mathertel.de/Arduino/DMXSerial.aspx.
There are a few example of implementation online. You basically hook up the MAX485 TX to Arduino RX. Put the .1uf cap across the MAX485 chip VCC and GND. (I actually use the sn75176 typically, but have had problems getting the whole thing to work without this filtering cap. I have been surprised to not see it in DMX shield designs.) On the XLR connector pin 1 connects to ground, pin 2 connects to MAX485 pin 7, pin 3 to MAX485 pin 6. I also recommend making a terminating jumper that allows you to connect or disconnect a 120 ohm terminating resistor across pins 2 and 3.
Alderin ld33001 year ago
I'm in the parts-sourcing part of a project, and I can't believe how often the connectors and sockets are so significantly expensive compared to the actual electronics that plug into them. Atmega328p (Arduino processor) $2 each (25+), 28pin socket for it, $1 each. *boggle*
ld3300 Alderin1 year ago
It has been very frustrating. I find for just personal projects I often forgo the connectors and just solder things together or find another alternative. That is probably the primary reason why a lot of cheap DMX devices use 3 pin XLR instead of 5.
TheLui1 year ago
excellent instructable, quick question how hard would it be to integrate a meter to actually see how much power the AC Relay is using?
I'm working on a project that has monitoring capabilities using an ACS712 chip - https://www.sparkfun.com/products/8882. This outputs a DC voltage as a function of the current, which can be AC or DC. https://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf
mbmosher (author)  TheLui1 year ago
Don't know. Some one else suggested using a Kil-O-Watt for this purpose.
PeckLauros1 year ago
Excelent instructables!
pbates1231 year ago
mbmosher - Nice layout, clean wire dressing, solid mechanical layout - all excellent traits for a safe electrical project. I agree with your change to 14 gauge wire it should be used on every connection on the high voltage side(>20 volts). Also direct connecting your circuit to the AC Main coming from the wall could be problematic. A 10 amp fuse or circuit breaker is adviseable. Circuit breaker switches are also available which would provide a master on/off switch capablity as well. I suggested a 10 amp fuse because the weakest point in the circuit is the relays, the circuit board should have been designed to carry atleast that much current. The relays have a maximum current rating of 10 amps @ 250 volts written on top. I am not sure what you wish to switch however you should take care never to exceed 1200 watts (120 volts * 10 amps = 1200 watts) or actually about 10% less (as a safety margin) with what you plug in. Never exceed the maximum rating of the weakest part in your circuit.
Great technique , What is next??

- Phil
mbmosher (author)  pbates1231 year ago
Thanks for this - Based on everyone's feedback I've added a new Fuse step.
MBMosher, I like your work it is very clean and neat and I like that you used heat shrinkable tubing - very good. If you can find it a smaller fuse ie 10amps its much advised. Also since you used a fuse, fuses have different delays, blow rates, how long they will pass a given current before they blow open. A 10 amp slow blow fuse will not blow if there is a quick surge. Would be a good choice for your project. It will open if the surge lasts for more than a few hundred milliseconds in which case its likely something more than a surge or voltage spike. Great ible!
is there any way to connect multiple relay in connection to control more devices
mbmosher (author)  power Bills1 year ago
Given all the weird power situations it would probably be best to just make multiple realy boxes.
mmorlan621 year ago
Two really big notes:

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
Conventionally the silver "cold" terminals should be connected with white insulated wire, this side of the circuit is often referred to as the "neutral". Connect the green "grounding" terminals with bare wire or green insulated wire.
kudos to you sir. again as a matter of safety this is a great comment - if you mix up the hot and neutral, in some occasions you could end up with the frame of some device being hot even if it is turned off. and if by chance you happened to have also unwittingly fused or switched the nuetral side of the setup at any point (as was mentioned in an earlier comment)- you make increase the chances for a "shocking" lesson to be learned. ( i have found that you only have to learn it once however )

Kudos to all though - great ible, great comments

stresser1 year ago
for some reason the captcha isn't showing up on replies for me....

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.
I'll happily second that!

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.
mbmosher (author)  stresser1 year ago
Great info, thanks!
Gription1 year ago
I have tested my hardware with the blink sketch and changed the delays to 3000 and int led from 13 to 2 and then uploaded the sketch. I repeated this for pins 3-9 and they all turned the relays on and off every 3 seconds. So no problem with the hardware. I must assume my problem is with the software. I am using MAX runtime 6.0.8 and the arduinoMaxInOutforDummies.ino sketch from ArduinoMax-InOut-forDummies01. When I load your MAX file I see a message in the MAX window that says "specified port not available" then "doesn't understand "reset". I load the sketch on COM7 and when I re-select COM7 in MAX I see the same "specified port not available". Anyone have any ideas?
After some digging around I changed
"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.
mbmosher (author)  Gription1 year ago
Yeah, that's how you hard write in a serial port - the trouble is that sometimes they change. Are you using a leonardo or uno arduino? Make sure the arduino is connected to the computer via USB before launching Max; serial with Max can be finicky.
Gription1 year ago
Using the same hardware and an ethernet sheild I found and modified an ethernet sketch to control the relays. This sketh controls each rely with a specific URL. I have the IP set to 192.168.1.111. The URL for pin 2 is 192.168.1.111/$1 and 192.168.1.111/$2 to toggle it on or off.
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();
  }
}

Alderin1 year ago
Very cool! I don't care what you plan to control with 8 channels of light main power, it is completely cool! Lightshows spring to mind obviously, but for my end, I have servers that sometimes freeze up, and replacement budget is slow in coming, so I have to go and power-cycle them. Would be much handier to just send the command to the powerstrip. Thanks!
jml20091 year ago
Great project! Now I would like to make one myself:)

One cool thing to add would be an ethernet shield and use the arduino as a client.
jgmrequel ideas are also awesome!
jgmrequel1 year ago
Very cool project, these are the sorts of things that makes Instructables great.

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 . . .)
As a side note, I am also a fan of Kill-A-Watt and my local library has them on the shelf. Worth checking into if you only use it every month or so.
mbmosher (author)  lfahrney1 year ago
Where is your local library? That's awesome! LEDs are a great idea too, the only reason I didn't put them in was me not liking lots of wires, but I will probably put them in in the future.
mbmosher (author)  jgmrequel1 year ago
Thanks! Would that fuse go on the hot or neutral side?
Depends - if you want to just protect/limit that outlet, go on the hot leading to the outlet. If you want the entire box to disable at one fault, then the neutral side or the input hot side (though professional electricians might suggest one over the other). Personally, I'd do both, with low current (1~2amp) fuses on each outlet's hot, and a 20 Amp breaker on the input hot side to protect the entire thing as well act as a power switch.
mbmosher (author)  jgmrequel1 year ago
You could easily add an Arduino power supply to the box, and if you were doing an Arduino project this would be the way to go. The only reason I didn't put one in is because I will mostly be using it with Max, so I need the USB (or bluetooth/wifi) connection.
krakllc1 year ago
Very nice. If you can get your hands on some cheap fiber optic cable you can take advantage of the fact that the relay board has LEDs built in for each relay. You can glue the fiber optic cable to the LED and run the other end next to the outlet. I am planning on doing a similar project for a 12 volt dc setup in my truck.
marhar1 year ago
Very nice, thanks for posting. I learned a lot from people's comments as well.
dcastor1 year ago
I think you skipped a step...you didn't show how you connected the hot side of the power cable to the relays.
1-40 of 60Next »