Using various modules on our web shop, we have mostly encoutered components which require low current and voltage to work. But what if we want to make a project which requires much higher voltage and current or even alternating current? How do we control such high current and do not risk Dasduino’s and other components’ malfunction? The answer is using the relay.
The relay is an electromagnetic switch and it is mainly used to control a high powered circuit using a low power signal. It is ideal for use with alternating current whose flow can be controlled using Dasduino board.
• Current necessary for activation (Dasduino’s current): 20 mA
• Coil’s voltage: 5V
• Max DC: 30V, 10A
• Max AC: 250V, 10A
HOW DOES IT WORK?
There are several different types of relays. We will provide a more detailed description of the operation of electromagnetic relays. They consist of coils, iron yokes and contacts. When current flows through the coil, magnetic field that attracts the iron yoke is created. The contacts which, depending on the flow of current, open or close the second circuit, are located on the iron yoke. Within the second circuit, it is possible to connect the consumer which requires high or alternating voltage. For handling the relay, it is necessary to know several characteristics of the relay itself. The first is the amount and type of voltage which is necessary for the coil to be activated. There are different values of that voltage depending on the need and purpose (often 5, 12, 24V DC). Another thing we must take into consideration is power of the consumer we connect to the relay. At the relay itself, the maximum amount of current and voltage that can be connected to relay (often 12, 14, 30V DC or 120, 220V AC), is written. If the limits are exceeded, the relay can be damaged or overheated.
HOW TO CONNECT?
In continuation of the tutorial we work with high alternating voltage which can cause serious injuries or even death, if handled improperly. More caution is needed to protect yourself and properly work with alternating voltage. This tutorial is made for educational purposes and e-radionica is not responsible for any injuries or damage caused by following this tutorial.
Relay consists of 6 pins: three pins through which the current in the coil flows (VCC, IN1 and GND) and three pins to which we connect the second circuit whose flow we want to control. These three pins are often referred to as NO, NC and GND. In order for us to use the module with Dasduino, it is necessary to connect it in a way shown in the picture. The module’s power supply, for simplicity, can be achieved by connecting +5V pin on the Dasduino and VCC pin on the module. The GND connector of the module is connected to one of the two GND pins on the Dasduino. IN1 is connected to any digital output of the Dasduino. The output connectors are connected to the consumer with alternating current. Consumer’s phase is connected to the NO (normal open) or NC (normal closed) connector, depending on whether we want the circuit to be normally open or closed. The consumer’s zero is connected to the GND relay connector.
It is important to mention that the relay can be used with DC lower voltages, not just high alternating ones. Think of the relay as a switch and it will all be clear.
We use relay the same way we use LED diodes. When we want to open or close a circuit which a consumer is connected to, we use digitalWrite function. Just as we would illuminate or turn off the LED diode, we turn the relay on and off. The program code shows illuminating the bulb alternately every two seconds.
#define RELAY 2 //number of pins which the relay is connected to
//defining relay pin as an output pin
// Turn the relay on
// Wait 2 seconds
// Turn the relay off
// Wait 2 seconds