loading
Working with the digital relay to control high voltage can be hard to understand.  There are no instructions on how to make this perform with an ARDUINO.  I created this so people will be able to use the relay with a standard 110 volt house outlet in either NO - NORMALLY OPEN  or NC - NORMALLY CLOSED modes.  As always working with high voltage is dangerous so be careful.  If you do not understand how it works seek help from someone who knows how to make it work or DO NOT ATTEMPT THIS INSTRUCTABLE !!!!!!



UNDERSTANDING RELAY STATES:

You can configure your ARDUINO signal to be either "LOW" or "HIGH".  It does make a difference as to how the RELAY controls the outlet in the "NO" or "NC" states.  For this project all PINS on the ARDUINO will start out in the "LOW" state as the default.  You need to determine how you need your "OUTPUT" PIN to be configured for your own projects.  You need to understand this concept so you can configure your projects using this RELAY BRICK to be the most effective with the least amount danger possible.


NO - Normally Open

The RELAY can be NO (Normally Open) state . When outlet is pluged into a high voltage power supply the outlet is HOT (power to it and LED on outlet is on).  The default mode at the ARDUINO is in the "LOW " state (RELAY LED light is off). When ARDUINO send a "HIGH" command to the RELAY (LED on RELAY turns on) all power is cut to the outlet  (LED light on outlet will go out).

POWER LOST DURING USE:
When power goes out or power cord is unpluged there will be no power to the outlet or ARDUINO and all devices connect will not work.

RELAY "LOW" (LED on RELAY is off) and power is lost to the ARDUINO and RELAY outlet will remain HOT.  What ever device is connected to the outlet will continue to run.
 
RELAY "HIGH"
(LED on RELAY is on) and power is lost to the ARDUINO and RELAY the outlet will revert back to a HOT condition.  What ever device is connected to the outlet will be turned on again.




NC - Normally Closed

The RELAY can be NC (Normally Closed) state . When outlet is pluged into a high voltage power supply the outlet has no power and is OFF (power to it and LED on outlet is off).  The default mode at the ARDUINO is in the "LOW " state (RELAY LED light is off). When ARDUINO send a "HIGH" command to the RELAY (LED on RELAY turns on) power allowed to flow to the outlet  (LED light on outlet will turn on).

POWER LOST DURING USE:
When power goes out or power cord is unpluged there will be no power to the outlet or ARDUINO and all devices connect will not work.

RELAY "LOW" (LED on RELAY is off) and power is lost to the ARDUINO and RELAY outlet will remain OFF (LED light on outlet is off) .  What ever device is connected to the outlet it will continue to be off.
 
RELAY "HIGH"
(LED on RELAY is on) and power is lost to the ARDUINO and RELAY the outlet will revert back to a OFF condition.  What ever device is connected to the outlet will turn off as power to the outlet has been lost.


Know what you can drive with this RELAY:
current * voltage = power 
This RELAY is rated for 10A at 120V
The RELAY can handle up to a 1,000W device.
It is not a good idea to run this RELAY at a full 1,000W demand.  It is a better idea to stop at about 800W to be on the safe side. 



Step 1: COMPONETS OF PROJECT

There are 4 major componets to get this project to work correctly:

1 - Arduino of some type to control the relay.

2 - 5V Relay module (Digital) -  Electronic Brick
      It is much easier to use this small foot print digital relay with all the correct parts in one unit.
      Building one of these little guys can be a lot of work and not perform as well as this unit.

3 - House Outlet the the relay will control

4 - The Sketch to drive the relay using an Arduino.
      (if you don't understand how to use sketches with an Arduino, you will need to learn this skill).

Step 2: PARTS and MATERIALS


BELOW YOU WILL FIND A FULL LISTING OF THE PARTS & MATERIALS USED:


1 --  SEEED Stuido 5V Realy module (digital) Electronic Brick
 http://www.seeedstudio.com/depot/electronic-brick-5v-relay-module-digital-p-479.html?cPath=48_53

1 --  Arduino (any type you want to use)

1 --  Duplex Ground Fault Receptacle
http://www.google.com/products/catalog?q=125V+Duplex+Ground+Receptacle&oe=UTF-8&cid=17102349241501817852&ei=XjPmS-b0II64iwTboKHaDg&sa=title&ved=0CCgQ8wIwCDgA#p

1 --  Proto Shield  -- (optional) or bread board to construct button circuit
        http://www.makershed.com/ProductDetails.asp?ProductCode=MKAD6

1 -- LED light

1 -- Power Cord grounded

1 -- Button Switch

1 -- 10 ohm resistor

1 -- 12 inches of 20 gauge YELLOW solid core wire

1 -- 12 inches of 20 gauge RED solid core wire

1 -- 12 inches of 20 gauge BLACK solid core wire

1 -- 12 inches of 18 gauge BLACK 600 volt wire
       http://www.boatingsolutions.com/Wire-Primary-18-Black-By-Foot-P11018C1609.aspx

1 -- Radio Shack - 
      12 position Mini European Style Terminal Block ( optional if constructed as shown
      http://www.radioshack.com/product/index.jsp?productId=2103986

Step 3: Understand Your RELAY BRICK

You need to understand your RELAY brick.

BOBB from the Seeed Stuido Forum did an outstanding job of showing the lay out of the relay.
http://www.seeedstudio.com/forum/viewtopic.php?f=4&t=683

The only thing missing for this overview is the LED light that is located next to the connector 3 terminal block.  This is an important part in the design of this relay.  You use it to see when power goes to the Connector 3 terminal block.  Why is this important -- well once the LED goes on you know you have a signal to the relay and the relay is actually turned on.  VERY IMPORTANT !!!!!!!!!!!!


Step 4: Construct Your OUTLET SETUP

MAKE SURE OUTLET OR POWER CORD HAS NO POWER CONNECTED TO THEM !!!!!!!!

Conection of your outlet to the power cord is very important that you do it right.  If not done right you might start a fire when working with this project.  This project was done outside an outlet box for demonstration purposes only.  Make sure you construct your project in an outlet box that meets all local building codes.

Please notice that we are using a Ground Fault Circuit Interrupter (GFCI) Outlet and not a normal outlet. The GFCI may save your life. It's the type of outlet you'll find near anything that outputs water (kitchen sinks, batchroom tubs, etc). When the outlet detects an abnormal amount of current, it assumes that a large amount of potentially fatal current is flowing through your body, and therefore switches off - saving you and your project.

Note: A two-wire extension cord will not work correctly. Notice this project is using a thick, three-wire circular extension cord. This extra wire is the ground return and allows the GFCI to operate correctly.



POWER CORD CONNECTION TO OUTLET:

WHITE WIRE CONNECTION:
Connect WHITE wire from power cord to silver screw mount on the wide prong side of the outlet.

GREEN WIRE CONNECTION: (ground wire)
Connect GREEN wire from power cord to metal screw mount on the bottom of the outlet.

BLACE WIRE CONNECTION: (hot connection)
Connect BLACK wire from power cord to "COMMON" or Terminal 3 center screw post on the RELAY.
 

Step 5: PUSH-BUTTON SWITCH CIRCUIT -- Control Input and Output to RELAY

I am using a momentary push-button switch connected to GND to control the input and output to the RELAY for this project . The kind I recommend has 4 legs, however there are only two you need to be concerned with.  Using your multimeter check to see which pairs are redundant (meaning always connected, share the same line).  When you press the button, both pairs get bridged, and GND is shared with pin 1 and the circuit is completed and a signal is sent to PIN 2 on the ARDUINO making it go to either a "HIGH" or "LOW" state.

Step 6: SKETCH - Create Sketch to Drive RELAY

Create the SKETCH that will drive the RELAY for this project.
You can either enter the code yourself or you can copy and paste from here.

// Test Relay signal when button is pressed
// Use PIN 7 to send signal to relay
// Turn on LED when the button is pressed to test Sketch code
// and keep it on after it is released
// including simple de-bouncing
//

 #define LED 13                    // the pin for the LED
 #define BUTTON 2              // the input pin where the pushbutton is connected
 #define RELAY 7                 // PIN for relay signal
 
 int val=0;                               // val will be used to store the state
                                                // of the input pin
 int old_val=0;                      // this variable stores the previous
                                               // value of "val"
 int state=0;                          //0=LED off and 1 = LED on

void setup(){
 pinMode(LED, OUTPUT);               // tell arduino LED is an output
 pinMode(BUTTON, INPUT);           // and BUTTON is an input
 pinMode(RELAY, OUTPUT);          // tells arduino RELAY is an output
}

void loop(){
 val=digitalRead(BUTTON);         // read input value and store it -- new input
                                  
 // check if there was a transition
 if ((val==HIGH) && (old_val==LOW)){
   state = 1 - state;
   delay(10);
 }

 old_val=val;                    // val is now old, let's store it

 if (state == 1){
  digitalWrite(LED,HIGH);           // turn LED ON
  digitalWrite(RELAY,HIGH);      // turn RELAY ON
 }else{
  digitalWrite(LED,LOW);            // turn LED OFF
  digitalWrite(RELAY,LOW);       // turn RELAY OFF
 }

                                  

 
TEST YOUR SKETCH:
Load the Sketch on to the Arduino.

Push Button Switch  --  LED on PIN 13 should light.

If not you need to de-bug your sketch and make it like the one above.

Step 7: RELAY Connection to Arduino

In this step we will be using Terminal 2 located on the RELAY.  This Terminal is made up of 3 post screws.

GND -- COM -- VCC

If you are looking at the terminal and can see into the set screw departments then this is the correct veiw of the terminal block.

BLACK WIRE (GND)   -  connects to GND on the Arduino.

YELLOW WIRE (COM) - connects to PIN 7 on the Arduino.

RED WIRE (VCC) -  connects to 5V on the Arduino


VIEW ADDITIONAL PICTURES FOR A LOOK AT THE CORRECT CONNECTIONS AT BOTH THE RELAY AND THE ARDUINO.

Now test the RELAY for signal being sent to Terminal block 3 to drive outlet


Here is a Youtube of the working RELAY:
http://www.youtube.com/watch?v=4IxNJZU5bsM

Step 8: NO - (Normally Open) Function

MAKE SURE OUTLET AND POWER CORD HAVE NO POWER CONNECTIONS!!!!!!!


NO
- ( Normally Open) Configuration for the RELAY 


CONNECTION 1 ----
Black wire from power cord is connected to the "COMMON" set screw of Terminal Block 3 on  the RELAY.  That would be the center connection when looking directly at the front of the Terminal Block. (see picture NO - (Normally Open) - Configuration if any question about this connection)

CONNECTION 2 ---
Using BLACK 600 Volt wire connect one end at the NO - (Normally Open) Terminal Block 3 NO set screw position.  Run this wire back to and connect to the silver screw on the short prong side of the OUTLET.  This will complete the circuit to the outlet.

PLUG IN THE POWER CORD ---
Your LED light on the OUTLET should turn on .  If not you need to double check all connections, after you un-plug the power cord or turn of power to the OUTLET.

IF EVERYTHING IS WORKING ---
Power cord is pluged in, LED light on OUTLET is on
Have Sketch load into Arduino
Have power to Arduino
Now push the BUTTON --  LED on Arduino and LED on RELAY will turn on --  LED on OUTLET will go out.

Here is a video of the actual event:
http://www.youtube.com/watch?v=LYKPc925el0

Step 9: NC - (Normally Closed) Function

MAKE SURE OUTLET AND POWER CORD HAVE NO POWER CONNECTIONS!!!!!!!


NC
- ( Normally Closed) Configuration for the RELAY 


CONNECTION 1 ----
Black wire from power cord is connected to the "COMMON" set screw of Terminal Block 3 on  the RELAY.  That would be the center connection when looking directly at the front of the Terminal Block. (see picture NC - (Normally Closed) - Configuration if any question about this connection)

CONNECTION 2 ---
Using BLACK 600 Volt wire connect one end at the NC - (Normally Closed) Terminal Block 3 NC set screw position.  Run this wire back to and connect to the silver screw on the short prong side of the OUTLET.  This will complete the circuit to the outlet. (see picture NC-OUTLET configuration)

PLUG IN THE POWER CORD ---
Your LED light on the OUTLET should be off .  If not you need to double check all connections, after you un-plug the power cord or turn of power to the OUTLET.

IF EVERYTHING IS WORKING ---
Power cord is pluged in, LED light is off on the OUTLET
Have Sketch load into Arduino
Have power to Arduino
Now push the BUTTON --  LED on Arduino and LED on RELAY will turn on --  LED on OUTLET will turn on.

Here is a video of the actual event:
http://www.youtube.com/watch?v=BGnLDw6T14o
<p>Schematic diagram please!</p>
<p>Don't feel bad at all about the confusion on the N/C and N/O designation. I'm seeing many people making this error. Hopefully live and learn! </p>
<p>i like your post! Very helpful!</p><p>For your info, you can find 5v relay modules on this webstore for a good price: <a href="http://voltatek.com/en/recherche?tag=relay" rel="nofollow">http://voltatek.com/en/recherche?tag=relay</a></p>
<p>Great subject for an instructables</p>
<p>Thanks - I learned a lot by doing the instructable. I refer back to it a lot as well.</p>
.<br>I agree with the others, you have NC and NO labeled backwards. <br><br>I also noticed you used a lower gage wire from your terminal block to the relay brick and back again (the HOT/black line). It looks a little under rated for a 10 Amp max relay. I use #12 Solid copper for such interconnects, but #14 gage should be fine. #14 solid is the standard 15 amp wire gage used in NA - North America. #12 gage is NA standard for 20 Amp service. The Lower the gage number in wire the smaller/thinner the wire and the Less Current it can carry before heating up.<br><br>Also remember that when a Load (power device) is switched on there may be a rush (Peak) in amps that exceeds the 10 Amp Continuous rating of the Relay. This is normal but is one of the reasons I would never downgrade my wire gage.<br><br>I would suggest to anyone playing with circuits that switches house main voltage to install a ARC Fault breaker at the panel or somewhere before your custom monkey business! This Is Not the same as a Ground Fault which saves You from getting electrocuted. Most electrical fires are started by Arcing. A small arc over time will carbonized where the electrical bounding has been broken or poorly made. Once carbonized, heat increases and increased heat can lead to Fire. Arc Fault Circuit Interrupters Saves Lives from Fires! ..and property and insurance hassles :) so play it safe and Happy automating!
Be very careful putting high current through this board! Even though the traces are short, they are no where near 14 gauge. Trying to put 10A at 12V vaporized the trace between the relay and the output connection. If I had taken the time to look at the thickness (thinness?) of the traces on the board I would never have done this.<br><br>Be warned.
agree, if you want more current it might be a good idea to solder some solid core copperwire of the right gauge between the relay contacts and the terminal block. Usually I solder that on the existing track
If any one would like some cheap handmade arduino bricks<br>pleas go to my etsy shop 111swords.<br>I would greatly appreciate it.<br>
This relay and other similar ones in 4-relay and 8-relay boards are available here: <br><br>http://➡.ws/relays<br><br>There's lots of information on power control with this relay and others here:<br><br>http://arduino-info.wikispaces.com/ArduinoPower<br><br>Regards, Terry King<br><br>terry@yourduino.com
Thanks Terry, <br>I will check these sites out. Always good to learn new things.<br><br>Rik
I would not use the 5V from the Arduino due the the current draw of the relay. I would use a separate 5V supply.
Great instructable; however, the open/close descriptions are backwards for electricity BUT not for water-<br><br>Electricity - Open circuits are not continuous, meaning there is an 'opening' or separation between one connection and another.<br><br>Water - An open valve is one in which the gate has been shifted as far away from the flow of water as possible (hence the phrase 'Turn it wide open' meaning 'to allow the maximum flow of water/fluid through')<br><br>Hope this helps!
mitsubob8404 -- Thanks for the input. I am new to electronics and understanding how these bricks work with the correct terminology.&nbsp; What would be the correct way to state the change I need to make?&nbsp; If you could help me on this I will make the change, so others will not make the same mistake I have made.<br> <br> Thanks so much for your input,<br> <br> Rik<br>
You have normally open and normally closed backwards. When a circuit is open, no current can flow. The circuit is &quot;off.&quot; When a circuit is closed, the power is on.
thanks for pointing that out. I will check with the Seeed Studio tech person on this, as they have reviewed this and had no changes as is. I can make the changes. Thanks again, rik

About This Instructable

90,852views

87favorites

License:

More by rik:RUNNING Arduino IDE on RPi @ 800 X 480 Resolution 800 X 480 - 5" HDMI Display - Using Jessie With Pixel -  Resolution Issue aquaponic BALCONY GARDEN 
Add instructable to: