give your Arduino a 120 volt kick in the pants!

The Arduino is a great tool for anyone interested in learning microcontroller programming, but after blinking some LEDs, what's next? This project enables your Arduino to control real-world 120 Volt electrical appliances you have in your home.

what can you use a plugduino for?

Well, its great for Halloween prop controller to automate your lasers, fog machines, fans and such in an intelligent way. You can use beam breaks, contact pads, distance sensors, and so on to control up to 4 devices independently or in unison to make a unique experience.

But you can also use in the house to control appliances based on sensors such as temperature, humidity, motion, light, and so on to open curtains, turn on lights, fans based on environmental conditions. You can also use it for more whimsical things like sign marquees, animated Christmas light lights, super sized Simon game, and anything that takes input, runs program logic, and controls 120V devices.

plugduino is a smart relay controller

which means that you can write a program that determines how each of the four electrical outlets are turned on or off, and in addition supply up to 4 inputs into the logic to interface it to the outside world. As a simple example, you can make a sequencer for the lights with a speed control simply by connecting a potentiometer to one of the inputs and using its value to control the sequencing speed.

Step 1: Lets Pop It Open!

Inside the plugduino you'll find just a few basic bits that are wired together to make the magic happen. The real mojo in the plugduino comes from the combination of an Arduino microcontroller and a SeedStudio V2.0 Relay Shield; the rest of the stuff is just wiring and connectors.

warning: working on 120V circuits can be dangerous and potentially lethal
make sure you know what you are doing and proceed carefully!


Because this project involves house wiring, follow the instructions carefully to ensure a safe build and always test and operate the device with a safety fuse. With the proper use of rated terminal strips, shrink tubing, wiring, and safety procedures, you can build this project safely, but always be aware that the risk of electrical shock is present!

The power circuit consists of a 3 prong power plug, fuse, terminal strip, and two dual outlets. The four red wires between each outlet and the control board provide the switching circuit. Note that this circuit is physically isolated from the rest of the wiring.

The control circuit consists of an Arduino Uno, a SeedStudio V2.0 relay shield, and a skinned 12V power wall wart. The program running on the Arduino reads sensor input and controls the status of the relays on the Relay Shield and hence the outlets. The control board is mounted onto a section of perfboard, and fastened to the bottom of the cabinet using nut/bolt/spacers.

The sensor input terminals support four sets of analog inputs to the Arduino to provide for switches, potentiometers, and the like. Depending on your needs, you could connect these terminals to whatever inputs ( analog and/or digital ) as you see fit. You could also use different connectors that might better suit your application, such as terminal posts, ribbon connector, etc.

The I/O status indicators display which outlets have power applied to them, and which inputs are generating an input value. The indicators are separated into two groups of input and output. In this project, white LEDs are used to display output status, and green LEDs are used to display input status.

The cabinet is a standard plastic and aluminum project box with contact paper applied to the front panel for aesthetics.

Step 3: Power Circuit Schematic

the power circuit  consists of a 120V 3 prong outlet cord,  fuse housing and fuse, switch, terminal block, control circuit power supply, and duplex outlets. The interface between the power circuit and the control circuit is the job of the Relay Shield, which contains both high and low power connections.

The power circuit connects the 120V power plug to both the low voltage power supply ( via neutral and hot ), and to the outlets through the switches on the Relay Shield (via neutral ). The outlets share both ground and hot connections completing the circuit.

the fuse must be used in any house powered circuit even  with the use of a grounded connection such as this. The fuse is used to protect from current overload primarily caused by the devices that are plugged into the outlets. We recommend using a 7A 250V fuse to stay well within the load limits of the relays on the shield.

the terminal block provides a clean connection between the input circuit and the high power circuitry in the cabinet. The idea is to minimize exposed contact to the supply. By using shrink tubing on all remaining connections the terminal block is the only point of contact between the mains supply and the device.

the power supply powers the Arduino and Relay Shield at 12 Volts DC. The power supply uses a transformer to create a separate isolated low voltage circuit. This low voltage circuit provides power for the microprocessor, the relay coils, the LEDs, and serves the reference circuit for sensor input.

the outlet block connects to the switch contacts on the Relay Shield (  rated at 10A @ 250V ) to the 120 volt power source. Using the recommended 7 amp fuse, the total load on all the outputs is 120V * 7A ~ 800 watts. This load should be sufficient for most lighting applications, but be careful to check power ratings when using power hungry devices such as fog machines and fans.

Step 4: Control Circuit Schematic

the control circuit consists of the sensor input connector, the Arduino, the status LEDs, and the low power side of the Relay Shield. The schematic shown here displays input / output / status for one channel since all 4 channels are wired identically. The pins used on the control circuit boards are 5V, GND(1), GND(2), A0, A1, A2, A3, D3, D4, D5, D6, D7, D9, D10, and D11. In addition to this, pins D0 and D1 are used to program the Arduino.

the sensor inputs are connected to the analog inputs on the Arduino board ( A0, A1, A2, A3 ). The input voltages on these pins are converted into a 10 bit integer value such that the range between 0V and 5V and translated into a value between 0 and 1023 respectively. The ideal connector thus contains 3 inputs per sensor ( 5V, GND, A ) resulting in 12 connection points.

the sensor status indicators provide a way to see the analog values that are being used on the front panel, which can be very useful in determining how the controller logic is working. We are using white LEDs here to provide that feedback. The program running on the Arduino simply reads the analog sensor values, and outputs those values to respective LEDs using the PWM output pins D3, D9, D10, and D11. The PWM output has 8 bit resolution and therefore has 1/4th the resolution of the actual input.

control status indicators indicate which relays (and hence which outlets) are energized and provide a look at how the controller logic is working and to help debug device operation. The pins D4, D5, D6, and D7 are connected between the Arduino and the Relay Shield (via header) to energize the relays; this part of the circuit simply taps those pins to light up the green LEDs.

Step 5: Strip the Brick

the power supply is a tap off the 120VAC line to provide power to the low voltage circuitry. You could power the Arduino from either the USB port connected to a PC, or through an external power such as a 9V battery, but since you already will be using 120V power for the device, it is more convenient to include it into the build. The cheapest way to provide a power supply to the control circuit is to simply strip open a standard wall wart power supply and mount it into the control board as pictured here.

check the specs, as you want to make sure that your supply is up to the job. The Arduino, Relay Shield, and LEDs can be powered  by as little as 5V, but we recommend 9-12 V and at least 500 mA to ensure reliable and long lasting operation. Also make sure that the power supply output is 9-12V DC, not AC. In this picture you can see this wall wart supply consists of a transformer, rectifier bridge, and filter capacitors; all of these are needed to supply a decent DC supply. If possible, test your supply before you strip it down - if you are buying a new supply look for one with the 2.5mm jack compatible with the Arduino board and plug it in to ensure it works; you can also use the jack in the final construction.

grip it and strip it. but be careful! The way you strip the case from the supply may vary, but we recommend you take care using a Dremmel or other small cutting tool to pry the case from the supply by first scoring the seams. In the example here, the supply had the two prongs connected via the red wires to the supply, and the two white wires to the connector. Once the case was open slightly, it was easy to cut the wires and then remove the rest of the skin.

Step 6: Build the Control Circuit Board

1. fit the perfboard by cutting it to the width of the inside of the enclosure. Note the clearance available and locate the board in the place where it has the most room. We recommend mounting the board to the bottom of the enclosure to ensure the most vertical clearance, but you may also find you can place the board by slotting into the enclosure if it gives you more room. Perfboard is very easy to work with and trim to fit by marking the cut line and snipping it off with wire cutters or using a hack saw.

2. layout the parts on the board and mark their location and mounting holes. In the this picture you can see a traced outline of the parts on the board. Give yourself at least a 1/4" space around the edges of the board to allow for mounting the board to the enclosure.

3. secure the parts to the board as you see fit. In this case, the power supply was glued to the perfboard using a thin layer of Gorilla Glue, and then locked into place using two zip ties pulled through holes drilled on the perfboard. The Arduino was secured by placing it on a semi-rigid insulated foam pad, and then holes were drilled through the pad and perfboard to align with the holes on the Arduino.

4. solder the low power wires that connect the power supply to the Arduino using the connector. Make sure to check polarity before plugging into the Arduino by marking the cable before cutting. Remove the original low power wires from the board by heating them with a soldering iron and pulling them out. It can be useful to use a solder vacuum tool to clean the holes more easily. Cut the cable to length and solder it into the original holes; in this way there are no open connections between the supply board and the Arduino. To help keep things secured you can tie small wire twists around the cable as you see in the picture.

5. solder the hi power wires using the 20 gauge wire, giving yourself approximately 12" of length on each. First strip all of the wires and solder two lines together using a braid to minimize the lump between the wires. Trim the wires and slide a section of heat shrink tubing down to the solder joint. Apply heat with a heat gun or blow dryer until the tubing shrinks tightly onto the connection. If you are new to doing this process, it is not difficult but you might want to practice the solder and shrink technique on some scrap wire until you are confident you can do it properly - it is very important to do this to ensure safe operation.

Step 7: Install Power Components

1. locate and mark holes for the power cable, fuse holder, switch, and terminal block. Start by finding the best entry location for the cable; you want this fit to be as tight as possible. In this case, our cable came with a rectangular grommet that we located near the top of the enclosure. If you do not have a grommet, you can find one at most hardware stores that will fit your power cable. If you choose not to use a grommet, make sure you tie a knot inside the cabinet.The power cable must be solidly secured to the enclosure to ensure it wont be yanked out or cause a short when pulled. Take some time to make sure this is done right.

The location of the fuse and terminal block should be selected such that the wiring from the cable can reach without having to splice the wire. Note int this example how the ground (green) and neutral (white) wires reach the terminal block, and the hot wire (black) reaches the fuse holder. It is important to make sure there are no exposed solder connections.

2. drill holes and mount the parts into the cabinet. The recommended 4" x 6" cabinet provides enough room that the soldering can be done after the parts are mounted. Make sure to tighten down all the parts with tools so that they will not work loose. If possible use lock washers to ensure things stay tight.

3. wire the supply side connections. Start by soldering the cord hot wire (black) to the fuse connector, including a section of shrink tubing on the wire. Once soldered and trimmed, slide the tubing down the wire onto the solder tab and shrink it onto the tab. Next, measure and cut some black 20 gauge wire between the open tab on the fuse connector and an open tab on the switch. Cut two sections of shrink tubing and slide onto the wire, then solder and seal as you did with the other fuse connection. Complete the hot supply side connection by soldering in another wire with shrink tubing to the other switch tab and the terminal block. On the terminal block side strip the wire approximately 1/4" and screw into the terminal making sure all the stripped wire is in under the screw with no excess wire sticking out.

To connect the ground and neutral wires, strip them each to 1/4" and attach to the bottom of the terminal block using care to make sure they leave no exposed wire. Note in the picture that all three power wires are connected firmly but cleanly to the bottom of the terminal block. All connections from the project will use the top screws. It is very important to make sure to double check your wiring here so that the only exposed electrical connections are at the terminal block.

Step 8: Install Sensor Connector

1. mark and drill holes on the right side of the cabinet to secure the connectors. Some connectors may require glue or nut/bolt sets to hold the connector. Make sure that there is enough clearance between the terminal tabs and the control board and the top of the case, where the LED circuits will be created.

2. mount the connectors. In most cases you will want to mount the connectors before soldering. The exception is if the connector tabs are not long enough to pass through the holes on the enclosure, in which case you should swap this step with the next one.

3. solder wires to the connector tabs. All of the ground connections can be wired together in a daisy chain fashion resulting in a single ground wire. Likewise all of the +5V connections can be wired together resulting in a single +5V wire. Each of the input connectors should be wired separately, resulting in a total of 6 wires ( GND, 5V, A0, A1, A2, A3 ). You can use 30 gauge wire cut approximately 6" to reach the control board.

Step 9: Build the Front Panel

1. fit the outlet extender using a hacksaw or Dremmel tool. The enclosure from RadioShack used for this project contains both a plastic and metal panel. We recommend using the metal panel as it is stronger and better suited for handling the stress forces of the receptacles. Start by tracing the outline of the outlet wall box extender ( here in orange ). Carefully cut the hole to fit the extender making sure to leave material to secure the extender to the panel using 4 nut/bolt sets. In most cases the extender box will use the same holes as the outlet cover plate, so we'll mount the outlets before we secure the extender.

2. prepare the outlets by making each outlet have its own hot connection. Each duplex receptacle has 5 sets of screws - one for ground (in the corner), two for hot (brass colored) usually on the right side , and two neural (silver colored) usually on the left side. Take a minute to verify which connections are which - outlets may vary by design but all will be marked on the case.

By default, the two screw connections for hot are connected together with a tab between them. Likewise, the two neutral screw connections are also connected together was well. We wan to keep the neutral (silver) connections connected, but break the tab between the hot (brass) connections. you can do this easily by taking a pair of pliers and bending the tab back and forth until it breaks off.

3. wire the outlets. By cutting 6 12" sections of 20 gauge wire ( 1 black, 1 green, 4 red ) we can create a wire harness between the front panel and the control board. As per the schematic, we will wire all the neutral connections together; this is illustrated on the picture here as the black wire. Note how the first outlet hot connector (brass) is tied to the black wire, and then another short black wire connects it to the neutral connection on the other outlet. Since they are connected by the tab, all outlets have neutral connections. Similarly the ground wire (green) is connected tot he first outlet and a short wire is used to connect it to the second. Finally, each of the hot wires (red) are connected and marked as to which outlet they belong to. The wires are zip tied to keep the harness clean.

4. drill the status indicator holes by drilling holes that fit the LED holder assemblies into two groups of four; one set for input status LEDs, and another for the output status LEDs. At this point you should have a panel that contains all of the holes needed on the panel, with nothing mounted.

5. assemble the panel by first covering it with your favorite contact paper or design if you like. Screw the LED holders in place, screw the outlets into the extender, and then screw the extender and cover plate onto the panel.

6. mount and wire the status indicators. Place each of the LEDs into the holders, grouping the colors together, and aligning the pins so that short pins ( cathode ) are all facing to the center of each group. According to the schematic, all of the cathodes are wired to ground, and each anode will have a resister wired to it on separate connections, making 9 connections in all ( ground plus 8 anodes ). Once all are mounted, tie all the cathodes together, and run a short wire between the groups and a longer wire ( 12" ) to the bundle and solder all the connections together; this will be referred to as the panel ground. On each of the remaining long pins ( anode ), solder a resistor to the LED and a 12" wire to the other end of the resistor. Mark each of these wires indicating position and bundle all of the wires into a harness as pictured.

Step 10: Build Shield Connectors

the shield stack is the combination of the Arduino Uno on the bottom, and the Relay Shield on the top. In order to make connections for the sensor inputs and the status indicators, we need to connect wires to the stack using the header pins that will ensure a solid and reliable connection. Included in the parts list is a 36 pin header that can be used for this. This header can broken into sections as needed to fit into the stack. Following the directions below, you will create 2 four pin headers, 1 three pin header, 1 two pin header, and 1 single pin header. Check to picture to see where they line up on the stack.

1. the sensor status headers connect the 4 sensor status LEDs on the front panel to the stack. To create this header, we will be using pins D3, D9, D10, and D11 which correspond to sensor inputs A, B, C, and D respectively. This requires a single pin header ( D3 ) connected to LED A, and a 3 pin header ( D9, D10, D11 ) connected to LEDs B, C, and D. To make the header, lay out the wires from the panel to the stack, measure and cut the wires, and solder to the header pins.

2. the control status header(pictured) connects the 4 outlet status LEDs on the front panel to the stack. To create this header, we will be making a 4 pin header ( D4, D5, D6, D7 ) which correspond to control outputs A, B, C, and D respectively. This requires a 4 pin header connected to the LEDs A, B, C and D. To make the header, lay out the wires from the panel to the stack, measure and cut the wires, and solder to the header pins.

3. the sensor headers connect the 4 analog inputs from the connector to the stack. To create this header we will be making a 4 pin header ( A0, A1, A2, and A3 ) which correspond to sensor inputs. This requires a 4 pin header wired from the 4 inputs coming from the sensor connector. In addition, we need use the last sensor wires to make a 2 pin header ( 5V, GND ).

4. the panel ground connects both sets of indicator LEDs on the panel to the ground on the stack. This requires a single pin header (GND) that connects the common ground wire to the stack. Note that the Arduino shield conveniently has 2 GND connections to support both the sensor ground and the panel ground.

Step 11: Putting It All Together

finishing the build requires mounting the control board and connecting the wires. At this point your project should have a lot of wires floating around; the power harness on the left panel, the indicator harness headers on the right panel, the sensor headers on the right enclosure, and the power supply lines on the control board. In this step we'll tie up all the loose ends.

1. build the stack by placing the Relay Shield on top of the Arduino, aligning the header pins. The version 2.0 shield should contain an insulating plastic cover on the bottom to make sure that none of the high power traces on the board come in contact with the Arduino. If this cover is missing, you will need to create a plastic barrier and glue it to the bottom of the Relay Shield. The barrier must be installed or you may destroy either or both boards!

2. mount the control board by drilling four holes at the corners of the perfboard, and then drilling the holes through the enclosure.Secure the board to the enclosure using bolt/nut sets.

3. drill the USB connector hole that allows access to the USB connector on the Arduino. Start by drilling a pilot hole that is aligned with the center of the USB connector, then follow it up with a 1/2" spade bit to make the hole big enough to fit the USB connector through the hole. If you wish to seal this hole you can find 1/2" rubber plugs at the hardware store.

4. connect the outlet circuit to the Relay Shield by wiring the supply hot and the 4 outlet hots through the relay connections (screw terminals). First measure, cut and strip a wire between the hot terminal strip and the NO1 connector on the Relay shield. Second measure, cut and strip short wires from NO1 to NO2, and NO2 to NO3, and NO3 to NO4. Now the hot supply line is connected to all of the relay switches. Second, connect each of the outlet hot (red) panel wires to each of the COM1-4 screw terminals on the Relay Shield, COM1 to outlet A, COM2 to outlet B, COM3 to outlet C, and COM4 to outlet D. This completes the high power wiring to the shield.

5. connect the power supply to the terminal strip. Trim the power wires on the supply to feed the connector terminal blocks and screw into the neutral and hot connections. It does not matter which wire is connected to which terminal. This completes the rest of the high power circuit; at this point there should be no 20 gauge wires left to connect.

6. insert the header pins to connect the indicators and sensor terminals to the shield. Start by connecting the sensor headers ( A0-A5, GND 5V ) the respective pins on the left side of the shield. Since the Arduino is covered refer to a photo of the board to double-check the placement the pins. Next, connect the panel ground header to the remaining ground pin on the left side of the Arduino. Finally, connect the sensor status headers ( D3, D9-D11 ) and the input status header ( D4-D7 ).

7. trace high power connections by first tracing the high power neutral circuit from the power cord through the Relay Shield and out to the outlets, and also to the power supply. Check the hot circuit through the fuse and switch, and then out to the outlets and the power supply. Finally check the ground connection through the block to the outlets.

8. trace low power connections by first tracing the sensor terminal inputs and power to the stack, then tracing the panel LEDs and panel ground to the stack. Once you are satisfied you know where (and why) the wires are connected the way they are, close up the enclosure double checking for clearance, especially on the high power terminal block and outlets.

Step 12: Low Power Test

1. connect the Arduino to your PC using a standard USB flat to D cable. Do not connect the 120V power cord yet! If you are new to using the Arduino, you should first visit the official Arduino website ( http://www.arduino.cc/ ) to get going and come back here once you've gotten the IDE running.

2. load the code into the Arduino IDE by simply doing a cut/paste on the code section below into a new file in the IDE. Before you build and run the code, make sure that the power cord is not plugged in and there are no devices plugged into any of the outlets; we are only testing the low power circuit now. Simply compile / load the code using the arrow button in the IDE, and your plugduino should begin operating.

// --------------------------------------------------------------------------
//  Plugduino_1 - low power functional test
// --------------------------------------------------------------------------

// Arduino pins used by Plugduino

#define A_OUT_PIN        4      // Relay Shield control A
#define B_OUT_PIN        5      // Relay Shield control B
#define C_OUT_PIN        6      // Relay Shield control C
#define D_OUT_PIN        7      // Relay Shield contorl D

#define A_IN_PIN         A0     // Sensor input A
#define B_IN_PIN         A1     // Sensor input B
#define C_IN_PIN         A2     // Sensor input C
#define D_IN_PIN         A3     // Sensor input D

#define A_IN_STATUS_PIN  3      // Sensor status pin A
#define B_IN_STATUS_PIN  9      // Sensor status pin B
#define C_IN_STATUS_PIN 10      // Sensor status pin C
#define D_IN_STATUS_PIN 11      // Sensor status pin D

// --------------------------------------------------------------------------
// setup - initialize the Plugduino
// --------------------------------------------------------------------------

void setup() {

  // configure output pins

  pinMode ( A_OUT_PIN , OUTPUT );
  pinMode ( B_OUT_PIN , OUTPUT );
  pinMode ( C_OUT_PIN , OUTPUT );
  pinMode ( D_OUT_PIN , OUTPUT );

  // configure status pins

  pinMode ( A_IN_STATUS_PIN , OUTPUT );
  pinMode ( B_IN_STATUS_PIN , OUTPUT );
  pinMode ( C_IN_STATUS_PIN , OUTPUT );
  pinMode ( D_IN_STATUS_PIN , OUTPUT );

  // initialize pullup reistors in inputs

  pinMode ( A_IN_PIN , INPUT ); digitalWrite ( A_IN_PIN , HIGH );
  pinMode ( B_IN_PIN , INPUT ); digitalWrite ( B_IN_PIN , HIGH );
  pinMode ( C_IN_PIN , INPUT ); digitalWrite ( C_IN_PIN , HIGH );
  pinMode ( D_IN_PIN , INPUT ); digitalWrite ( D_IN_PIN , HIGH );

// --------------------------------------------------------------------------
// realtime loop
// --------------------------------------------------------------------------

void loop()

  static int            testOut = 0;
  static unsigned long  timeWait = 0;

  // read the current time in milliseconds

  unsigned long time = millis();

  // read inputs

  int in1 = analogRead ( A_IN_PIN );
  int in2 = analogRead ( B_IN_PIN );
  int in3 = analogRead ( C_IN_PIN );
  int in4 = analogRead ( D_IN_PIN );

  // update input display status

  analogWrite ( A_IN_STATUS_PIN , in1 >> 2 );
  analogWrite ( B_IN_STATUS_PIN , in2 >> 2 );
  analogWrite ( C_IN_STATUS_PIN , in3 >> 2 );
  analogWrite ( D_IN_STATUS_PIN , in4 >> 2 );

  // cycle through the outputs

  if ( time - timeWait >= 1000 ) {

    timeWait = time;
    digitalWrite ( testOut , LOW );

    if ( testOut < D_OUT_PIN ) testOut++;
    else testOut = A_OUT_PIN;

    digitalWrite ( testOut , HIGH );

3. Its alive! should be your immediate observation, but if happens to be something else you might want to go back and check the wiring again. What you should see is that each of the outlet status indicators turns on and off in sequence for one second along with the pleasant clicking sound of the relays on the Relay Shield.

4. code review. if you take a look at the source code, you should be able to figure out what's going on.

At the start of the code, constants are declared that correspond to the pins on the Arduino where your headers are connected. These pin assignments are used in the code as symbols to make it easier to understand.

In setup() we configure the directions of the input and output pins. Note that by default the sensor input pins are set high, and therefore should be lit up as shown in the picture when you run the code.

in loop() we read the sensor inputs, write the values value back out to the sensor indicators, and then sequence through each of the control outputs one at a time, turning it on, waiting one second ( 1000 milliseconds ) and then turning it off and moving to the next.

Step 13: Sensor Test

1. wire up the potentiometer, which we'll use as your first sensor. Cut 3 sections of about 12" of 30 gauge wire, and solder the ends onto the solder tabs on the potentiometer. Strip the ends of the other wire and insert into 5V, A0, GND sensor A input such that the left tab is 5V, center tab is A, right tab is GND. Do NOT connect then in any other way as you don't want to short the 5V line to ground as it may damage the power supply in the box. ! In general you should always take caution to make sure that the connection between 5V and GND is well understood in whatever sensor you connect.

2. check the status indicator which should vary smoothly from off to full brightness as you rotate the potentiometer. Also confirm that the input you are connected to matches the LED that is changing. Proceed to check the remaining sensor inputs in the same fashion to confirm that all inputs are working properly.

3. make a simple brain. Congratulations! you have verified that you ready to begin making the plugduino smart. We will demonstrate this by modifying the code now to use the potentiometer to control the sequencer speed. Put the potentiometer back on the first input, and change line 90 now to read:
if ( time - timeWait >= 5 + in1 ) {
Now when you run the program you will be able to continuously change the speed of the cycle using the potentiometer. Note that the analog input has a range from 0 to 1023 (ideally), so we have a minimum delay of 5 + 0 = 5, and a maximum delay of 5 + 1023 = 1027 millisecond delay range. In our tests 5 milliseconds seems the be the fastest switching time before the relays no longer trigger.

Step 14: High Power Test

1. disconnect the USB from the back of the plugduino. In normal operation, it is fine to have the plugduino connected to both the USB and 120V connection at the same time, but to for first test unplug the USB cable from the plugduino now.

2. power on by first checking to make sure the fuse is seated firmly in the fuse holder, and the switch is in the off position to start. Plug the cable into the outlet, and take a quick look to see if anything bad happens. Next turn on the power switch and you should see the sample program running a few seconds after you turn on the box just as during low power test. If you don't see anything happen, check to make sure your supply is properly powering the Arduino, and that the fuse has not blown.

3. plug a light in to the first outlet. Pick a light like a desk lamp that you know is on before you unplug it from the wall. You should see the light turn on in coordination with the control status light and the click of the relay. Now try the other 3 outlets to confirm proper operation.

4. plug USB back into the PC while the program is still running and its plugged into the wall. Now you can feel free to make a change to the program and see what happens on the plugduino without having to disconnect or reconnect anything. Now you are ready to make your own creations!

Step 15: Help and Ideas

want are you going to do now? By now you should have a good working knowledge of how the plugduino works, so goof around with it a bit and come up with your own crazy use. Feel free to post your project ideas in this instructable so we all share in the plugduino adventures and bask in the light of 120V power!

sensor frenzy There are literally hundreds of input sensors that you can use to drive the plugduino, but here's a couple of links that you might find interesting:  Arduino Playground, Trossen Robotics, Sparkfun, Adafruit.

more to explore In addition to this instructable, we will be hosting a website as we develop more useful software and serve as a place for any reference material that might seem useful. You can visit the website at http://www.plugduino.com.
This is awesome! I am new to arduino and build escape rooms. I'd love to have one of these, but if I build this I may electrocute myself or burn down the building. Can anyone give me a price quote beyond the cost of supplies? I'd buy all you need, so how much to build and ship to Ohio? Thank you.
<p>Great instructable! I was able to replicate this for my own application with great results. The only hiccup I am seeing is some sort of noise from the outlets I plug this into, basically the unit starts cycling on/off really fast at random periods. I have tried lots of different outlets and it will work as designed for awhile until it starts freaking out again. I have also tried using an AC noise filter with no effect. I was wondering how I could prevent this? Keep in mind this application is in an industrial setting.</p>
<p>Sounds like a programming problem. Without knowing anything about your program I'd guess a buffer overrun. Try using floats or doubles instead of integers. Alternatively, you can flush your buffers periodically to head off a overrun.</p>
If you try it in a non-industrial setting does the problem go away?
<p>Can you use the relay shield to turn on all outlets at the same time? </p>
Sure, its just a matter of telling the Arduino which outputs you want to set high based on the single input. Doing so in sequence would be effectively at the same time since the Arduino will execute much faster than the relays could respond.
Sure, its just a matter of telling the Arduino which outputs you want to set high based on the single input. Doing so in sequence would be effectively at the same time since the Arduino will execute much faster than the relays could respond.
<p>nice! instead of using that dial can you use a laser break beam sensor like for making a drag stage light? if so i am so making this project lol</p>
Sure. The dial is just a test of any type of sensor you would like to connect; you only need to change the code that reads the sensor to calibrate it to the sensor you are doing. You can find out more by just looking into the Arduino analog/digital input functions - lots of examples.
<p>@svenkatesh3, not as you ask, but you can monitor power usage by plugging the whole thing into a Kill-a-watt or power meter outlet. You can't measure power use using just relays anyways (though you can crudely approximate if you know the power draw of what you plug in, then simply measure &quot;on&quot; time...). There have been folks who modified the Adafruit Tweet-a-watt to use an arduino, so you could combine the two things into one larger enclosure. </p>
<p>can we able to transmit how much watts its consuming by the device through Xbee transmitter and receiver and which should display in LCD and how to connect with Arduino board could u help me ??</p>
<p>I want my Arduino to control 4 power outlets (on\off)..my home electricity is 230v </p><p> so i have to design 4 power outlets which should control hair dyer(400w),200w blub,Lcd tv,(50w)pumps<br>in my project if any fault happens like overvoltage,neutral line fault or overheating happens in any of the outlets that particular outlet should be isolate which should be indicate with LED for this which component should use whether SSR relay or 4 channel Relay shield ??<br><br>Please help me understand these things, and remember I'm very new , so if you think I need to but something else, it will be great if you could explain <br><br>Lots of Thanks !!!!<br><br>shyam</p>
<p>Hi shyam. One advantage of mechanical relays like the one used in this project is that they have a fairly slow response time, which might help if you attempt to trigger a device (such as motor) too quickly. I would suggest that you could put a fuse on each of the outlets in addition to isolate any fault to just that device.</p>
<p>This is a project want to do and submit it i have to control 4 device and i have to show if fault happens means what relay will do whether all the four socket turn off or particular outlet will turned off and i have to measure the each outlet Power and have to transfer the data into LCD thro Xbee whether arduino uno is enough or i go for arduino mega ?</p><p><br>ll upload my schematic diagram soon :) :) <br><br>and guide me help me !!! <br><br>Thanks a lot for response :) :)</p>
<p>In this Control circuit schematic They explained about sensor inputs (the sensor inputs are connected to the analog inputs on the Arduino board ( A0, A1, A2, A3 ). The input voltages on these pins are converted into a 10 bit integer value</p><p>such that the range between 0V and 5V and translated into a value between 0 and 1023 respectively. The ideal connector thus contains 3 inputs per sensor ( 5V, GND, A<br>) resulting in 12 connection points.) I need clear explanation about this and what type of sensors they using and how they connected ??<br><br>Thanks For ur help :) :) </p>
<p>Here are a few more links to get you thinking:</p><p><a href="http://learn.adafruit.com/photocells/using-a-photocell" rel="nofollow">http://learn.adafruit.com/photocells/using-a-photo...</a></p><p><a href="http://playground.arduino.cc/ComponentLib/Thermistor" rel="nofollow">http://playground.arduino.cc/ComponentLib/Thermist...</a></p><p><a href="http://www.trossenrobotics.com/c/arduino-sensors.aspx" rel="nofollow">http://www.trossenrobotics.com/c/arduino-sensors.a...</a></p>
<p>Thanks :) :) </p>
<p>This is essentially a direct input to the Arduino, so there are many examples of analog input - too many to describe here. To get you started, take a look at this article:</p><p><a href="http://arduino.cc/en/Tutorial/AnalogInput" rel="nofollow">http://arduino.cc/en/Tutorial/AnalogInput</a></p><p>Although this is simply a potentiometer, you can use the same method for thermistors, photocells, and the like.</p>
That is really nice work.
dude yes I could control a light or plasma ball or even tesla coil yay! (super exited)
Thanks! Since the Arduino is just turning the pins on/off, the programming possibilities are pretty wide open. One simple example might be to string 4 sets of lights woven around a tree. How you animate them is where the coolness of the project would come in.
Cool project! You could use something like this to make programmable Christmas lights that go with music.
The clicking would drive me insane - why not use solid state relays, or even a discrete set of triac output optocouplers and triacs - then you could even do fading and other cool stuff if you have lights in the outlets. <br>I made a sequencer like that back in the early 90's, but it had 16 outputs, and was not microcontroller programmed - it was all hard wired logic - but it was pretty cool. Even had audio input.
I personally love the clicking. There is something satisfying about it to me.
Nice project! I'm wondering why you chose to switch the neutrals with the relays leaving the hot inputs to the plugs powered as opposed to always providing ground and neutrals to the plugs and switching the hots? I probably would do it the other way around. <br>Best Wishes
Thank you, and excellent question. This is an oversight in my build that I will correct shortly in the instructions. As you probably know, switching neutral still keeps the circuit alive (but off) whereas switching hot disconnects the circuit. Thanks for the catch, and I'll have an update to correct this shortly.
The diagrams and instructions now indicate the modified wiring where the hot connection is used to switch the outlets. Thanks again for the reading through the project and making the catch.
Looking great! <br>Thanks! <br>
This us a cool project! The URL is missing a colon after the http.
Thanks! I think I have corrected the link; I assume you mean the URL on the last page...?

About This Instructable




Bio: I am a multidisciplinary engineer actively interested in new technology and how it can be used to further interest in science, technology, engineering, and mathematics.
More by flashular:babbletron -  an interactive exploration of computer generated speech plugduino - Arduino based 120 Volt outlet controller Raspberry Pi as a DMX light controller 
Add instructable to: