Apoorvs
Apoorvs
On
Wiring a relay module to the Arduino UNO board
DEPARTMENT OF
ELECTRONICS & COMMUNICATION
ENGINEERING
CERTIFICATE
Certified that the Project Based Learning report entitled, “Wiring a relay module to the
Arduino uno board ” is work done by
in partial fulfilment of the requirements for the award of credits for Project Based Learning
(PBL) in Embedded System Design of Bachelor of Technology Semester V, in Electronics &
Communication Engineering.
Date:
First and foremost, we would like to express our gratitude to our Mentor, Dr. Arundhati A.
Shinde who was a continual source of inspiration. she pushed us to think imaginatively and
urged us to do this project without hesitation. Her vast knowledge, extensive experience, and
professional competence in the subject of Electronic & Communication enabled us to
successfully accomplish this project. This endeavor would not have been possible without her
help and supervision.
Sneha Amodkar
Apoorva Das
Anushka Srivastav
INDEX
Problem Statement
1 1
2
Introduction
2
Conclusion 10
6
7 Reference 11
Problem statement
Solution
In this project, the Arduino Uno will interface with a relay module that serves as an
intermediary between the microcontroller and the high-power circuit controlling the bulb. The
Arduino Uno, equipped with digital output pins, will send signals to the relay module,
triggering it to either close or open the circuit, thereby turning the bulb on or off. This setup
leverages the relay module's capability to handle higher voltages and currents safely,
maintaining isolation between the low-voltage Arduino circuitry and the mains-powered bulb.
.
1
INTRODUCTION
Wiring a relay module to an Arduino Uno board is an essential skill for anyone looking to
expand their knowledge in electronics, automation, and embedded systems. A relay is an
electrically operated switch that can control high-power circuits with a low-power signal,
making it ideal for applications where the Arduino, which operates on low voltage (5V), needs
to control high-voltage devices, such as household appliances, lights, motors, or industrial
equipment.
One of the main challenges when working with microcontrollers like the Arduino is their
inability to handle high current or high voltage directly. If you want to control a 220V AC
appliance or a high-power DC motor, directly connecting it to the Arduino would damage the
board. This is where a relay comes in—it acts as an electrically controlled switch, enabling the
Arduino to turn devices on or off without direct electrical contact with high-voltage circuits.
Using a relay allows you to bridge the gap between low-voltage logic (from the Arduino) and
high-voltage, high-current devices, adding versatility to your projects. Relay modules are
typically opto-isolated, meaning there is no direct electrical connection between the control side
(Arduino) and the load side (the device being controlled), providing an extra layer of safety.
This setup is commonly used in applications like home automation systems, where you can
control lights, fans, or heaters remotely. It’s also prevalent in industrial automation, robotics,
and even DIY projects that require controlling heavy-duty electrical components through a low-
power microcontroller. Understanding how to wire a relay module to the Arduino opens up
numerous possibilities for automation and innovation, allowing you to take on projects
involving both low-power digital systems and high-power electrical loads with confidence
2
COMPONENTS USED
To make a temperature and humidity measuring device using DHT11 and ESP8266, and
display the readings on an LCD screen, the following components are required:
1.Relay module:
A relay module is an electrical switch that allows a low-power signal (like from an Arduino
or other microcontroller) to control high-power devices. Here are its key features:
Key Features:
. Electrical Isolation
Provides isolation between the low-power control circuit (microcontroller) and the high-power
circuit (like AC appliances), ensuring safety.
Operates with low voltage (3.3V or 5V) from microcontrollers and switches higher voltage
loads, such as 110V/220V AC or 30V DC devices.
NO contact: Default state is open, current flows when the relay is activated.
NC contact: Default state is closed, current stops when the relay is activated.
Relays are designed to handle large currents and high voltages, typically rated for 10A at 250V
AC or 30V DC.
Many relay modules use opto-isolators (opto-couplers) to electrically separate the low-voltage
control circuit from the high-voltage load, enhancing protection against surges and electrical
noise.
3
2.Arduino uno :
The Arduino Uno is one of the most popular and versatile microcontroller boards in the
Arduino family, widely used for prototyping and electronics projects. Here are the key features
that make it highly suitable for beginners and experienced developers alike
Key Features :
1. Microcontroller
2. Operating Voltage
5V: The board operates at 5V, which is compatible with most sensors, modules, and components
3. Clock Speed
16 MHz: The Arduino Uno runs at a clock speed of 16 MHz, which is adequate for most
general-purpose projects, providing sufficient processing power for a wide range of tasks.
4. USB Interface
USB Type-B Port: The Arduino Uno uses a USB connection for programming and power
supply. This interface also allows for serial communication between the Arduino and your
computer for debugging and monitoring.
Multiple Power Inputs: You can power the Arduino Uno via the USB cable (5V), a barrel jack
(7-12V), or through the Vin pin (7-12V). It also includes a voltage regulator to ensure stable 5V
and 3.3V power outputs
4
3. Potentiometer:
A potentiometer is a three-terminal variable resistor commonly used to adjust voltage,
control devices, or as a user input component in electronics. Here are its key features:
Key Features:
1. Adjustable Resistance
The resistance can be manually varied by rotating or sliding a control knob, providing a
continuous range of values.
2. Three Terminals
The potentiometer acts as a voltage divider, producing a variable output voltage based on the
position of the wiper. The output voltage ranges between the supply voltage and ground.
5. Types of Potentiometers
6. Resistance Range
Available in various resistance values (e.g., 1KΩ, 10KΩ, 100KΩ), depending on the application.
5
CIRCUIT CONNECTIONS
CIRCUIT Diagram
6
CODE IMPLEMENTATION
void setup() {
Serial.begin(115200);
pinMode(relay, OUTPUT);
}
void loop() {
// Normally Open configuration, send LOW signal to let current flow
// (if you're usong Normally Closed configuration send HIGH signal)
digitalWrite(relay, LOW);
Serial.println("Current Flowing");
delay(1000);
7
CODE EXPLANATION
The code provided is used to control a relay module connected to an Arduino Uno. A relay is an
electrically operated switch that allows control over a high-voltage device (like a light or motor)
using a low-voltage signal from the Arduino. The code operates the relay in a Normally Open
(NO) configuration, where the device is normally off until the relay is activated to allow current
to flow.
Code Breakdown:
1. Define Pin for Relay
cpp
Copy code
const int relay = 12;
This defines relay as pin 12 on the Arduino. This pin will be used to control the relay.
2. Setup Function
cpp
Copy code
void setup() {
Serial.begin(115200);
pinMode(relay, OUTPUT);
}
3. Loop Function
cpp
Copy code
void loop() {
// Normally Open configuration, send LOW signal to let current flow
digitalWrite(relay, LOW);
Serial.println("Current Flowing");
delay(1000);
digitalWrite(relay, LOW);: This sends a LOW signal to the relay's control pin (pin 12).
In a Normally Open (NO) configuration, setting the pin to LOW closes the relay,
allowing current to flow through the relay and powering the connected device.
o Serial.println("Current Flowing");: Prints "Current Flowing" to the Serial
Monitor, indicating that the relay is closed and the current is flowing through the load
(device).
o delay(1000);: Pauses the program for 1 second (1000 milliseconds), keeping the
relay closed during this time.
8
digitalWrite(relay, HIGH);: This sends a HIGH signal to the relay. In a Normally Open
configuration, setting the pin to HIGH opens the relay, stopping the current flow and
turning off the connected device.
o Serial.println("Current not Flowing"); : Prints "Current not Flowing" to the
Serial Monitor, indicating the relay is open and current is not flowing.
o delay(1000);: Pauses the program for 1 second, keeping the relay open during this
time.
Summary:
The code alternates the relay state every second, turning the connected device on and off in a
loop, while providing feedback on the Serial Monitor
9
CONCLUSION
In conclusion, wiring a relay module to an Arduino Uno is a fundamental technique that greatly
enhances the capabilities of your projects by enabling control over high-power devices using the
low-voltage logic of the Arduino. The relay acts as an electrically controlled switch, allowing
you to safely manage devices that require higher voltage or current than the Arduino can directly
handle.
Additionally, through Arduino code, you can automate tasks, turning devices on or off at specific
times or under certain conditions, which is ideal for home automation, industrial systems,
robotics, and smart energy management. The use of a relay module provides flexibility, safety,
and reliability, making it an essential tool for controlling complex electronic systems in a wide
variety of applications.
CO 6 : Select and use the appropriate Arduino Uno and Relay Module for real-world
applications.
10
REFERENCE
https://www.researchgate.net/publication/332835074_Research_Paper_On_Home_Automatio
n_Using_Arduino
https://quartzcomponents.com/blogs/electronics-projects/home-automation-project-using-
arduino-uno-and-2-channel-relay-
module?srsltid=AfmBOopSPRsCBJcI6icjx7rlndmUERoy77ufuyIwViWW4DDL7V_7XzeG
https://www.instructables.com/Home-Automation-With-Blink-eyeorgan/
11