Lab 3 : Relay & 120 Volts of Raw Wall Power!

Lab 3 – Relays and 120vac 

Today I am going to talk you through and demonstrate how to connect a 5v relay through your arduino to get use of 120 BIG volts. This allows you to access things that need a lot of power- lights, hair dryers, fans, projectors, blenders, you get the idea.

It’s a simple circuit technically, but a fairly complicated concept, so for Monday we’ll just focus on the how & why, and start the lab. Wednesday you’ll get to practive & work with the code some more.To prepare for the lab, read through the steps, and have your arduino programmed to the “button” code that runs a simple switch off pin 2.

A relay is a mechanical or solid state component that allows the arduino to control a device that requires 120-240v ac.
Data sheet for relay
This relay operates by supplying current to a coil. When the coil receives the current in contracts and moves a contact to the opposite pole of the relay. It’s basically a switch, but with a pin for an external power supply. A relay keeps our two circuits -the switch coming from the arduino and the lightbulb going to wall power- separate.

Step 1:

You should solder headers on your relay pins, if you are reasonably comfortable with soldering. Once the little pins on the relay bend off or break, the relay is useless, and you’ll have to go to radio shack to replace it ($4.79). If you don’t want to solder, be careful with those little pins!

Parts list:

5v relay
ceramic light bulb socket
light bulb
AC plug
braided wire
wire caps (2)
electrical tape

Step 1: Place the relay on the bread board with the “valley” running down the middle of the relay. Three legs on one side of the valley, two on the other. The text side of the relay should be on the left.


Step 2:

Connect the arduino power and ground pins to the correct vertical buses on the bread board

(just like we are doing any other normal  circuit)

Step 3:

Jump from the ground bus to one of the coil pins on the relay. If your relay is oriented correctly, this will be one of the top right pins. I use the second pin to go to ground. ( You can see the wires in my picture) The relay is non polar- this means you can reverse the wires- just know what you are doing.


Step 4:

Jump from digital pin 13 to the other coil pin on the relay.
that’s where the orange wire is going in my picture above. The brown wire is going to the ground bus.

Step 5:

Make your switch circuit, using pin 2, like we have been doing:
-Jump the resistor from ground to a horizontal bus on the bread board
-Jump from that same bus to digital 2 on the arduino.
-Connect switch between that horizontal bus and the power bus

Step 6:
Program the arduino with the basic button code from Examples >digital >button. You can now test the relay by closing the switch and listening for the mechanical click. If you here “chattering” , that is the relay going off and on quickly, it means your switch circuit is not grounded or you forgot the resistor.

Step 7:
Connect one end of the AC plug wire to the input pin on the relay. MAKE SURE THAT THE AC PLUG IS NOT PLUGGED IN!!

Connect the other end of the AC plug to one of the poles on the relay output. One pole is “always on” and the other is “always off”


Step 8:

Verify that your circuit is correct…

Remove the USB cable from the arduino, and power your arduino with wall power. Check FIRST!! to hear for the “click” of the relay switch. This means your relay is correctly wired. if your switch is wired correctly the LED on pin 13 should light as the button is pressed.

Step 9:

Plug in the AC plug and watch the magic!! BEFORE moving any wires at this point, TURN THE POWER OFF!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s