Introduction: Arduino - Relays (Control AC Appliances)

Arduino is an awesome micro-controller to get started with DIY electronics, but you can not control AC appliances with it directly. Relays help to do this the arduino drives a 5v relay, which in turn controls AC appliances. The only down side to a relay is that the frequency of switching is limited to low value. To over come this we could use triacs which I would demonstrate in a different instructable.

In this instructable I'm going to show you how to get started with working with relays using the arduino UNO.

Step 1: Components

For this project you will need

  • Arduino Uno
  • Relays
  • Atmega328 (Optional)
  • 16 Mhz Crystal
  • 22 pF Crustal

Step 2: Relays

There are many types of relays I'm using the most standard 5v relay, 5v because the arduino is capable of powering 5v. A relay can not be directly powered by a bread board so you need to solder it to a PCB.

Also, you would need to add a fly-back diode in parallel to the coil of the the relay. You can see the above picture as a reference to which pins are the coil and control pins.

Step 3: Circuit

Follow the circuit in the picture above and solder all the components on a PCB. The program uses digital pin 5 as the relay pin but you could use any other pin, just make sure to make changes accordingly to the code.

Note Be careful while working with high voltage devices, make sure all the wires you use are rated to hold the right power ans all the wires are insulated properly.

Step 4: Blink for AC Appliances

Now that the circuit is done lets test the circuit out, lets try out the blink application just like the ones we do with LEDs, but now we would be doing with AC Circuits.You can connect an ac appliance to the relay to test it out, I tried it out using a CFL Bulb. The program turns on and off the Bulb every five seconds.

void setup() { pinMode(5, OUTPUT); }

void loop() { digitalWrite(5, HIGH); delay(5000); digitalWrite(5, LOW); delay(5000); }

Step 5: Going Further

Now the at you know how to work with relays you could make a custom arduino circuit to control many relays. I built one using the atmega328, added in two relays, a Bluetooth shield and left out a few headers for other sensors. This would make a cool home automation circuit which I would show you in another tutorial.

Comments

author
Bagoong (author)2017-07-10

Looks like fun. But this is a bit of a confusing Instructable. You seem to be illustrating two separate projects as though they are one, yet neither is illustrated completely.

For instance, you show 2 * capacitors, yet your circuit diagram does not include even one.

Also you mention, and illustrate a 16MHz Crystal, yet this is not wired into the circuit drawing.

Thanks

author
JB95 (author)2017-07-05

i'd rather use a smaller controller like the ATtiny85

author
SamuelD71 (author)2017-07-05

You should not power your relay directly from the Arduino board. This may damage your board because the relay will draw too much current. Drive a transistor that will drive your relay instead.

About This Instructable

2,197views

67favorites

License:

Bio: IoT Related Projects
More by tinkerproject:Tasty Biscuit LaddooSpicy Corn CurryPhulka - Fluffy Roti Breads
Add instructable to: