Introduction: Arduilay

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.

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

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

Step 3: Wire the Grounds and Colds

Picture of Wire the Grounds and Colds

Cut yourself six 3inch lengths of wire.  I used 18 gauge wire, but 14 gauge would probably be better. Use at least 14gauge wire - I went back and rewired mine based on feedback in the comments.  Strip and bend each end into a C shape.  Use three of these wires to connect all the GREEN ground screw terminals, and the other three to Connect the SILVER neutral terminals.  Since we left the cold side tabs in tact, we only have to use one screw per outlet pair.  Use your multimeter to ensure that all the GREEN screws are connected and all the SILVER screws are connected (even the ones without wires).

Step 4: Add the Relay

Picture of Add the Relay

Now, cut 8 lengths of wire (about 4-6 inches depending on the outlet's position), strip the ends, and C shape one of them.  One C end goes to each of the 8 GOLD screws, so that each GOLD screw has its own wire.  The other strait end of the wire goes into the really array.  PLEASE NOTE:  In the photo I have it wired up wrong!  The wires should go into the MIDDLE terminal of each relay's 3 terminals, NOT the LEFT terminal.

Step 5: Mount Some Stuff

Picture of Mount Some Stuff

You can now mount the outlets to the faceplate with the #6 screws, and the relay array to the faceplate with the #4 screws.  Check to make sure you've got outlet one going to relay one and outlet two going to relay two, etc.

Step 6: Add the Relay Powers

Picture of Add the Relay Powers

Cut 7 one inch lengths of wire and strip the ends.  Make them into staple shapes and connect all the RIGHT relay terminals together.  They should all have two staple lets going into them except the first and last ones.  PLEASE NOTE:  I still have the GOLD screw wires wired wrong in these photos!  They should be going to the middle relay terminals.

Step 7: Put the Arduino in the Box

Picture of Put the Arduino in the Box

Line up the Arduino in the bottom of the outlet box.  Drill and 5/8 inch hole for the USB port and a 3/8 inch hold for the power jack in the side of the box.  I just did this by eye.  I ended up using 2 #2 machine screws to hold the Arduino in place, bit now the box is kind of wobbly due to the screw heads, so there may be a better solution, like using countersunk flat heads, or tape.

Step 8: Make This Funny Cable

Picture of Make This Funny Cable

Now you need a cable to connect the 10 relay pins to the Arduino.  This is a weird one.  We've got the 10 female headers all nice in a row, but the male headers split the first and last off and those get connected together.  This is the power and ground.  This cable gets plugged into pins 2-9 of the Arduino.  I use these pins because pins 0-1 are used for serial communication with Max/MSP.  Pay attention to how the cable connects to each device as it may need a twist to get 1 to 1 etc.  I use hot glue and tape to cover the exposed solder connections to prevent crossed wires.

Step 9: Add the Power Cable

Picture of Add the Power Cable

The power cable should be routed through the outlet box first.  The old construction boxes have built in strain relief ports on the bottom, you just jam the wire through.  Use one of the ports on the end of the box where the Arduino is NOT located.  This will give you some wiggle room when accessing the box internals.  Connect the GREEN wire to one of the GREEN outlet screws, the neutral wire to one of the SILVER screws and the hot wire to one of the power (staples) relay terminals.  If your hot / neutral cables are not labeled, the neutral wire connects to the larger of the two flat plug prongs.  Use your multimeter.

Step 10: UPDATE: Add a Fuse!

Picture of UPDATE:  Add a Fuse!

So after receiving so much excellent feedback from everyone I've made a few additions.  Get yourself a little fuse holder and and a fuse.  I'm using a 20amp 110v one because it's the only 110v variety my local hardware store had, though as people have noted a 10amp one may be better.  Wire this in on the hot (GOLD) side of the power cord before it gets to the relay board.  You can also see in this photo the upgrade to 14g wires and the splitting of each relay power wire to its own lead (versus the "staples" series used before).

Step 11: Close It Up

Picture of Close It Up

Use the remaining #6 screws and nuts to close up the box.

Step 12: Connecting to MAX

Picture of Connecting to MAX
Before you test out the AC get your Max and Arduino code set up.  

The Arduino code comes from the ArduinoMax_InOut_forDummies from the Arduino playground.  Just upload the included sketch from there.

Then you can connect whatever AC stuff you want.  

Max code is in the text file.


JessG714 (author)2017-10-29

Awsome ! Thank you! I did this wtih an esp8266 12e so i can control it with Alexa

sreeci (author)2013-01-17

While appreciating all the efforts you have taken to assemble this system, one must say that, additional explanations are lacking and errors are evident. You have also have not provided schematics, no information as to what you are trying to control, lacks info on Laser cut face plate and the video clip is not explanatory.
You must remember, we are dealing with high tension wiring.
Thanks anyway, nice thought.

Amarotica (author)sreeci2015-06-14

How is this high tension? You are getting home relay controls mixed up with the powerlines that go from Portland to San Francisco...

markbulla (author)Amarotica2017-09-12

In many places "high tension" refers to anything over 24vac.

PatS57 (author)2016-01-23

Did anyone actually try to build this with 14 AWG wire? I can't see any possible way to wire the "staple" jumpers with 14AWG. One wire barely fits in the socket, but two does not seem to be possible. Am I doing something wrong?

markbulla (author)PatS572017-09-12

Hello - I know that you posted this question quite a while ago, but in case you are still looking for an answer, I thought that I would post one. If you look at the rear of the outlets, you will see four small round holes. These are places that you can push in 14 ga. solid wires to make connections to the outlet, instead of, or in your case, in addition to using the screws. You can hook up one of the 14 ga. wires to the screw, and just push the other one into the hole (it won't let go unless you push a small screwdriver into the small rectangular hole right next to the round hole.


tycon4 (author)2016-11-14

Would I be able to use this with Christmas lights and the Vixen software instead of MAX? :)

charlessenf-gm (author)2016-05-22

FYI: There are three wires used in a 120Vac AC Circuit such as you would control. Ground, Neutral, and Hot (Power).

The color coding for the connecting wires is Green, White and Black. (In a 220VAC Circuit, power is also supplied via a Red wire and, often the Neutral is not present,

While the Neutral and Ground and not described as "Hot," neither is described as 'Cold.' If you were, indeed wiring all the SILVER connections together, these would be the Neutral connections and should be connected (joined, linked, etc) with a White insulated wire.

If you check the power cord you used, you may find there is a color-coded wire insulation for each of the three wires. On some power cords, one of the connectors is 'ribbed' linearly to define the Neutral conductor (or is it the Hot connector - got a meter handy?).

All in all an ambitious project and worth saving for future reference. I was impressed by the cover plate you made as well.

RichardW58 (author)2015-10-28

Thanx for this great posting. I plan on doing the same thing but with a raspberry pi. If I run into trouble I will hit you back.

aaronplazton (author)2015-09-28

Thanks, great instructable. I'm adapting some of what you did here for my own solution and have one question. What material are you using for the faceplate?

BAH. Answering my own question by reading further ("It is masonite surfaced on both sides.").

Amarotica (author)2015-06-14

Great project! Would like to know more about the coding of it if you could elaborate...

JonathanJordy (author)Amarotica2015-07-28

still need help in coding? maybe i can help you understand

transfamily142 (author)2015-04-01

hi . can you help me how we can load MAX . cn you show me please . thanks you Sir

foreveryung (author)2015-01-16

Why are you connecting the fuse leads to the right terminal, shouldn't it be the left terminal? If you connect it to the right then when the relay is off it will turn on the light and when the relay is on it will turn of the light. Is this correct?

nodoubtman (author)2014-12-22


where is located the power (staples) ?

thank you!


scooter.trash.562 (author)2014-12-12

Thanks for this! I'm an old guy fussing around with an Arduino. I took several years of electronics but had a brain fart when it came to hooking mains A/C into a relay.

You also unwittingly supported US veterans (not that I am one). I've already got a circuit built up for Xmas lights on a helicopter in front of the American Legion Post 127, Buford, GA. Just to show them what can be done, each rotor has separate strings of lights. In an hour or two I'll be making them alternately flash like they're moving. The vets will LOVE this.

nodoubtman (author)2014-12-04

the hot wire to one of the power (staples) relay terminals.

where is it?



drahz (author)2014-08-26

you missed the step where you add the ribon cable to the relay. I got this far and now I'm stuck.

TerryKing (author)2013-12-29

More technical information about this type relay board, and pointer to schematics
on the ArduinoInfo.Info WIKI HERE:

redman88 (author)2013-12-20

how do you make the faceplate

JAnwyl (author)2013-12-07

How do you do step 6 with a larger wire?

KDodman (author)JAnwyl2013-12-12

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

KDodman (author)2013-12-11

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.

ld3300 (author)2013-01-14

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 (author)ld33002013-10-01

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 (author)trainwizard2013-10-02

Here is one example of coding:
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 (author)ld33002013-01-18

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 (author)Alderin2013-01-19

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.

TheLui (author)2013-02-28

excellent instructable, quick question how hard would it be to integrate a meter to actually see how much power the AC Relay is using?

Sherman315 (author)TheLui2013-04-03

I'm working on a project that has monitoring capabilities using an ACS712 chip - This outputs a DC voltage as a function of the current, which can be AC or DC.

mbmosher (author)TheLui2013-03-02

Don't know. Some one else suggested using a Kil-O-Watt for this purpose.

PeckLauros (author)2013-03-06

Excelent instructables!

pbates123 (author)2013-01-23

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)pbates1232013-01-25

Thanks for this - Based on everyone's feedback I've added a new Fuse step.

pbates123 (author)mbmosher2013-01-26

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!

power Bills (author)2013-01-24

is there any way to connect multiple relay in connection to control more devices

mbmosher (author)power Bills2013-01-25

Given all the weird power situations it would probably be best to just make multiple realy boxes.

mmorlan62 (author)2013-01-24

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.



darkroommike (author)2013-01-18

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.

DB.Cooper (author)darkroommike2013-01-21

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

stresser (author)2013-01-18

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.

DB.Cooper (author)stresser2013-01-21

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)stresser2013-01-19

Great info, thanks!

Gription (author)2013-01-19

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?

Gription (author)Gription2013-01-19

After some digging around I changed
"text" : "serial c 115200"
"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)Gription2013-01-19

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.

Gription (author)2013-01-19

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 The URL for pin 2 is$1 and$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:

To turn it off:

* 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);

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 =;
        // 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){
          if(c == '1'){
            digitalWrite(2, HIGH);
          if(c == '2'){
            digitalWrite(2, LOW);
          if(c == '3'){
            digitalWrite(3, HIGH);
            if(c == '4'){
            digitalWrite(3, LOW);
          if(c == '5'){
            digitalWrite(4, HIGH);
          if(c == '6'){
            digitalWrite(4, LOW);
          if(c == '7'){
            digitalWrite(5, HIGH);
          if(c == '8'){
            digitalWrite(5, LOW);
          if(c == '9'){
            digitalWrite(6, HIGH);
          if(c == '0'){
            digitalWrite(6, LOW);
          if(c == 'A'){
            digitalWrite(7, HIGH);
          if(c == 'B'){
            digitalWrite(7, LOW);
          if(c == 'C'){
            digitalWrite(8, HIGH);
          if(c == 'D'){
            digitalWrite(8, LOW);
          if(c == 'E'){
            digitalWrite(9, HIGH);
          if(c == 'F'){
            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
    // close the connection:

Alderin (author)2013-01-18

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!

jml2009 (author)2013-01-18

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!

About This Instructable




More by mbmosher:ArduilayMindflex Duel Bluetooth Arduino FIO HackSolar Bike Stereo
Add instructable to: