Introduction: Arduino - Relays (Control AC Appliances)

About: " Work until you no longer have to introduce yourself " Show some love on Instagram @makers_bee & Motivate me on YouTube @MakersBee

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 downside to a relay is that the frequency of switching is limited to a low value. To overcome 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: Bill of Materials

For this project, you will need

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

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 flyback diode in parallel to the coil of the relay. You can see the above picture as a reference to which pins are the coil and control pins.

Step 3: Circuit Sketch

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 and all the wires are insulated properly.

Step 4: Blink for AC Appliances

Now that the circuit is done. Let's test the circuit out, let us 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.