How to Connect a Relay Module with Arduino – Step-by-Step

A relay module with Arduino is one of the most essential circuits in electronics engineering. A relay acts as an electrically operated switch that allows a low-power circuit to control a high-power device such as a light, motor or fan. It is widely used in automation projects, IoT systems and final year projects for students in Pakistan.

Relay module wiring diagram — Arduino UNO, 1-channel relay module, COM and NO terminals, 12V bulb.

Introduction – What Is a Relay and Why It's Used in Electronics

A relay is an electrically operated switch. When a small current flows through the coil, it creates a magnetic field. This field pulls a metal armature, which closes (or opens) a set of contacts, allowing current to flow through another circuit.

In simple terms, your Arduino board controls the small input current, while the relay switches a larger current for appliances. The relay module and Arduino combination provides isolation between the control and power circuits — the Arduino never touches the load's power directly, which is what makes the setup safe for automation and industrial projects.

Relays are crucial in IoT systems, Arduino robots, home automation and industrial control panels.

COM, NO and NC – The Three Terminals

The load side of a relay module has three screw terminals. Understanding them is the whole point of the module:

  • COM (Common) – the terminal that is always connected to one side of the switch. The power supply goes here.
  • NO (Normally Open) – connected to COM only when the relay is ON. A light wired to NO stays OFF until the Arduino turns the relay on. This is the terminal you want for most projects.
  • NC (Normally Closed) – connected to COM when the relay is OFF, and disconnected when it turns ON. Use it when the load should run until the Arduino switches it off.

For the light in this guide, use COM + NO: the bulb stays off until the Arduino turns the relay on.

Types of Relays – Mechanical and Solid-State

There are two primary types of relays used in engineering projects:

1. Electromechanical Relays (EMR)

These relays use physical moving parts to make and break electrical connections. They are common in DIY projects, school projects and basic automation systems. You can hear them click when they switch.

2. Solid-State Relays (SSR)

SSRs have no moving parts. They use semiconductor components for faster switching, long life and silent operation. They are ideal for industrial automation and CNC projects.

This guide uses the common 1-channel electromechanical relay module — the blue board with one relay, three control pins (VCC, GND, IN) and three screw terminals (COM, NO, NC).

Components Required

ComponentPrice / link
Arduino UNO R3 DIPArduino UNO R3 DIP ATmega328P with USB Cable — Rs 1,200
1-channel relay module 5V1 Channel Relay Module 5V — Rs 155
Jumper wires40-Pin Jumper Wires 30cm — Rs 180
12V 2A AC/DC adapter (load power supply)12V 2A AC/DC Adapter — Rs 275
12V DC bulb (test load)No QKZEE listing — available at the Hall Road shop on request

Circuit Connections

Control Side – Arduino to Relay Module

Relay module pinArduino pin
VCC5V
GNDGND
IND7

Load Side – Relay to Bulb

ConnectionWhere it goes
12V supply +Relay COM terminal
Relay NO terminalOne side of the 12V bulb
Other side of the 12V bulb12V supply −

When the relay is ON, COM connects to NO, the circuit closes, and the bulb lights. When the relay is OFF, COM disconnects from NO and the bulb goes out. The NC terminal is not used in this circuit.

Steps

  1. Connect the VCC of the relay module to the 5V pin of the Arduino.
  2. Connect GND to the GND pin of the Arduino.
  3. Connect the IN pin of the relay module to Digital Pin 7 of the Arduino.
  4. Connect the 12V supply + to the COM terminal of the relay.
  5. Connect the NO terminal to one side of the 12V bulb, and the other side of the bulb to the 12V supply −.

⚠️ Safety: Test with 12V DC First — Never Wire 220V Mains Live

A relay can switch 220V mains, but do not use mains for your first test. Test the circuit with the 12V DC bulb first — if the wiring is wrong, the worst that happens is a bulb that does not light. With 220V mains, a wrong wire can give you a serious shock or start a fire. Never touch the relay's screw terminals while the circuit is powered. If your project must switch a real 220V appliance, get an adult or an electrician to check your wiring before you plug it in, and never work on it while it is connected to the mains.Arduino Code Example – Controlling a Light or Fan

const int relayPin = 7;   // IN pin of the relay module

void setup() {
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH);   // relay OFF (most modules are active LOW)
}

void loop() {
  digitalWrite(relayPin, LOW);    // relay ON — COM connects to NO, bulb lights
  delay(3000);
  digitalWrite(relayPin, HIGH);   // relay OFF — COM disconnects from NO
  delay(3000);
}

Active LOW — read this before you upload. Most 1-channel relay modules are ACTIVE LOW: the relay clicks ON when IN is LOW and OFF when IN is HIGH. That is why the code above turns the relay on with LOW, not HIGH. The old version of this post did digitalWrite(relayPin, HIGH); // Turn ON relay — on the common active-low module, that leaves the relay OFF, and the bulb never lights. If your module is the active-HIGH type (it clicks when IN goes HIGH), swap the two writes.

This code alternates the relay ON and OFF every 3 seconds. You can use it to control a light, fan or even a motor. For IoT-based automation, this code can be modified using Firebase, Blynk IoT or ThingSpeak IoT platforms, which are frequently used in final year projects in Lahore and engineering universities across Pakistan.

How It Works

  1. The Arduino sets D7 LOW. The relay module's transistor switches the coil on, the armature moves, and COM connects to NO.
  2. The 12V circuit closes (supply + → COM → NO → bulb → supply −) and the bulb lights.
  3. The Arduino sets D7 HIGH. The coil switches off, the armature springs back, COM disconnects from NO, and the bulb goes out.
  4. The Arduino's 5V side and the load's 12V side never touch each other — the relay's contacts are the only connection, and they are isolated from the control pins.

Applications – Home Automation and Industrial Control

Relay modules are vital components in both home and industrial automation. Let's look at some real-world applications:

1. Home Automation Systems

Relays are used to control lights, fans and home appliances via Arduino or ESP8266 Wi-Fi boards. This setup is ideal for students aiming to build IoT smart homes.

2. Industrial Automation

In industrial projects, relays manage heavy machinery, CNC automation and motor controllers. They offer electrical isolation and safety.

3. Robotics and DIY Projects

Arduino robots often use relays to control motors, sensors and other components. It is a must-learn module for electronics engineering students working on final year projects.

4. Biomedical and Mechanical Projects

Relays can also switch sensors, pumps or valves in medical science model projects and mechanical engineering projects.

We use the relay in our automatic tap water system — the IR sensor detects your hand and the relay switches the water pump on. We also use it in our IoT geyser safety system — the relay switches the heater off when the temperature gets too high.

Where to Buy the Parts

The Arduino UNO (Rs 1,200), 1-channel relay module (Rs 155), jumper wires (Rs 180) and 12V 2A adapter (Rs 275) are available at QKZEE Technologies, Shop 20, 1st Floor, Al-Khalil Center, Hall Road, Lahore, and online at qkzeetech.com with delivery all over Pakistan — see the links above. The 12V DC bulb is available at the Hall Road shop on request.

Still Stuck?

If the relay does not click, or the bulb never lights, message us — tell us whether the relay clicks when you upload the code, and what the Serial Monitor shows, and we will help you find the fault.

WhatsApp YouTube

FAQs

Why does my relay not click?

Check the wiring (VCC → 5V, GND → GND, IN → D7) and that the Arduino is powered. If the module has a jumper between VCC and JD-VCC, leave it in place for this circuit — removing it is only for separate relay power supplies.

Why does the bulb never light even though the relay clicks?

The load side is wired wrong. Check: supply + → COM, NO → bulb, bulb → supply −. If you wired the bulb to NC instead of NO, the bulb will be ON when the relay is OFF and OFF when it is ON — swap NC for NO.

What is the difference between NO and NC?

NO (Normally Open) connects to COM only when the relay is ON — the load stays off until the Arduino turns it on. NC (Normally Closed) connects to COM when the relay is OFF — the load runs until the Arduino turns it off.

Can I switch a 220V bulb with this relay?

The relay's contacts are rated for it (most 1-channel modules are rated 10A at 250V AC), but do not do it as a first test. Test with 12V DC first, and get an adult or an electrician to check your mains wiring before you plug it in. Never touch the terminals while powered.

Why does my code turn the relay on with LOW?

Most 1-channel relay modules are active LOW — the relay clicks ON when IN is LOW. If your module is active HIGH, swap LOW and HIGH in the code.

Can I control the relay from my phone?

Yes — connect a NodeMCU or ESP32 instead of the UNO, and use Blynk or ThingSpeak to switch the relay from a phone. The relay wiring stays the same; only the control board changes.

Conclusion – Safety Tips and Best Practices

When working with relay modules, always understand the voltage ratings and isolation requirements. Test with 12V DC first, never wire 220V mains live, and double-check your connections before powering the circuit. A relay is the part that lets a small Arduino control big things — learn its three terminals (COM, NO, NC) and its active-LOW behaviour, and you can switch almost anything safely.