Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

An Essential Introduction to DC Relays in Arduino Projects: What They Are and How They Work

DC relays are essential components in many Arduino projects, allowing you to control high-power devices like motors, lights, or other electrical equipment using the low-power signals from an Arduino board. A relay acts as an electrically operated switch that can be turned on or off, controlling the flow of current. In this article, we’ll explore the basics of relays, how they work, and how you can integrate them into your projects to expand the capabilities of your system.

Input and Output Interface

Relays

In an Arduino project, understanding the input and output interfaces of a DC relay is crucial for controlling high-power devices safely and efficiently. Let’s break down these two interfaces:

Input Interface (Low Voltage)

The input interface refers to the part of the relay that receives the low-power control signal from the Arduino. There are three connection pins in this area.

  • VCC: This pin is connected to the Arduino’s 5V pin for power.
  • GND: This pin is connected to the Arduino’s GND pin.
  • IN: This pin is connected to a digital output pin on the Arduino.

Output Interface (High Voltage)

The output interface refers to the part of the relay that controls the external high-power circuit. The relay has a set of switch contacts, usually labeled as NO (Normally Open), NC (Normally Closed), and COM (Common). These contacts connect to an external circuit or device (e.g., a motor, light, or fan) that the relay will control.

  • NC (Normally Closed): In its default state, the relay is closed. The NC contact is connected to the load’s negative terminal when the relay is not activated. The current flows continuously until a signal is sent from the Arduino to the relay module, which opens the circuit and stops the current.
  • NO (Normally Open): The relay is open by default, so the circuit is disconnected. When the relay is activated, the NO contact closes, allowing current to flow to the connected device.
  • COM (Common): The COM terminal is the central point where either the NO or NC contact will connect, depending on whether the relay is activated or not. This contact is connected to the load’s positive terminal.

 We usually only use two of these pins:

  • NO + COM: normally open mode
  • NC + COM: normally closed mode

Types of Relays

In relay-based circuits, the terms “high-level trigger” and “low-level trigger” refer to how the relay is activated, based on the input signal provided to the relay’s control pin. The trigger type determines whether the relay is activated when the input signal is high (5V) or low (0V).

  • High level trigger relay: This relay is activated when a high voltage (5V) is applied to the control pin.
  • Low level trigger relay: This relay is activated when a low voltage (0V) is applied to the control pin.

How It Works

There are two input modes that make the relay works oppositely.

  • High level trigger mode
  • Low level trigger mode

There are two output modes that make the relay works oppositely.

  • Normally open mode
  • Normally closed mode

The combination of input and output modes includes:

  • High level trigger relay + normally open mode
  • High level trigger relay + normally closed mode
  • Low level trigger relay + normally open mode
  • Low level trigger relay + normally closed mode

The next will show the normally open mode in detail.

The circuit is normally open. The relay is activated when the control pin receives a low signal (0V). Then, the NO contact closes the circuit, causing the light to turn on.

The circuit is normally open. The relay is activated when a high voltage (5V) is applied to its control pin. Then, the the circuit is closed and the lamp lights on.

Code

// Low-level trigger relay

#define RELAY_PIN 2

void setup() 
{
  pinMode(RELAY_PIN, OUTPUT);
}

// Switch on/off relay after every 2 seconds. 
// LOW signal will turn on relay and HIGH signal will turn off relay.

void loop() 
{
  digitalWrite(RELAY_PIN, LOW);
  delay(2000);
  digitalWrite(RELAY_PIN, HIGH);
  delay(2000);  
}

Project

The following example demonstrates the Arduino project incorporating the DC relay.