Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES Buy from JP

Content

  1. Introduction
  2. Preparations
  3. About the OSOYOO Relay Module
  4. Example

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 OSOYOO Relay Module works and how to use it with the Osoyoo Uno board to control high voltage devices.

Note: In this lesson, we set the relay module to be active high

Preparations

Hardware

Software

About OSOYOO Relay Module

Overview

This is a 5V 1-Channel Relay Module board, Be able to control various appliances, and other equipment with large current. It can be controlled directly by Microcontroller (Raspberry Pi, Arduino, 8051, AVR, PIC, DSP, ARM, ARM, MSP430, TTL logic). Very useful project for application like Micro-Controller based projects, Remote controller, Lamp on Off, and any circuits which required isolated high current and high voltage switching by applying any TTL or CMOS level voltage.


Features

Pins Out

Input

It has a 1*3(2.54mm pitch) XH2.54 header for connecting power (5V and 0V), and for controlling the relay. The pins are marked on the PCB:

Output

This relay module could be considered like a series switches: 1 normally Open (NO), 1 normally closed (NC) and 1 common Pin (COM).

How relay works?

The working of a relay can be better understood by explaining the following diagram given below.

There are 5 parts in every relay:

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 (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.

4. Set of electrical contacts – There are two contact points:

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

5. Molded frame – Relays are covered with plastic for protection.

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.

High Voltage Warning


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.

Examples

Using the Arduino to Control the Relay

In this example, when a HIGH level is supplied to signal terminal of the relay module, the LED on the relay will light up. Otherwise, it will turn off. If a periodic high and low level is supplied to the signal terminal, you can see the LED will cycle between on and off.

Connection

First, please plug OSOYOO Magic I/O shield into UNO board:

Then connect the OSOYOO 1-Channel Relay Module to the port D3 of the Magic I/O shield with 3-pin PNP cables as below:

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.

int SIG = 3;
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(SIG, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(SIG, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(SIG, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Running Result

A few seconds after the upload finishes, you should see the LED cycle between on and off.