Osoyoo.com
Osoyoo.com
com /2017/08/28/arduino-lesson-1-channel-relay-module/
Unknown Title
Note: ALL OSOYOO Products for Arduino are Third Party Board which is fully
compatitable with Arduino
Introduction
A relay is an electrically operated switch. Many relays use an electromagnet to mechanically operate a
switch, but other operating principles are also used, such as solid-state relays. Relays are used where it
is necessary to control a circuit by a separate low-power signal, or where several circuits must be
controlled by one signal.
In this lesson, we will show you how the 1-Channel Relay Module works and how to use it with the
Osoyoo Uno board to control high voltage devices.
Preparations
Hardware
Osoyoo Basic Board (Fully compatible with Arduino UNO rev.3) x 1
1-Channel Relay Module x 1
Breadboard x 1
Jumpers
1/8
USB Cable x 1
PC x 1
Software
Arduino IDE (version 1.6.4+)
What is a Relay?
A relay is an electrically operated device. It has a control system and (also called input circuit or input
contactor) and controlled system (also called output circuit or output cont actor). It is frequently used in
automatic control circuit. To put it simply, it is an automatic switch to controlling a high-current circuit with
a low-current signal.
Advantages
The advantages of a relay lie in its lower inertia of the moving, stability, long-term reliability and small
volume. It is widely adopted in devices of power protection, automation technology, sport, remote control,
reconnaissance and communication, as well as in devices of electromechanics and power electronics.
Generally speaking, a relay contains an induction part which can reflect input variable like current,
voltage, power, resistance, frequency, temperature, pressure, speed and light etc. It also contains an
actuator module (output) which can energize or de-energize the connection of controlled circuit. There is
an intermediary part between input part and output part that is used to coupling and isolate input current,
as well as actuate the output. When the rated value of input (voltage, current and temperature etc.) is
above the critical value, the controlled output circuit of relay will be energized or de-energized.
NB: input into a relay can be divided into two categories: electrical quantities (including current, voltage,
frequency, power etc.) and non- electrical quantities(including temperature, pressure, speed, etc.)
Features
2/8
The features of 1-Channel Relay module are as follow:
Good in safety. In power system and high voltage system, the lower current can control the higher
one.
1-channel high voltage system output, meeting the needs of single channel control
Wide range of controllable voltage.
Being able to control high load current, which can reach 240V, 10A
With a normally-open (NO) contact and a normally-closed (NC) contacts
Pins Out
Input
It has a 1×3 (2.54mm pitch) pin header for connecting power (5V and 0V), and for controlling the relay.
The pins are marked on the PCB:
Output
The 1 channel relay module could be considered like a series switches: 1 normally Open (NO),
1 normally closed (NC) and 1 common Pins (COM).
3/8
The working of a relay can be better understood by explaining the following diagram given below.
1. Electromagnet – It consists of an iron core wounded by coil of wires. When electricity is passed
through, it becomes magnetic. Therefore, it is called electromagnet.
2. Armature – The movable magnetic strip is known as armature. When current flows through them, the
coil is it energized thus producing a magnetic field which is used to make or break the normally open
4/8
(N/O) or normally close (N/C) points. And the armature can be moved with direct current (DC) as well as
alternating current (AC).
3. Spring – When no currents flow through the coil on the electromagnet, the spring pulls the armature
away so the circuit cannot be completed.
.Normally open – connected when the relay is activated, and disconnected when it is inactive.
.Normally close – not connected when the relay is activated, and connected when it is inactive.
Principle
The diagram shows an inner section diagram of a relay. An iron core is surrounded by a control coil. As
shown, the power source is given to the electromagnet through a control switch and through contacts to
the load. When current starts flowing through the control coil, the electromagnet starts energizing and
thus intensifies the magnetic field. Thus the upper contact arm starts to be attracted to the lower fixed
arm and thus closes the contacts causing a short circuit for the power to the load. On the other hand, if
the relay was already de-energized when the contacts were closed, then the contact move oppositely and
make an open circuit.
As soon as the coil current is off, the movable armature will be returned by a force back to its initial
position. This force will be almost equal to half the strength of the magnetic force. This force is mainly
provided by two factors. They are the spring and also gravity.
Relays are mainly made for two basic operations. One is low voltage application and the other is high
voltage. For low voltage applications, more preference will be given to reduce the noise of the whole
circuit. For high voltage applications, they are mainly designed to reduce a phenomenon called arcing.
Relay Applications
Relays are used to protect the electrical system and to minimize the damage to the equipment connected
in the system due to over currents/voltages. The relay is used for the purpose of protection of the
equipment connected with it.
These are used to control the high voltage circuit with low voltage signal in applications audio amplifiers
and some types of modems.
These are used to control a high current circuit by a low current signal in the applications like starter
solenoid in automobile. These can detect and isolate the faults that occurred in power transmission and
distribution system. Typical application areas of the relays include
5/8
Motor drives control
Protection systems of electrical power system
Computer interfaces
Automotive
Home appliances
Notices
The maximum DC load is 10A, the maximum DC load voltage is 30V the maximum AC load is 10A,
the maximum AC load voltage is 250V.
Why is it overheating when the relay is under use? If the load voltage or current is rather high, it
will give off extra heat, it is all right when the temperature is confined within 65℃. You are advised
to choose another one that can support larger power if the temperature is upper 65℃.
The relay will discharge spark or magnetic field during the process of mechanical opening and
closing. In order to prevent it from being interfered, you’d better keep it away from other MCU or
chips.
Before we continue with this lesson, I will warn you here that we will use High Voltage which if incorrectly
or improperly used could result in serious injuries or death. So be very caution of what you are doing.
Example
Arduino Control Lamp
Overview
In this example, we will show how to use the Osoyoo UNO board to control a relay to turn on/off the lamp.
Connection
Build the circuit as below digram:
WARNING – THIS PROJECT INVOLVES HIGH VOLTAGES THAT CAN CAUSE SERIOUS INJURY OR
DEATH. PLEASE TAKE ALL NECESSARY PRECAUTIONS, AND TURN OFF ALL POWER TO A
6/8
CIRCUIT BEFORE WORKING ON IT.
Code Program
After above operations are completed, connect the Arduino board to your computer using the USB cable.
The green power LED (labelled PWR) should go on.Open the Arduino IDE and choose corresponding
board type and port type for you project. Then load up the following sketch onto your Arduino.
void setup()
{
pinMode(relayPin, OUTPUT); //initialize the LED as output
Serial.begin(9600); // start serial port at 9600 bps:
while (! Serial);
Serial.println("Please input your command to control this Lamp:"); //print
message on serial monitor
}
void loop()
{
//read string from serial monitor
if(Serial.available()) // check if data has been sent from the computer
{ comdata= Serial.read();
Serial.println(comdata);
if(comdata == 49)
{
7/8
digitalWrite(relayPin, HIGH);//turn the lamp on
Serial.println("light is on");
}
else if(comdata == 48)
{
digitalWrite(relayPin, LOW);//turn the lamp off
Serial.println("light is off");
}
}
}
Running Result
A few seconds after the upload finishes, open the Serial Monitor, input 1, you will see the lamp will be
turned on; input 0(zero), you will see the lamp will be turned off.
8/8