Arduino - Relays (Control AC Appliances)




About: IoT Related Projects

Intro: 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.



    • Optics Contest

      Optics Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Plastics Contest

      Plastics Contest

    3 Discussions


    1 year ago

    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.



    1 year ago

    i'd rather use a smaller controller like the ATtiny85


    1 year ago

    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.