Advertisement

Relay module control with Arduino.

     

    

            Hello guys, Welcome back to my srituhobby blog. Are you a new member of my blog? Please read my previous posts. So, let's go to today's post. Today we will be going to talk about high voltage control with the Arduino. Did you know that the maximum voltage of an Arduino board is 5v and the current is 40mA? We cannot control devices over 5v via the Arduino board. For that, we have to get the help of another component. That is, the transistor or relay must be used. Today we will use a relay for our project as a relay has the ability to control AC and DC voltages.

What is a relay?

    Relay is an electronic switch. We can see this as a small box. It has five pins. Three pins can be used to input and two pins to receive output. Look at the picture below.


Pins 1 and 2 are used to power this component. It is mentioned above on this device. We can get different types of relays like 5v, 6v, 9v, etc. The third pin must give us the potential we need to get the output. It can supply AC or DC voltage. However, the current available through this is shown at the top of the relay. That is, when the value is exceeded, the relay will burn out. Therefore, use devices with less current than the specified level. we can get outputs using 4 and 5 pins. The four-pin is called Normally close(NC) and the five-pin is called Normally open(NO). The four-pin is usually connected to the 3rd pin. The 5th pin connects to the 3rd pin when the relay is activated.

Ok, let's see now the relay structure. It contains an electromagnetic coil. This coil is activated by the force applied through pins 1 and 2. We can ON/OFF this coil using the Arduino pin pulse. When this is ON and OFF, the copper plate at the end of the coil is connected to pins 4 and 5. This is why a sound is emitted when the relay is operated. This copper plate is NC under normal conditions. Is associated with the pin and the copper plate is connected to the NO pin when the relay is in the active state. Depending on your needs, you can get outputs from either of these NC or NO pins. Please remember that the potential given for pin 3 can be obtained from pins 4 and 5. I think you learned about how to work relay.

This relay cannot be connected directly to the Arduino board. This is because the high voltage we apply to the relay can cause it to burn out if it returns to the Arduino board. For that, we need to create a small circuit. But for this, we will use the relay module designed for Arduino.





It is designed as a very safe circuit. An optical coupler IC and a diode were used to stop the return of electricity. It includes three pins and three terminals. The VCC and GND pins are used to power this relay module and IN pin used give to the signal through the Arduino board. The middle terminal is called a common pin. It must be given an input voltage. The other two terminals can get outputs. The right terminal is NC and the left terminal is NO. The voltage we supply to terminal 3 can be obtained through terminals NO or NC. You must remember the AC voltage is very dangerous. Must be carefully working with AC voltage. Ok, let's do this project practically. The required components are as follows.


Components.

Let's do this project step by step.


Step 1

Let's identify these components.

Arduino Uno board.


You can use any other Arduino board for this project.


Relay module.


This component is described above.

Jumper wires.


This project used three Male to Female jumper wires.


Step 2

Connect these components as follows.


Step 3

Let's look at the code. This project is using the LED blink example code.

 /*Relay module control.
  Serial monitor readings.
  created by the SriTu Tech team.
  Read the code below and use it for any of your creation
*/
void setup() {
  Serial.begin(9600);//enable serial monitor
  pinMode(2, OUTPUT);//define arduino pin D2
}
void loop() {
  digitalWrite(2,HIGH);//relay on
  Serial.println("ON");//print serial monitor ON
  delay(1000);//delay
  digitalWrite(2, LOW);//relay off
  Serial.println("OFF");//print serial monitor OFF
  delay(1000);//delay
}

Step 4

Select board and port.



Step 5

Upload code.



Ok, now we can see how to work relay. In addition to this article, you can see how this project is done in the video below. Please watch it.

The video below shows how to install an AC bulb in this project. Please try it safely. So we will meet in the next post. Have a good day. Bye-bye.


Post a Comment

0 Comments