0% found this document useful (0 votes)
215 views

Project Report On Smart Lab

Smart sensors are devices that take input from the physical environment, perform predefined functions upon detecting specific inputs, process data, and pass it on. They enable more accurate automated data collection with less noise. Smart sensors are crucial elements of IoT and are used in a wide variety of monitoring and control applications. They typically contain sensors, microprocessors, and communication components. The document then discusses the components and modules required for smart sensors, including an Arduino UNO board, relay module, sensors, power supplies, and software. It provides examples of smart sensor uses in industrial environments and security systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
215 views

Project Report On Smart Lab

Smart sensors are devices that take input from the physical environment, perform predefined functions upon detecting specific inputs, process data, and pass it on. They enable more accurate automated data collection with less noise. Smart sensors are crucial elements of IoT and are used in a wide variety of monitoring and control applications. They typically contain sensors, microprocessors, and communication components. The document then discusses the components and modules required for smart sensors, including an Arduino UNO board, relay module, sensors, power supplies, and software. It provides examples of smart sensor uses in industrial environments and security systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

1

CHAPTER 1: SMART SENSORS

A smart sensor is a device that takes input from the physical environment and uses built-in
compute resources to perform predefined functions upon detection of specific input and then
process data before passing it on.

Smart sensors enable more accurate and automated collection of environmental data with less
erroneous noise amongst the accurately recorded information. These devices are used for
monitoring and control mechanisms in a wide variety of environments including smart grids,
battlefield reconnaissance, exploration and many science applications.

The smart sensor is also a crucial and integral element in the internet of things (IoT), the
increasingly prevalent environment in which almost anything imaginable can be outfitted with
a unique identifier and the ability to transmit data over the internet or a similar network. One
implementation of smart sensors is as components of a wireless sensor and actuator network
(WSAN) whose nodes can number in the thousands, each of which is connected with one or
more other sensors and sensor hubs, as well as individual actuators.

Compute resources are typically provided by low-power mobile microprocessors. At a


minimum, a smart sensor is made of a sensor, a microprocessor and communication technology
of some kind. The compute resources must be an integral part of the physical design -- a sensor
that just sends its data along for remote processing isn't considered a smart sensor.

1.1 SMART SENSORS USE

There are countless use cases for smart sensors. They are very commonly used in industrial
environments and are the driving force behind Industry 4.0.

 Factories often use smart temperature sensors to make sure machines are not
overheating, and vibration sensors to make sure machines aren't at risk of vibrating
loose. Smart sensors also enable process control, such as monitoring a process, like
manufacturing an item, and making any adjustments that might be required to meet
quality or production goals. This was once a manual process, but smart sensors can be
used to automate process control.

 Smart sensors also play a key role in modern security systems. Thermal imaging
sensors can be used to detect an intruder's body heat. Similarly, devices such as smart
locks, motion sensors, and window and door sensors are commonly connected to a
common network. This enables the security sensors to work together to paint a
comprehensive picture of the current security status.
2

1.2 Components and Modules Required

 Hardware Used
● Arduino UNO
● Relay Module
● AC/DC Adaptor
● PIR Sensor
● 9v Power Supply
● Breadboard
● Wires

 Software Used

● Arduino IDE
● Wokwi Simulation
3

CHAPTER 2:
ARDUINO

2.1 WHAT IS ARDUINO?

Arduino Uno is an open-source microcontroller board based on the processor ATmega328P.


There are 14 digital I/O pins, 6 analog inputs, a USB connection, a power jack, an ICSP header,
and a reset button. It contains all the necessary modules needed to support the microcontroller.
Just plug it into a computer with a USB cable or power it with an adapter to get started. You
can experiment with your Arduino without worrying too much about it. In the event of a worst-
case scenario, you could buy a new one as the Uno is very economical compared to other boards
like raspberry pi, STM, etc.
The Arduino UNO is a standard board of Arduino. Here UNO means 'one' in Italian. It was
named UNO to label the first release of Arduino Software. It was also the first USB board
released by Arduino. It is considered a powerful board used in various projects. Arduino.cc
developed the Arduino UNO board.
Arduino UNO is based on an ATmega328P microcontroller. The name of this Micro Controller
is ATmega328p which is a product of Atmel.
● 32 - represents its flash memory capacity which is 32KB.
● 8 - represents its CPU type which is 8 bits.
● p - simply denotes that it needs less power to work than its earlier version.

It is easy to use compared to other boards, such as the Arduino Mega board, etc. The board
consists of digital and analog Input/Output pins (1/0), shields, and other circuits.
The Arduino UNO includes 6 analog pin inputs, 14 digital pins, a USB connector, a power
jack, and an ICSP (In-Circuit Serial Programming) header. It is programmed based on IDE,
which stands for Integrated Development Environment. It can run on both online and offline
platforms.
It is one of the most popular development boards and is widely used in various electronics
projects. The Arduino Uno board has 14 digital input/output pins, 6 analog inputs, a 16 MHz
quartz crystal, a USB connection, and a power jack. It is programmed using the Arduino
4

Integrated Development Environment (IDE) and supports C/C++ programming language. The
Arduino Uno can be used to control various electronic components like LEDs, motors, sensors,
etc., and is a great platform for both beginners and experienced makers to get started with
electronics and programming.
The Arduino Uno has a number of input/output (I/O) pins that allow you to connect various
electronic components such as LEDs, sensors, and motors. It also features an onboard voltage
regulator, which helps to stabilize the voltage levels for reliable operation. Additionally, the
Arduino Uno can be easily programmed using the Arduino Integrated Development
Environment (IDE), which is a user-friendly software environment that supports C/C++
programming languages. Overall, the Arduino Uno is a versatile and flexible platform that is
widely used for a variety of projects, from simple hobby projects to complex industrial
applications.

Figure 2.1
5

2.2 MAIN FEATURES OF ARDUINO

Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital


input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic
resonator, a USB connection, a power jack, an ICSP header and a reset button. It contains
everything needed to support the microcontroller; simply connect it to a computer with a USB
cable or power it with a AC-to-DC adapter or battery to get started. You can tinker with your
UNO without worrying too much about doing something wrong, worst case scenario you can
replace the chip for a few dollars and start over again.

Replaceable chip

The ATmega328P can easily be replaced, as it is not soldered to the board.

EEPROM

The ATmega328P also features 1kb of EEPROM, a memory which is not erased when
powered off.

Battery Connector

The Arduino UNO features a barrel plug connector, that works great with a standard 9V
battery.

Compatibility

• Arduino IDE
• Arduino CLI
• Web Editor

2.3 DATA TRANSMISSION IN ARDUINO UNO


1. Arduino can be used to communicate with a computer, another Arduino board or other
microcontrollers. The ATmega328P microcontroller provides UART TTL (5V) serial
communication.
2. Serial communication can be done using digital pin 0 (Rx) and digital pin 1 (Tx). An
ATmega16U2 on the board channels this serial communication over USB and appears as a
virtual com port to software on the computer.
6

3. The ATmega16U2 firmware uses the standard USB COM drivers, and no external driver
is needed. However, on Windows, a .inf file is required.
4. The Arduino software includes a serial monitor which allows simple textual data to be sent
to and from the Arduino board.
5. There are two RX and TX LEDs on the arduino board which will flash when data is being
transmitted via the USB-to-serial chip and USB connection to the computer (not for serial
communication on pins 0 and 1).
6. A Software Serial library allows for serial communication on any of the Uno's digital
pins.
The ATmega328P also supports I2C (TWI) and SPI communication and the Arduino software
includes a Wire library to simplify use of the I2C bus.

2.4 APPLICATION OF ARDUINO UNO

Arduino Uno comes with a wide range of applications. Following are some of the main
applications of the board.
 Parking Lot Counter
 Arduino Uno is used in Do-it-Yourself projects prototyping.
 Traffic Light Count Down Timer
 Emergency Light for Railways
 Embedded System
 In developing projects based on code-based control
 Medical Instrument
 Security and Defence System
 Weighing Machines
 Home Automation
 Industrial Automation
 Development of Automation System
 Digital Electronics and Robotics
 Designing of basic circuit designs.
7

These are all the applications of Arduino Uno. Anyway, there are a lot of other microcontrollers
available in the market but, why do you prefer Arduino Uno?
Well, the answer is that the Arduino UNO as well as Arduino Nano V3 are the most official
versions that come with Atmega328 8-bit AVR Atmel microcontroller where RAM memory is
32KB. And, Arduino comes with a big community that is developing and sharing the
knowledge with a wide range of audience. When you decide Arduino board over other
controllers, you don’t need to arrange extra peripherals and devices as most of the functions
are readily available on the board that makes your project economical in nature and free from
a lot of technical expertise. That’s why, if you are planning to create a project relating to digital
electronics, embedded system, robotics, or IoT, then using Arduino Uno would be the best,
easy, and the most economical option.

2.5 ARDUINO UNO – ATMEGA 328 PIN MAPPING

Figure 2.2
8

2.6 THE HARDWARE STRUCTURE OF ARDUINO UNO

● Microcontroller
● 14 Digital Pin
● Analog Pins
● Power Supply
● Power Jack
● USB Port
● Reset Button

Microcontroller: Microcontroller is the central processing unit of Arduino Uno.


3 Microcontroller Board is based on the Microchip Technology ATmega328 8-bit Microcontroller
(MCU). Arduino Uno features 14 digital input/output pins (six of which can be used as PWM outputs),
six analog inputs, and a 16MHz quartz crystal. Uno also includes a USB connection, a power jack, an In-
Circuit Serial Programming (ICSP) header, and a reset button. This Arduino MCU board contains
everything the user needs to support the MCU. The user can get started by connecting the Uno to a
computer with the USB cable or by powering it with an AC/DC adapter or battery. The Uno can be
programmed with Arduino Software (Integrated Development Environment). The ATmega328 on the
Uno comes pre-programmed with a bootloader that allows the user to upload new code to the MCU
without the use of an external hardware programmer.
Arduino Uno differs from preceding boards in that it does not use the FTDI USB-to-serial driver chip.
This board instead features the Atmega16U2 programmed as a USB-to-serial converter.

Figure 2.3
9

Digital Pins: There are 14 digital pins on Arduino Uno which can be connected to components like
LED, LCD, etc.

The pins on the Arduino can be configured as either inputs or outputs. This document explains the
functioning of the pins in those modes. While the title of this document refers to digital pins, it is
important to note that vast majority of Arduino (Atmega) analog pins, may be configured, and used, in
exactly the same manner as digital pins.

2.7 PROPERTIES OF PINS CONFIGURED AS OUTPUT

Pins configured as OUTPUT with pinMode () are said to be in a low-impedance state. This means
that they can provide a substantial amount of current to other circuits. Atmega pins can source
(provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to
other devices/circuits. This is enough current to brightly light up an LED (don't forget the series
resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or
motors.
Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or
destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in
a "dead" pin in the microcontroller, but the remaining chip will still function adequately. For this
reason, it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1k resistors, unless
maximum current draw from the pins is required for a particular application.

Analog Pins: There are 6 analog pins on the Uno. These pins are generally used to connect sensors
because all the sensors generally have analog values. Most of the input components are connected
here.

Arduino Uno boards have six analog input pins, labelled A0 to A5. At first glance A0 to A5 looks
like five pins. Because pin numbering starts from 0, there are actually six pins. In other words, A1
to A5 are five pins. Hence A0 to A5 are six pins.

Arduino MEGA 2560 boards have sixteen analog input pins, labelled A0 to A15. As explained
above, pin numbering starts from 0. Therefore, A0 to A15 are sixteen pins and not fifteen.

Arduino analog input pins read voltages between 0V to 5V by default, with a certain resolution. Ten-
bit binary values represent the voltages read. On the other hand, digital input pins only read two
10

logic levels of 0 or 1.

Figure 2.4

Power Supply: The power supply pins IOREF, GND, 3.3V, 5V, and Vin is used to connect sensors
because all the sensors generally have analog values. Most of the input components are connected
here.

All Arduino boards need electric power to function. A power supply is what is used to provide
electric power to the boards and typically can be a battery, USB cable, AC adapter or a regulated
power source device.

There are different ways to power your Arduino board. The most common way is through the USB
connector available on every board, but there are a few other possibilities to power your board. If
you like to know more about this, the different ways to supply power to your board are listed below:

USB

Arduino boards can operate satisfactorily on power that is available from the USB port. It provides
5V DC voltage and can be sourced from the port from a PC, wall socket adapter or portable power
bank.

AC socket

Some Arduino boards like UNO, MEGA and DUE, come with an AC socket that can be used to
11

power the boards and to supply additional voltage if needed. A power supply adapter that provides
from 7 to 12V (Volts) of DC (Direct Current) is required. The adapter is plugged onto the wall
socket and the other end goes directly onto the board’s AC socket.

Make sure the power adapter complies with your Arduino board specifications.

If you find that additional power is required from your Arduino board to operate it properly, or if
you need to operate the Arduino board disconnected from a USB port.

The AC adapters are commonly available in retail stores for use with consumer products are often
suitable, but make sure that it has the proper connector for plugging into the power socket on your
Arduino board: 5.5mm diameter cylindrical plug with 2.1mm pin hole, and that provides Positive
voltage on the inside pin hole and Negative (or common/ground) voltage on the outside cylindrical
sleeve of the connector plug.

Battery

Some boards come with a Li-Po (Lithium-ion Polymer) battery socket that fits this kind of batteries.
For example, MKR boards (except MKR FOX and WAN 1300) come with this feature. These types
of batteries supply 3.7V, are rechargeable and they can provide higher energy than other lithium
batteries.

VIN

Another way to power your board is by supplying voltage from a regulated power source directly
to the VIN pin. Just need to connect the positive wire from your power supply to VIN and the
negative to GND. Follow your board power specifications to figure out the voltage range that your
board can handle.

VIN pin is an INPUT only.

Power Jack: Uno board can be powered both by an external supply and via USB cable.

Let's talk about when it is recommended to use each of the options ways in which Arduino boards
can be powered:

USB Connector

This option is often recommended when experimenting with small loads that require 5V; the current
12

would be constrained by the USB host device where the board is connected.

Barrel Jack Connector

This option is recommended when a regulated power supply with a barrel jack connector is
available. Current is constrained by the regulated power supply and the onboard voltage regulator.

Battery Connector

This option is recommended for portable projects or projects that need a secondary o backup power
supply. Currently, 3V7 Li-Ion and Li-polymer batteries are supported only; the battery's capacity
constrains current.

VIN Pin

This option is recommended when a regulated power supply without a barrel jack connector is
available. Take into account that using VIN pin should be made carefully since this pin does not
have reverse polarity protection. Current is constrained by the regulated power supply and the
onboard voltage regulator.

3V3/5V Pin

Avoid this option since the risk of damaging the onboard voltage regulator is high. It can be done
safely if the applied voltage to the 3V3 or 5V pins is not higher than the input voltage of the voltage
regulators.

USB Port: This port function is to program the board or to upload the program. The program can
be uploaded to the board with the help of Arduino IDE and USB cables.

Reset Button: This is used to restart the uploaded program.

The RESET button is a white or blue push button located on top of your Arduino board. Pressing it has
the same effect as disconnecting and reconnecting the power supply: The board will wait briefly for a
new sketch to uploaded, then it will start executing any instructions in the sketch from the beginning.
13

Figure 2.5

2.8 ARDUINO UNO SPECIFICATION

● Microcontroller: ATmega328P
● Operating Voltage: 5V
● Input Voltage (recommended): 7-12V
● Input Voltage (limit): 6-20V
● Digital I/O Pins: 14 (of which 6 provide PWM output)
● PWM Digital I/O Pins: 6
● Analog Input Pins: 6
● DC Current per I/O Pin: 20 mA
● DC current for 3.3V Pin: 50 mA
● Flash Memory: 32 KB (ATmega328P) of which
● 0.5 KB used by bootloader
● SRAM: 2 KB (ATmega328P)
● EEPROM: 1 KB (ATmega328P)
● Clock Speed: 16 MHz
14

● LED_BUILTIN: 13

The specifications of Arduino Uno is as given in the table below.

Arduino Uno Specifications Table

ATmega38P – 8 bit AVR family


Microcontroller
microcontroller
Operating Voltage 5V
Recommended Input Voltage 7-12V
Input Voltage Limits 6-20V
Analog Input Pins 6 (A0-A5)
Digital I/O Pins 14 (Out of which 6 provide PWM output)
DC Current on I/O Pins 40mA
DC Current on 3.3V Pin 50mA
Flash Memory 32 KB (0.5 KB is used for Bootloader)
SRAM 2kB
EEPROM 1kB
Frequency (Clock Speed) 16MHz
Table 2.1

Pin's information

Pin Category Pin Name Details


Vin: Input voltage to Arduino
when using an external power
source.
5V: Regulated power supply
used to power
microcontroller and other
Power Vin, 3.3V, 5V, GND
components on the board.
3.3V: 3.3V supply generated
by on-board voltage
regulator. Maximum current
draw is 50mA.
GND: ground pins.

Reset Reset Resets the microcontroller.

Used to provide analog input


Analog Pins A0-A5
in the range of 0-5V
Input/Output Pins Input/Output Pins Can be used as input or
15

output pins.
Used to receive and transmit
Serial 0(Rx), 1(Tx)
TTL serial data.
External Interrupts 2, 3 To trigger an interrupt.
PWM 3, 5, 6, 9, 11 Provides 8-bit PWM output.
10 (SS), 11 (MOSI), 12 (MISO)
SPI Used for SPI communication.
and 13 (SCK)
Inbuilt LED 13 To turn on the inbuilt LED.
Used for TWI
TWI A4 (SDA), A5 (SCA)
communication.

To provide reference voltage


AREF Analogue Reference
for input voltage.

Table 2.2

2.9 FEATURES OF THE ARDUINO UNO BOARD

It is an easy USB interface. This allows interface with USB as this is like a serial device.

The chip on the board plugs straight into your USB port and supports your computer as a virtual
serial port. The benefit of this setup is that serial communication is an extremely easy protocol
which is time-tested and USB makes a connection with modern computers and makes it
comfortable.

It is easy to find the microcontroller brain which is the ATmega328 chip. It has more hardware
features like timers, external and internal interrupts, PWM pins and multiple sleep modes.

It is an open-source design and there is an advantage of being open-source is that it has a


large community of people using and troubleshooting it. This makes it easyto help in debugging
projects.

It is a 16 MHz clock which is fast enough for most applications and does not speed up the
microcontroller.

It is very convenient to manage power inside it and it had a feature of built-in voltage regulation.
This can also be powered directly off a USB port without any external power. You can connect an
external power source of up to 12v and this regulates it to both 5v and 3.3v.

13 digital pins and 6 analog pins. This sort of pin allows you to connect hardware toyour Arduino
Uno board externally. These pins are used as a key for extending the computing capability of the
Arduino Uno into the real world. Simply plug your electronic devices and sensors into the sockets
that correspond to each of these pins and you are good to go.

This has an ICSP connector for bypassing the USB port and interfacing the Arduino directly as a
serial device. This port is necessary to re-bootload your chip if it corrupts and can no longer be used
on your computer.
16

It has 32 KB of flash memory for storing your code.

An on-board LED is attached to digital pin 13 to make the debugging of code and tomake the debug
process easy.

Finally, it has a button to reset the program on the chip.

Advantages
● Not much knowledge is required to get started.
● Fairly low cost, depending on the shields you need.
● Lots of sketches and shields are available.
● No external programmer or power supply needed

2.10 Arduino Uno Pin Configuration

 Serial Pins 0 (Rx) and 1 (Tx):Rx and Tx pins are used to receive and transmit TTL serial data.
They are connected with the corresponding ATmega328P USB to TTL serial chip.

 External Interrupt Pins 2 and 3:These pins can be configured to trigger an interrupt on a low
value, a rising or falling edge, or a change in value.

 PWM Pins 3, 5, 6, 9 and 11:These pins provide an 8-bit PWM output by using analogWrite()
function.

 SPI Pins 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK):These pins are used for SPI
communication.

 In-built LED Pin 13:This pin is connected with an built-in LED, when pin 13 is HIGH – LED
is on and when pin 13 is LOW, it’s off.

Along with 14 Digital pins, there are 6 analog input pins, each of which provide 10 bits of resolution, i.e.
1024 different values. They measure from 0 to 5 volts but this limit can be increased by using AREF pin
with analog Reference() function.

 Analog pin 4 (SDA) and pin 5 (SCA) also used for TWI communication using Wire library.

Arduino Uno has a couple of other pins as explained below:

 AREF: Used to provide reference voltage for analog inputs with analogReference() function.

 Reset Pin: Making this pin LOW, resets the microcontroller.


17

Figure 2.6
18

CHAPTER 3: RELAY MODULE

3.1 WHAT IS RELAY MODULE?

A power relay module is an electrical switch that is operated by an electromagnet. The


electromagnet is activated by a separate low-power signal from a microcontroller. When activated,
the electromagnet pulls to open or close an electrical circuit.

A simple relay consists of a wire coil wrapped around a soft iron core, or solenoid, an iron yoke
that delivers a low reluctance path for magnetic flux, a movable iron armature and one or more sets
of contacts. The movable armature is hinged to the yoke and linked to one or more sets of moving
contacts. Held in place by a spring, the armature leaves a gap in the magnetic circuit when the relay
is de-energized. While in this position, one of the two sets of contacts is closed while the other set
remains open.

When an electrical current is passed through a coil, it generates a magnetic field that in turn
activates the armature. This movement of the movable contacts makesor breaks a connection with
the fixed contact. the contacts were open. When switching off the current to the coil, the armature
is returned, by force, to its relaxed position. This force is usually provided by a spring, but gravity
can also be used in certain applications. Most power relays are manufactured to operate in a quick
manner.

Relay modules are simply circuit boards that house one or more relays. They come in a variety of
shapes and sizes, but are most commonly rectangular with 2, 4, or 8 relays mounted on them,
sometimes even up to 16 relays.
Relay modules contain other components than the relay unit. These include indicator LEDs,
protection diodes, transistors, resistors, and other parts.
• A relay is an electrical switch that can be used to control devices and systems that use higher
voltages. In the case of module relay, the mechanism is typically an electromagnet.
• The relay module input voltage is usually DC. However, the electrical load that a relay will
control can be either AC or DC, but essentially within the limit levels that the relay is designed for.
• A relay module is available in an array of input voltage ratings: It can be a 3.2V or 5V relay
module for low power switching, or it can be a 12 or 24V relay module for heavy-duty systems.
• The relay module information is normally printed on the surface of the device for ready
19

reference. This includes the input voltage rating, switch voltage, and current limit.
The relay module's function is mainly to switch electrical devices and systems on or off. It also
serves to isolate the control circuit from the device or system being controlled. This is important
because it allows you to use a microcontroller or other low-power device to control devices with
much higher voltages and currents.

Another relay module purpose is to amplify the control signal so that it can switch the higher
currents using only a small out of power from a microcontroller.

It is also important to note the difference between a relay and a relay module. A relay is a single
device that has an electromagnet and a switch, or it can be a solid-state type. A relay module, on
the other hand, is a board that has one or multiple relays on it and several other components to
provide isolation and protection. Because of its modular construction, this type of switching and
control device can be many different configurations. It can be a single-channel relay module for a
single load or it can be a multi-channel device with multiple relays to control several circuits.

The relay module working principle is actually quite simple. It uses an electromagnet to open and
close a set of electrical contacts. Here is the sequential working of relay module devices for easier
understanding:
• The typical relay module connection points include an input side that consists of 3 or 4
jumper pins, and an output side that has 3 screw terminals.
• When the control signal is applied to the input side of the relay, it activates the electromagnet,
which attracts an armature.
• This in turn closes the switch contacts on the output (high voltage) side, allowing electricity
to flow and power the device or system that is connected to it.
• To prevent flyback voltage from damaging the relay module circuit and the input device, a
diode is often placed in parallel with the electromagnet coil. This diode is known as a flyback diode.
It allows current to flow in only one direction.
• When a higher level of isolation is required, an optocoupler is used. An opto-isolated relay
module has the photoelectric device on the input side, which is used to control the electromagnet’s
switching action.
Relay modules are available with either normally open (NO) or normally closed (NC) switch
configurations.
• A NO switch is open when the electromagnet is not activated, and closed when it is activated.
20

• An NC relay switch, on the other hand, remains closed by default, and only opens when the
relay is activated.
It works on the principle of electromagnetic attraction. When the circuit of the relay senses the fault
current, it energises the electromagnetic field which produces the temporary magnetic field. This
magnetic field moves the relay armature for opening or closing the connections. The small power
relay has only one contact, and the high power relay has two contacts for opening the switch.

A Relay is an electrical switch which can be controlled by an Arduino or any microcontroller. It is


used to programmatically control on/off devices which use high voltage/current.
It has two groups of pins: input(low voltage group)and output(high voltage group).

Pins in the input group are connected to Arduino, including three pins:
● DC-pin: needs to be connected to GND.
● DC+pin: needs to be connected to VCC.
● IN pin: receives a control signal from Arduino.

Pins in the output group are connected to high-voltage devices including


● COM pin: a common pin used in both normally open and closed modes.
● NO pin: is used in normally open mode.
● NC pin: is used in normally closed mode.
IN Practice we don’t use all pins in the high-voltage group. We use only two of them.
● The normally open and closed modes work oppositely.
● most relay modules support both of these modes.

Normally open (NO) contacts connect the circuit when the relay is activated; the circuit is
disconnected when the relay is Inactive. Normally closed (NC) contact disconnect the circuit when
the relay is activated; the circuit is connected when the relay is inactive.
● Normally open relay: Normally open relays default in the open position, meaning that when
they’re not in use, there is no contact between the circuits. When power is introduced, an
electromagnet pulls the first circuit into contact with the second, thereby closing the circuit and
allowing power to flow through. When the electricity turns off, the circuit opens up again to stop
the flow.
21

3.2 5V RELAY PIN CONFIGURATION

The pin configuration of the 5V relay is shown below. This relay includes 5-pins where each pin and its
functionality are shown below.

Pin1 (End 1): It is used to activate the relay; usually this pin one end is connected to 5Volts whereas
another end is connected to the ground.

Pin2 (End 2): This pin is used to activate the Relay.

Pin3 (Common (COM)): This pin is connected to the main terminal of the Load to make it active

Pin4 (Normally Closed (NC)): This second terminal of the load is connected to either NC/ NO pins. If
this pin is connected to the load then it will be ON before the switch.

Pin5 (Normally Open (NO)): If the second terminal of the load is allied to the NO pin, then the load
will be turned off before the switch.

Signal Pin: The signal pin is mainly used for controlling the relay. This pin works in two cases like
active low otherwise active high. So, in active low case, the relay activates once we provide an active
low signal toward the signal pin, whereas, in an active high case, the relay will trigger once we provide
a high signal toward the signal pin.
However, these modules generally work on an active high signal which will strengthen the relay coil to
make contact with the common terminal with the normally open terminal.

5V VCC: This pin needs 5V DC to work. So 5V DC power supply is provided to this pin.

Ground: This pin connects the GND terminal of the power supply.
22

3.3 FEATURES OF RELAY MODULE

The features of the 5V relay include the following.


 Normal Voltage is 5V DC
 Normal Current is 70mA
 AC load current Max is 10A at 250VAC or 125V AC
 DC load current Max is 10A at 30V DC or 28V DC
 It includes 5-pins & designed with plastic material
 Operating time is 10msec
 Release time is 5msec
Maximum switching is 300 operating per minute.

3.4 COMPONENTS OF RELAY MODULE

The components in a 5v relay module with a single channel include a relay, output terminal,
status LED, power LED, input connector & switching transistor.

Relay
A 5V relay is coated with blue color plastic material. For both AC & DC loads, the utmost
operating voltage & current are also displayed on the relay. This relay operates with 5V, so it
is called a 5V relay.

Output Terminal
The output terminal of the relay module is located at the left-hand side, used to fix an AC/DC
load & AC/DC i/p power source. Every o/p connector’s terminal is connected through NC,
COM pins & NO of the relay.

The relay module consists of screws that are used to connect wires & cables. The max current
supported by this module is 10A & the max contact voltage is 250V AC & 30V DC. Thick
main cables are mainly used whenever high voltage & current load is used.

Status LED
23

Status LED is connected by using a current limiting resistor that is located on the top right side
of the relay module. So this LED illustrates the relay status by activating the relay & coil
through a signal pin. The DC supplies throughout a relay coil.

Power LED
Power LED shows the condition of the power source that is connected through the single
channel module. If we provide the above 5V source toward both the pins of the module like
Vcc & GND, the LED will be damaged due to high voltage.

Freewheeling Diode
The connection of this diode can be done across the coil to keep away from the back EMF
effect, so-called a flyback diode. The type of coil used in the relay is the inductive type. Once
the current supplies throughout an inductive load, then it generates a back EMF voltage, which
may harm the circuit. So, this diode is mainly used to keep away from this effect.

Input Connector
The input connector is located on the right side of the module. This connector is mainly used
to supply a 5V power supply & input signal. In addition, it also supplies power supply toward
the power LED, relay coil & status LED.

Switching Transistor
Generally, the input signal which is given to a relay is from the I/O pins of microcontrollers
like ESP32, TM4C123, Arduino, etc. However, the highest current sourcing capacity of GPIO
pins is usually below 20mA.

Therefore, a switching transistor is used in this module is to strengthen the current to the
requirement of the minimum current level of the relay coil. A switching transistor is used to
control the 5V relay from the microcontroller’s GPIO pin.

Some kinds of relay modules are available with an opto isolator like a switching device to give
optical isolation among high & low voltage circuits.
24

However, if you are utilizing a separate relay exclusive of a module & you want to utilize
several relays within your projects, then a relay driver IC can be used to drive several arrays
from the pins of GPIO in a microcontroller.

3.5 SPECIFICATIONS OF RELAY

The specifications of a 1- channel relay module include the following.

 Voltage supply ranges from 3.75V – 6V


 Quiescent current is 2mA
 Once the relay is active then the current is ~70mA
 The highest contact voltage of a relay is 250VAC/30VDC
The maximum current is 10A

How to Use/Relay Module Circuit Diagram


The circuit diagram of the single-channel relay module circuit is shown below. In this circuit,
we can observe that how the relay module is activated and deactivated through a digital
signal. This signal is applied to a control pin of the relay module. The following circuit diagram
is the internal 5V single channel relay module diagram.

Figure 3.1
25

In the above circuit diagram, the single-channel relay module includes resistors-2, transistors,
LEDs-2 & a 5V relay. Relay modules are available in two types based on the control signal
type used for activation of the relay.

One relay module comes with an NPN transistor whereas another module comes with a PNP
transistor. If the relay module uses an NPN Transistor, then it will activate the relay by applying
an active high signal to the control pin. Alternatively, if a PNP is used then the relay will be
activated through an active low signal on the control pin.
It’s working in proteus simulation software is, when we provide an active high signal toward
the control pin in a relay module, then the coil in the relay activates to make the relay active
through the connection of the NO pin through the COM pin.

Likewise, once we provide an active low no signal toward the relay’s control pin, then the coil
deactivates using a freewheeling diode so that the relay will be deactivated.

In the same way, for PNP based relay module, the relay is activated through an active low
signal, whereas an active high signal will deactivate the relay.

The controlling of a 5v single channel relay module can be done by interfacing any kind of
microcontroller. For that, we use a GPIO pin like a digital o/p pin which gives an active high
& low signal toward the control pin. Once the relay activates, we can listen to an audible sound
that comes from the module

3.6 ADVANTAGES OF RELAY MODULE

The advantages of the relay module include the following.


 A remote device can be controlled easily
 It is triggered with less current but it can also trigger high power machines
 Easily contacts can be changed
 At a time, several contacts can be controlled using a single signal
 Activating part can be isolated
 It can switch AC or DC
 At high temperatures, it works very well
26

3.7 DISADVANTAGES OF RELAY MODULE

The disadvantages of the relay module include the following.


 When contacts of relay modules are used overtime then they may damage
 Noise can be generated through the opening & closing of the contacts.
 Time taken for switching is High

3.8 APPLICATIONS OF RELAY MODULE

Relay modules are used in different applications which include the following.

 Used in over voltage/under voltage protection system


 Mains Switching
 Speed control of motors through start-delta converters
 Automatic electrical appliances
 Electrical isolation in between high & low power sources
 Lights
 AC voltage load switching using less voltage DC
 Delivery of Isolated power
 Home automation projects
 Switching with High Current
 Home Automation Relay Module
 Relay modules are also used in home automation systems to control lights, appliances,
and other devices. The home automation relay module is often used with mains
electricity. So it’s mostly rated for 10A or less for maximum current, and up to 250V
AC.
 Industrial Relay Module
 In industrial applications, the industrial relay module is used to control machinery,
process controls, and other industrial equipment. Other relay module uses in industrial
settings include lighting control and the control of alarm or security systems.
 Automotive Relay Module
 Relay modules are widely used in automotive applications. The automotive relay
module controls things like headlights, turn signals, and even the starter motor. A car
27

relay module is also found in many other automotive circuits such as those that
operate remote starters or theft alarms.
 Arduino Relay Module
 Hobbyists often use a relay module with Arduino in their projects. An Arduino is a
microcontroller board that is widely popular in DIY electronics projects. The relay
module, when paired with an Arduino, can control various appliances and devices.

Figure 3.2
28

CHAPTER 4: PIR SENSOR

4.1 WHAT IS PIR SENSOR?

All living objects, whose body temperature is more than 0°C, emit the heat in form of infrared
radiation through their body, also called as thermal radiations. This Radiated energy is invisible
to human eye. These Signals can be detected by using PIR sensor which is specially designed
for such purpose. PIR sensor i.e. Passive Infrared Sensor, passive word indicates PIR Sensor
does not generate or radiate any energy for detection purposes.

PIR Sensors don't detect or measure "HEAT"; they detect the infrared radiation emitted or
reflected from objects.They are small, inexpensive, low power and easy to use. They are
commonly found at home, medical, factories etc. areas.

A Passive infrared sensor is an electronic sensor that measures infrared light radiating from
objects. PIR sensors mostly used in PIR-based motion detectors. Also, it used in security alarms
and automatic lighting applications. The below image shows a typical pin configuration of the
PIR sensor, which is quite simple to understand the pinouts. The PIR sensor consist of 3 pins,

Figure 4.1
29

 Pin1 corresponds to the drain terminal of the device, which connected to the positive
supply 5V DC.
 Pin2 corresponds to the source terminal of the device, which connects to the ground
terminal via a 100K or 47K resistor. The Pin2 is the output pin of the sensor. The pin 2
of the sensor carries the detected IR signal to an amplifier from the
 Pin3 of the sensor connected to the ground.

4.2 WHAT DOES A PIR SENSOR DETECT?

Generally, PIR sensor can detect animal/human movement in a requirement range. PIR is made
of a pyroelectric sensor, which is able to detect different levels of infrared radiation. The detector
itself does not emit any energy but passively receives it. It detects infrared radiation from the
environment. Once there is infrared radiation from the human body particle with temperature,
focusing on the optical system causes the pyroelectric device to generate a sudden electrical
signal.

Simply, when a human body or any animal passes by, then it intercepts the first slot of the PIR
sensor. This causes a positive differential change between the two bisects. When a human body
leaves the sensing area, the sensor generates a negative differential change between the two
bisects.

Figure 4.2
30

4.3 WORKING PRINCIPLE OF PIR SENSOR

It works on the principle that whenever it detects a change in infrared radiation,it generates a
digital output signal. It consists of a Fresnel lens and a pyroelectric material. Fresnel lens is made
up of high density polythene concentrates so that they fall on pyroelectric material. Metal can
help to make the sensor more immune to temperature, humidity and noise. Pyroelectric material
detects the changes in infrared radiation and generates and output signal. It is made of 2 slots of
material sensitive to IR. When a person comes in range of sensor the first slot creates a positive
differential voltage and when person leaves the second slot it creates a negative differential
voltage.This output signal is then connected to external circuitry and converted to digital output.

The passive infrared sensor does not radiate energy to space. It receives the infrared radiation
from the human body to make an alarm. Any object with temperature is constantly radiating
infrared rays to the outside world. The surface temperature of the human body is between 36° C
- 27 ° C and most of its radiant energy concentrated in the wavelength range of 8 um-12 um.

Passive infrared alarms classified into infrared detectors (infrared probes) and alarm control
sections. The most widely used infrared detector is a pyroelectric detector. It uses as a sensor
for converting human infrared radiation into electricity. If the human infrared radiation is
directly irradiated on the detector, it will, of course, cause a temperature change to output a
signal. But in doing all this, the detection distance will not be more. In order to lengthen the
detection distance of the detector, an optical system must be added to collect the infrared
radiation. Usually, plastic optical reflection system or plastic Fresnel lens used as a focusing
system for infrared radiation. In the detection area, the lens of the detector receives the infrared
radiation energy of the human body through the clothing and focused on the pyroelectric sensor.
When the human body moves in this surveillance mode, it enters a certain field of view in
sequence and then walks out of the field of view. The pyroelectric sensor sees the moving
human body for a while and then does not see it, so the infrared radiation of human body
constantly changes the temperature of the pyroelectric material. So that it outputs a
corresponding signal, which is the alarm signal.
31

Figure 4.3

4.4 RANGE OF PIR SENSOR

 Indoor passive infrared: Detection distances range from 25 cm to 20 m.


 Indoor curtain type: The detection distance ranges from 25 cm to 20 m.
 Outdoor passive infrared: The detection distance ranges from 10 meters to 150 meters.

Outdoor passive infrared curtain detector: distance from 10 meters to 150 meters.

4.5 SPECIFICATION OF PIR SENSOR

 Detection range: up to 7 meters


 Detection angle: 110 degrees
 Operating voltage: DC 4.5V - 12V DC
 Output signal: 3.3V digital output
 Delay time: adjustable from 0.3 seconds to 5 minutes
 Operating temperature: -15°C to +70°C
32

Figure 4.4

 PIR sensor: Never keep PIR Sensor close to the Wi-Fi antenna, ESP32, or NodeMCU.
 PIR (Passive Infrared) sensor close to a Wi-Fi antenna impacts the sensor's
performance.
 PIR sensors detect changes in infrared radiation for motion detection.
 Wi-Fi signals emit electromagnetic radiation that can interfere with the PIR sensor.
Which causes false detection.
 So always keep the PIR sensor and Wi-Fi antenna as far apart as possible.

Also, you can try to shield the PIR sensor from the Wi-Fi signal. This can be done by using
metal shields or Faraday cages around the PIR sensor.
33

CHAPTER 5: CONNECTION OF COMPONENTS

Figure 5.1

Relay Module Connection:

 VCC is connected with 5V pin of Arduino.


 GND is connected with GND of Arduino.
 Arduino is connected with Arduino digital pin 4.
 Similarly, second relay’s In pin is connected to digital pin 7.

PIR Module Connection


 Vcc of PIR is connected to the 5v pin of Arduino
 GND is connected to the GND of Arduino
 Digital pin of PIR is connected to digital pin 2 of Arduino.
34

CHAPTER 6: SIMULATION

Figure 6.1

Figure 6.2
35

Figure 6.3

Figure 6.4
36

CHAPTER 7: SOFTWARE CODE

const int SENSOR_PIN = 2; // the Arduino pin connected to output (middle) wire of sensor
const int RELAY_PIN = 4; // the Arduino pin which is connected to control relay
const int RELAY_PIN_SECOND = 7;

void setup() {
Serial.begin(9600); // setup Serial Monitor to display information

Serial.println("HC-SR501 sensor with relay");


pinMode(SENSOR_PIN, INPUT);// Define SENSOR_PIN as Input from sensor
pinMode(RELAY_PIN, OUTPUT);
pinMode(RELAY_PIN_SECOND, OUTPUT);// Define RELAY_PIN as OUTPUT for
relay
}

void loop() {

int motion =digitalRead(SENSOR_PIN);// read the sensor pin and stores it in "motion"
variable

// if motion is detected
if(motion){
Serial.println("Motion detected");
digitalWrite(RELAY_PIN, LOW);
digitalWrite(RELAY_PIN_SECOND, LOW);// Turn the relay ON
}else{
Serial.println("nothing moves");
digitalWrite(RELAY_PIN,HIGH);
digitalWrite(RELAY_PIN_SECOND,HIGH);// Turn the relay OFF
}
delay(500);
}
37

7.1 EXPLAINATION OF CODE

The given code is an Arduino sketch that uses a PIR sensor to detect motion and control a
relay to switch on/off connected lights. Let's take a closer look at the code and understand
how it works:

const int SENSOR_PIN = 2;


const int RELAY_PIN = 4;
const int RELAY_PIN_SECOND = 7;

These are constants used to define the sensor and relay pins connected to the Arduino board.
The SENSOR_PIN variable is set to 2, which represents the input pin connected to the output
wire of the PIR sensor. The RELAY_PIN variable is set to 4, which represents the output pin
connected to the relay. RELAY_PIN_SECOND is set to 7, which is another output pin
connected to a second relay.

void setup() {
Serial.begin(9600);
Serial.println("HC-SR501 sensor with relay");
pinMode(SENSOR_PIN, INPUT);
pinMode(RELAY_PIN, OUTPUT);
pinMode(RELAY_PIN_SECOND, OUTPUT);
}

The `setup()` function is called once when the Arduino board is powered on or reset. It
initializes the Serial Monitor and sets the pinMode of SENSOR_PIN, RELAY_PIN, and
RELAY_PIN_SECOND as INPUT and OUTPUT, respectively.

void loop() {
int motion = digitalRead(SENSOR_PIN);

if(motion){
Serial.println("Motion detected");
digitalWrite(RELAY_PIN, LOW);
digitalWrite(RELAY_PIN_SECOND, LOW);
}else{
Serial.println("nothing moves");
digitalWrite(RELAY_PIN,HIGH);
digitalWrite(RELAY_PIN_SECOND,HIGH);
}
delay(500);
}

The `loop()` function runs continuously once the `setup()` function has completed. It first
reads the state of SENSOR_PIN using `digitalRead()` and stores the result in the variable
motion.

If motion is detected by the PIR sensor, motion will be equal to HIGH, and the code will
execute the following statements: print "Motion detected" to the Serial Monitor using
38

`Serial.println()`, turn on the RELAY_PIN and RELAY_PIN_SECOND pins by setting them


to LOW using `digitalWrite()`.

On the other hand, if no motion is detected, motion will be equal to LOW, and the code will
execute the following statements: print "nothing moves" to the Serial Monitor using
`Serial.println()`, turn off the RELAY_PIN and RELAY_PIN_SECOND pins by setting them
to HIGH using `digitalWrite()`.

Finally, the code waits for 500 milliseconds using `delay()` before repeating the loop.

Overall, the code implements a simple motion-activated lighting control system using a PIR
sensor and relay module. It reads the output from the sensor and turns on/off the relay pins
connected to the lights based on whether motion is detected or not.
39

CHAPTER 8:
WORKING

The working principle of a PIR sensor and how it is used to control a relay to turn on lights
when motion is detected. The Arduino implements this functionality by reading the output pin
of the PIR sensor and using it to control the relay pins.

When a human or animal body comes in the range of the PIR sensor, it detects the movement
by sensing the infrared radiation emitted by the object. The PIR sensor converts this
movement into a digital HIGH signal and sends it to the Arduino board. The Arduino board
reads this signal and determines that motion has been detected.

If motion is detected, the code turns on the relay pins by setting them to LOW. This sends a
signal to the connected lights to turn on. On the other hand, if no motion is detected, the code
turns off the relay pins by setting them to HIGH. This sends a signal to the connected lights to
turn off.

Therefore, the code implemented in the Arduino sketches above controls the relay module
using the PIR sensor and turns on the lights when motion is detected, providing an automated
and energy-efficient way to control the lighting in a room or area.

Figure 8.1
40

CHAPTER 9:
CONCLUSION

This project aims to address the issue of electricity wastage in various settings, such as
homes, schools, colleges, and industries. Wastage of electricity not only causes unnecessary
financial burden but also has a negative impact on the environment. Thus, it is imperative to
promote energy efficiency and reduce electricity wastage in all possible ways.

The developed system utilizes Passive Infra-Red (PIR) sensors and an Arduino
microcontroller to detect motion in the PIR range. PIR sensors are a type of motion sensor
that detects infrared radiation emitted by living objects. When a human or animal body comes
into the sensor range, it emits heat energy in the form of infrared radiation. The PIR sensor
detects this radiation and triggers the connected Arduino board. The system then activates the
connected lights through the relay, providing a convenient way to control the lighting system.
When no motion is detected, the lights will turn off after a certain duration, thus reducing
unnecessary electricity consumption.

The Arduino microcontroller is a powerful tool that can be programmed to perform various
functions. In this project, it is programmed to receive the input from the PIR sensor and
activate the relay accordingly. The Arduino code is straightforward and can be easily
modified to adjust the timing and other parameters as needed.

This project has several potential benefits. Firstly, it promotes energy efficiency by reducing
unnecessary electricity wastage. Secondly, it provides a convenient way to control the
lighting system. Instead of manually turning the lights on and off, the system automatically
detects motion and turns the lights on or off accordingly. Finally, it has the potential to reduce
electricity bills, especially in large buildings such as schools, colleges, and industries, where
energy consumption can be significant.

In conclusion, the development of a smart sensor for laboratory applications is an essential


step towards achieving efficient, and cost-effective monitoring systems. By integrating
traditional sensing elements with advanced microcontroller technology, smart sensors offer
real-time data that can significantly enhance the overall quality and reliability of laboratory
measurements. The evolution of smart sensors is a continuously advancing field, offering
opportunities for innovation and improvement in the design and performance of these
devices. The development of this project demonstrates the potential of using PIR sensors and
an Arduino microcontroller to promote energy efficiency and reduce electricity wastage,
providing an effective and practical solution to an ongoing environmental challenge.
41

REFERENCE

[1] Cheng-Hung Tsai, Ying-Wen Bai, Chun-An Chu, Chih-Yu Chung and Ming-Bo Lin, "PIR-
sensor-based Lighting Device with Ultra-IowStandby Power Consumption", IEEE
Instrumentation and Measurement Technology Conference (I2MTC), 2011.

[2] R Harikrishnan, P Sivagami, “Intelligent Power Saving System using PIR Sensors”,
Institute of Electrical and Electronics Engineers, April 2017

[3] Prof. Vikram M. Kakade, “Home Automation using PIR Sensor”, International Journal for
Scientific Research & Development Vol. 5, Issue 1, 2017

[4] P. Rajakumar, Barath C. Kanna, R. Archana, A. Akshaya, K Abhinaya, M. Boobalan,


“Automation of Room Lighting System Using Arduino and PIR Sensor”, IEEE, December
2022
42

You might also like