0% found this document useful (0 votes)
58 views44 pages

Team-H III BSC Ecs Final Year Project Report Chapter

This document describes an IoT-based home automation system using Arduino. The system uses an RFID reader to identify users and control a servo motor to open doors. It also uses an ESP8266 WiFi module connected to an Arduino board to control home appliances like lights and fans through a smartphone app. The system aims to automate home devices for convenience and energy efficiency using Internet of Things technology.

Uploaded by

Ramesh Babu
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)
58 views44 pages

Team-H III BSC Ecs Final Year Project Report Chapter

This document describes an IoT-based home automation system using Arduino. The system uses an RFID reader to identify users and control a servo motor to open doors. It also uses an ESP8266 WiFi module connected to an Arduino board to control home appliances like lights and fans through a smartphone app. The system aims to automate home devices for convenience and energy efficiency using Internet of Things technology.

Uploaded by

Ramesh Babu
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/ 44

IOT BASED HOME AUTOMATION USING ARDUINO

CHAPTER 1

INTRODUCTION
Home automation is a concept that seeks to give you the fingertip control over your
everyday home electrical appliances, allowing you to save money on lights, improve energy
efficiency, and make the most of your energy. In addition to lighting controls, the concept
may be used to create a centralized entertainment system for the home as well as a
comprehensive home security system. Internet of Things-based home automation systems,
as the name suggests, aim to operate all of your smart home's devices using internet
protocols or cloud-based computations.
In comparison to a wired system, the IoT-based home automation system offers a great deal
of flexibility. It also has several advantages, such as ease of use, installation simplicity,
avoiding the complexity of running wires and loose electrical connections, fault detection
and triggering simplicity, and mobility simplicity. The ESP8266 is used to scan an id card
using RFID technology. Attendance is kept on this as well. before entering the gate, a person
will present their RFID card, which will be read by the RFID Reader EM-18 module, to the
IoT.

1.1 LITEREATURE REVIEW


A basic yet advanced existence is becoming more and more important as technology
continues to evolve at a rapid pace. Without the Internet, people's social and educational
lives would be pointless. Controlling and monitoring the electronic, electrical, and
mechanical systems that are used in a wide range of infrastructure is now possible thanks
to IoT devices connected to the Internet of Things (IoT). There is only one person in charge
of these devices connected to the cloud server, and any modifications made to them are
communicated or informed to all authorised users on the network. Various electronic and
electrical devices can be connected and operated from afar using various network
infrastructures. There is no longer any need to manually activate a switch when we have a
web browser on a laptop or smart phone, or any other smart technique that allows us to
operate switches. Smart switches are currently available, however they are pricey and
require other devices, such as a hub or a switch, to work correctly. There are a multitude of
connectivity devices on the market to address the demand for communication between the
device and the micro-controller, among other things, as wireless technology continues to
grow rapidly. Radio frequency (RF) and ZigBee technology are commonly used in wireless
networks. In this project, we used an ESP8266-01 Wi-Fi module programmed on the

DEPARTMENT OF ECS SKASC 1


IOT BASED HOME AUTOMATION USING ARDUINO

Arduino UNO platform to control several gadgets.


K. Venkatesan and Dr. U. Ramachandraiah (2020) demonstrate how they have built a
Zigbee module in an Arduino mega that they use to control various devices via a web page
and an Android app [2] by utilising this module. They've used a wide range of sensors for
a wide range of purposes. In addition, a web-based server provides clients with real-time
notice and input on what's happening in their home [1]. In addition, a web application is
used to control the gadgets, which includes logic gates, Raspberry Pi, 555 timers, and flip-
flop. A study by Shashank Shiva Kumar Jha, Vishwateja Mudiam Reddy demonstrates how
this is run and controlled.
Students' id cards can now be monitored using Radio Frequency Identification (RFID)
based on the Internet of Things (IoT) to open the door, according to Soumil Nitin Shah and
Abdelshakour Abuzneid (2019). Schools are worried about students who don't show up to
class on time. Truancy can have a negative impact on a student's academic progressThe use
of an RFID-based door-opening system with an IoT system is one solution to the issue.
RFID and the Internet of Things (IoT) are two of the most prominent technology research
trends at the moment.

1.2 PROJECT STATEMENT


Nowadays, people with a hectic daily life routine sometimes forget to switch off the devices
at home. As a human being, we can’t run from the clumsiness attitude, plus with our packed
daily routine life that sometimes makes us so in a hurry that sometimes makes us forget to
switch off the lamps. It will cause the electricity bill to rise sharply. Besides, it is one of the
electricity wastages that will lead the earth to become an unhealthy place. Besides, the
elderly and the handicapped users faced problems accessing manual control of lights and
fans instead of the automation process.

1.3 PROJECT OBJECTIVES


The main objective of this project is to control the devices such as lamp and door at home
using smartphone and RFID.
1. To design a system that performs home automation using a microcontroller
2. To add an RFID sensor to home automation so that users can control how their doors
work.
3. To develop an intelligent environment in which smart technology is used to control home
appliances.

DEPARTMENT OF ECS SKASC 2


IOT BASED HOME AUTOMATION USING ARDUINO

1.4 SCOPE OF PROJECT


1. This project is focusing on hardware and software that is being used.
2. The emphasis includes controlling and programming.
3. The main controller uses the Arduino UNO R3 and NODE MCU.

1.5 PROJECT SIGNIFICANCE


Blynk app has been used for most of the home automation projects, or "home appliances,"
that have been completed. Our project differs from others in that we employ two
microcontrollers (Arduino and NODEMCU) instead of only one, such as Wi-Fi modules,
Bluetooth, ZigBee, and GSM modules. Our equipment must be connected to the internet
before we can send commands via Telegram or Blynk applications, which is comparable to
how we use IOT as a platform to operate our home devices. In contrast to other projects,
ours makes use of a smartphone to issue commands, while others make use of a tablet
laptop, etc.

DEPARTMENT OF ECS SKASC 3


IOT BASED HOME AUTOMATION USING ARDUINO

CHAPTER 2
SYSTEM ARCHITECTURE
2.1 BLOCK DIAGRAM

Fig 2.1 Block diagram


The block diagram of IoT based home automation using Arduino system consist of:
 Power Supply: A power supply is an electrical device that supplies electric power to an
electrical load. The primary function of a power supply is to convert electric current from a
source to the correct voltage, current, and frequency to power the load. As a result, power
supplies are sometimes referred to as electric power converters. Some power supplies are
separate standalone pieces of equipment, while others are built into the load appliances that
they power.
 RFID Reader: A RFID system is made up of two parts: a tag or label and a reader. RFID
tags or labels are embedded with a transmitter and a receiver. The RFID component on the
tags has two parts: a microchip that stores and processes information, and an antenna to
receive and transmit a signal. The tag contains the specific serial number for one specific
object. To read the information encoded on a tag, a two-way radio transmitter-receiver

DEPARTMENT OF ECS SKASC 4


IOT BASED HOME AUTOMATION USING ARDUINO

called an interrogator or reader emits a signal to the tag using an antenna. The tag responds
with the information written in its memory bank. The interrogator will then transmit the
read results to an RFID computer program.

 LCD display: LCDs (Liquid Crystal Displays) are used in embedded system applications
for displaying various parameters and status of the system. LCD 16x2 is a 16-pin device
that has 2 rows that can accommodate 16-character search. LCD 16x2 can be used in 4-bit
mode or 8-bit mode. It is also possible to create custom characters. It has 8 data lines and 3
control lines that can be used for control purposes.
 Servo Motor: A servomotor is a rotary actuator or linear actuator that allows for precise
control of angular or linear position, velocity and acceleration. It consists of a suitable motor
coupled to a sensor for position feedback. It also requires a relatively sophisticated
controller, often a dedicated module designed specifically for use with servomotors.
 IOT: The ESP8266 Wi-Fi Module is a self-contained SOC with integrated TCP/IP
protocol stack that can give any microcontroller access to your Wi-Fi network. The
ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking
functions from another application processor. Each ESP8266 module comes pre-
programmed with an AT command set firmware, meaning, you can simply hook this up to
your Arduino device and get about as much Wi-Fi ability as a Wi-Fi Shield offers. The
ESP8266 module is an extremely cost effective board with a huge, and ever growing,
community.
In our present generation, we are upgrading to digitalized gadgets and other auxiliary
devices, such as smartphones and tablets. IoT-powered home automation is the subject of
this series, which we researched and completed a project on. One is that we utilized an
Arduino uno to read the RFID tag on the door, and the other is a Blynk IoT programme to
operate the NodeMCU-based home appliances. Arduino and LCD display and servo motor
are connected to the Arduino first, then the servo motor and LCD display are connected to
the Arduino. Once the card is scanned by RFID, commands are sent to the servo motor,
which opens the door, and the information about the people in the room is displayed.
The next diagram is based on the IoT Blynk programme for the Node MCU ESP8266. Wifi
is used to communicate with the module and deliver commands to it. The data must be
saved from a previous session by the key setting user, and then it is the player's turn.
Lighting and other home appliances can be turned on after the directions have been read.

DEPARTMENT OF ECS SKASC 5


IOT BASED HOME AUTOMATION USING ARDUINO

2.2 CIRCUIT DIAGRAM

Fig 2.2 Circuit diagram

2.3. CIRCUIT DIAGRAM DESCRIPTION


2.3.1 ARDUINO
 5v power supply is connected to the IOT module (ESP8266) and 1st pin of the Arduino
Uno.

 9th pin connected to RST pin of RFID.

 10th pin is connected to SDA pin of RFID.

 11th pin is connected to MOSI pin of RFID.

 12th pin is connected to MISOI pin of RFID.

 13th pin is connected to SCK pin RFID.

 3.3v and ground is connected to RFID module.

 3rd pin is connected to servo motor input pin, 5v to power supply and Gnd to servo motor
is connected.

 A0 is connected to SCL pin of i2c module.

 A1 is connected to SDA pin of i2c module.

 5v and ground is connected to the 12c module for 16*2 LCD Display.
2.3.2 NODEMCU
 Power supply of 5v is connected to the module and ground is also connected.
 D1, D2, D5, D6 are connected to R1, R2, R3, R4.
 SD3, D3, D7, RX are connected to push switch of S1, S2, S3, S4.
 And lights are connected towards relay and AC supply of 220v.

DEPARTMENT OF ECS SKASC 6


IOT BASED HOME AUTOMATION USING ARDUINO

2.4 WORKING PRINCIPLE

 This project uses Arduino Uno to control the motor. The Arduino Board is programmed
using the Arduino IDE software.

 Moisture sensor measures the level of moisture in the soil and calculates the average
moisture value and sends the signal to the Arduino if watering is required. The water pump
supplies water to the plants until the desired moisture level is reached.

 The rechargeable battery that supplies required power source via12v.

 A moisture sensor is used for sensing the soil condition –to know whether the soil is wet
ordry, and the input signals are then sent to the microcontroller, which controls the whole
circuit. Whenever the soil condition is dry, the microcontroller sends command to relay and
the motor gets switched on and supplies water to the field. And if the soil gets wet, motor
gets switched off.

2.5 PROPOSED ALGORITHM

 Step1: Start-up of the modules.

 Step2: RFID sensor read the input value gathering.

 Step3: Analyzing the RFID value

 Step4: Turn on the motor if the detected.

 Step5: Using mobile sever to control the home appliance.

2.6 CONSTRUCTION

 Collect all the materials required for the project.

 Connect the solar panel to the battery.

 Connect the sensor and relay in the Arduino.

 Connect the respective modules in their placed.

 Upload the code.

 Test run.

DEPARTMENT OF ECS SKASC 7


IOT BASED HOME AUTOMATION USING ARDUINO

CHAPTER 3

HARDWARE DESCRIPTION

3.1. ARDUINO UNO

Fig 3.1 Arduino UNO


The Arduino Uno is an open-source microcontroller board based on the Microchip
ATmega328P microcontroller and developed by Arduino.cc The board is equipped with
sets of digital and Analog input/output (I/O) pins that may be interfaced to various
expansion boards (shields) and other circuits. The board has 14 digital I/O pins (six capable
of PWM output), 6 Analog I/O pins, and is programmable with the Arduino IDE (Integrated
Development Environment), via a type B USB cable. It can be powered by the USB cable
or by an external 9-volt battery, though it accepts voltages between 7 and 20 volts. The Uno
boardis the first in a series of USB-based Arduino boards; it and version 1.0 of the Arduino
IDE werethe reference versions of Arduino, which have now evolved to newer releases.
The ATmega328 on the board comes pre-programmed with a bootloader that allows
uploading newcode to it without the use of an external hardware programmer. There
are many versionsof Arduino boards introduced in the market like Arduino Uno, Arduino
Due, Arduino Leonardo, Arduino Mega, however, most common versions are Arduino Uno
and Arduino Mega.

DEPARTMENT OF ECS SKASC 8


IOT BASED HOME AUTOMATION USING ARDUINO

Table 3.1: Arduino UNO pin description

Pin Category Pin Name Details

Power Vin, 3.3V, Vin: Input voltage to Arduino when using an external
5V, GND power source.
5V: Regulated power supply used to power
microcontroller and other 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.

Analog Pins A0 – A5 Used to provide analog input in the range of 0- 5V


Input / Output Digital Pins 0 Can be used as input or output pins.
Pins – 13
Serial 0(Rx), 1(Tx) Used to receive and transmit TTL serial data.
External 2, 3 To trigger an interrupt.
Interrupts
PWM 3, 5, 6, 9, 11 Provides 8-bit PWM output.

SPI 10 (SS), Used for SPI communication.


11
(MOSI),
1
2
(MISO) and
13 (SCK)
Inbuilt LED 13 To turn on the inbuilt LED.
TWI A4 (SDA), Used for TWI communication.
A5 (SCA)
AREF AREF To provide reference voltage for input voltage.
Analog Pins A0 – A5 Used to provide analog input in the range of 0- 5V

Input/Output Digital Pins 0 Can be used as input or output pins.


Pins – 13
Serial 0(Rx), 1(Tx) Used to receive and transmit TTL serial data.

External 2, 3 To trigger an interrupt.


Interrupts

DEPARTMENT OF ECS SKASC 9


IOT BASED HOME AUTOMATION USING ARDUINO

PWM 3, 5, 6, 9, 11 Provides 8-bit PWM output.

SPI 10 (SS), 11 Used for SPI communication.


(MOSI), 12
(MISO) and
13 (SCK)
Inbuilt LED 13 To turn on the inbuilt LED.

TWI A4 (SDA), Used for TWI communication.


A5 (SCA)
AREF AREF To provide reference voltage for input voltage.

Table 3.2: Arduino UNO Technical Specifications

Microcontroller ATmega328P – 8-bit AVR family


microcontroller
Operating 5V
Voltage
Recommended 7-12V
Input Voltage
Input Voltage 6-20V

Table 3.3: Arduino UNO technical Limitations

Analog Input 6 (A0 – A5)


Pins
Digital I/O 14 (Out of which 6 provide PWM output)
Pins
DC Current on I/O 40 mA
Pins

DC Current on 50 mA
3.3V Pin

Flash Memory 32 KB (0.5 KB is used for Bootloader)

EEPROM 1 KB

Frequency (Clock 16 MHz


Speed)

DEPARTMENT OF ECS SKASC 10


IOT BASED HOME AUTOMATION USING ARDUINO

Other Arduino Boards

Arduino Nano, Arduino Pro Mini, Arduino Mega, Arduino Due, Arduino Leonardo.

Overview

Arduino Uno is a microcontroller board based on 8-bit ATmega328P microcontroller.


Along with ATmega328P, it consists other components such as crystal oscillator, serial
communication, voltage regulator, etc. to support the microcontroller. Arduino Uno has 14
digital input/output pins (out of which 6 can be used as PWM outputs), 6 analog input pins,
a USB connection, A Power barrel jack, an ICSP header and a reset button.

How to use Arduino Board?

The 14 digital input/output pins can be used as input or output pins by using pin Mode (),
digital Read () and digital Write () functions in Arduino programming.

Each pin operates at 5V and can provide or receive a maximum of 40mA current, and has
an internal pull-up resistor of 20-50 KOhms which are disconnected by default. Out of these
14 pins, some pins have specific functions as listed below:

 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 analog
Write () 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 a 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.

DEPARTMENT OF ECS SKASC 11


IOT BASED HOME AUTOMATION USING ARDUINO

Arduino Uno has a couple of other pins as explained below

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

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

Communication

Arduino can be used to communicate with a computer, another Arduino board or other
microcontrollers. The ATmega328P microcontroller provides UART TTL (5V) serial
communication which 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. The ATmega16U firmware uses the standard
USB COM drivers, and no external driver is needed. However, on Windows, an .inf file is
required. The Arduino software includes a serial monitor which allows simple textual data
to be sent to and from the Arduino board. 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).

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. The Arduino software
includes a Wire library to simplify use of the I2C bus.

3.2 LCD
LCD (Liquid Crystal Display) is a type of flat panel display which uses liquid crystals in its
primary form of operation. LCD draws its definition from its name itself. It is combination
of two states of matter, the solid and the liquid. LCD uses a liquid crystal to produce a visible
image. LCD's technologies allow displays to be much thinner when compared to cathode ray
tube (CRT) technology.

Fig 3.2 Liquid Crystal Display (LCD)

DEPARTMENT OF ECS SKASC 12


IOT BASED HOME AUTOMATION USING ARDUINO

• In an LCD television, the pixels are switched on or off electronically using liquid crystals
to rotate polarized light.
• LCDs are used in a wide range of applications, including LCD televisions, computer
monitors, instrument panels, aircraft cockpit displays, and indoor and outdoor signage.
• LCDs (Liquid Crystal Displays) are used in embedded system applications for displaying
various parameters and status of the system.
• LCD 16x2 is a 16-pin device that has 2 rows that can accommodate 16 characters each.
• LCD 16x2 can be used in 4-bit mode or 8-bit mode.
• It is also possible to create custom characters.
• It has 8 data lines and 3 control lines that can be used for control purposes.
• For more information about LCD 16x2 and how to use it, refer the topic LCD 16x2
module in the sensors and modules section.
Functions Used:

1. LiquidCrystal object_name (rs,rw,en,d4,d5,d6,d7)


This function defines an object named object_name of the class LiquidCrystal.
rs, rw and en are the pin numbers of the Arduino board that are connected to rs, rw and en
of LCD. d0, d1, d2, d3, d4, d5, d6 and d7 are the pin numbers of the Arduino board that
are connected to data pins D1, D2, D3, D4, D5, D6 and D7 of LCD.
Example: LiquidCrystal lcd(13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3). This makes use of LCD in
8-bit mode.
2. lcd.begin(cols,rows)
This function is used to define the number of rows and columns the LCD has and to
initialize the LCD.Needs to be called before calling other functions, once the object is
defined using the function in point 1. Example, for 16x2 LCD we write lcd.begin(16,2).
lcd is the name of the object of the class LiquidCrystal. 16 is the number of columns and 2
is the number of rows.
3. lcd.setCursor(col,row)
This function positions the cursor of the LCD to a location specified by the row and column
parameters. col is the column number at which the cursor should be at (0 for column 1, 4
for column 5 and so on). Row is the row number at which the cursor should be at (0 for row
1, 1 for row 2). Example, for setting the cursor at the 5 th column in t h e 2 nd row,
lcd.setCursor(4,1). lcd is the name of the object of the class Liquid Crystal.

DEPARTMENT OF ECS SKASC 13


IOT BASED HOME AUTOMATION USING ARDUINO

4. lcd.createChar(num,data)
This function is used to create a new custom character for use on the LCD. num is the
CGRAM location (0 to 7) at which the custom character is to be stored. data is array of eight
bytes which represent the custom character. Custom character can be of 5x8 pixels only.
Arduino to 16×2 LCD Module:

Fig 4.2.2.3 Arduino to LCD

Fig 3.3 Circuit Diagram Arduino to 16*2 LCD

The RS pin of the LCD module is connected to digital pin 12 of the Arduino. The R/W pin
of the LCD is grounded. The enable pin of the LCD module is connected to digital pin 11
of the Arduino. In this project, the LCD module and Arduino are interfaced in the 4-bit
mode. This means only four of the digital input lines (DB4 to DB7) of the LCD are used.
This method is very simple, requires fewer connections, and you can almost utilise the full
potential of the LCD module. Digital lines DB4, DB5, DB6 and DB7 are interfaced to
digital pins 5, 4, 3 and 2 of the Arduino. The 10K potentiometer is used for adjusting the
contrast of the display. The 560 ohms resistor R1 limits the current through the back light
LED. The Arduino can be powered through the external power jack provided on the board.
The +5V required in some other parts of the circuit can be tapped from the 5V source on
the Arduino board. The Arduino can also be powered from the PC through the USB port.

3. 3 NODEMCU
Node MCU is an open source LUA based firmware developed for the ESP8266 Wi-Fi chip.
By exploring functionality with the ESP8266 chip, NodeMCU firmware comes with an
ESP8266 development board/kit, i.e., Node MCU Development board. Because NodeMCU
is an open source platform, their hardware design is editable, modifiable, and buildable.

The Node MCU Dev Kit/board consists of an ESP8266 Wi-Fi-enabled chip. The ESP8266

DEPARTMENT OF ECS SKASC 14


IOT BASED HOME AUTOMATION USING ARDUINO

is a low-cost Wi-Fi chip developed by Express if Systems with the TCP/IP protocol. For
more information about ESP8266, you can refer to the ESP8266 Wi-Fi Module. Version 2
(V2) of the NodeMCU Dev Kit is available, i.e., the NodeMCU Development Board v1.0
(Version2), which typically comes in a black PCB.

The Node MCU Dev Kit has Arduino like Analog (i.e., A0) and Digital (D0-D8) pins on its
board. It supports serial communication protocols, i.e., UART, SPI, I2C, etc. Using such
serial protocols, we can connect it with serial devices like I2C enabled LCD displays,
Magnetometer HMC5883, MPU-6050 Gyro metre + Accelerometer, RTC chips, GPS
modules, touch screen displays, SD cards etc.

Fig 3.4 NodeMCU


How to start with NodeMCU?

NodeMCU Development board is featured with Wi-Fi capability, analog pin, digital pins
and serial communication protocols. To get start with using NodeMCU for IoT applications
first we need to know about how to write/download NodeMCU firmware in NodeMCU
Development Boards. And before that where this NodeMCU firmware will get as per our
requirement. There is online NodeMCU custom builds available using which we can easily
get our custom NodeMCU firmware as per our requirement.

How to write codes for NodeMCU?

After setting up ESP8266 with NodeMCU firmware, let’s see the IDE (Integrated
Development Environment) required for development of Node MCU. NodeMCU with
ESPlorer IDE a scripts are generally used to code the Node MCU. Lua is an open source,
lightweight, embeddable scripting language built on top of C programming language.

NodeMCU with Arduino IDE

Here is another way of developing NodeMCU with a well-known IDE i.e. Arduino IDE.
We can also develop applications on NodeMCU using Arduino development environment.
This makes easy for Arduino developers than learning new language and IDE for
NodeMCU.

DEPARTMENT OF ECS SKASC 15


IOT BASED HOME AUTOMATION USING ARDUINO

GPIO (General Purpose Input Output) Pins:

NodeMCU has general purpose input output pins on its board as shown in above pinout
diagram. We can make it digital high/low and control things like LED or switch on it. Also,
we can generate PWM signal on these GPIO pins.

Fig 3.5 NodeMCU Pin configuration


ADC (Analog to Digital Converter) channel (A0):

NodeMCU has one ADC channel/pin on its board.

SPI (Serial Peripheral Interface) Pins:

NodeMCU based ESP8266 has Hardware SPI (HSPI) with four pins available for SPI
communication. It also has SPI pins for Quad-SPI communication. With this SPI interface,
we can connect any SPI enabled device with NodeMCU and make communication possible
with it.

I2C (Inter-Integrated Circuit) Pins:

NodeMCU has I2C functionality support on ESP8266 GPIO pins. Due to internal
functionality on ESP-12E we cannot use all its GPIOs for I2C functionality. So, do tests
before using any GPIO for I2C applications.

DEPARTMENT OF ECS SKASC 16


IOT BASED HOME AUTOMATION USING ARDUINO

UART (Universal Asynchronous Receiver Transmitter) Pins:

NodeMCU based ESP8266 has two UART interfaces, UART0 and UART1. Since UART0
(RXD0 & TXD0) is used to upload firmware/codes to board, we can’t use them in
applications while uploading firmware/codes.

3.4 READER AND CARD (RFID)

Radio-frequency identification (RFID) uses electromagnetic fields to automatically


identify and track tags attached to objects. An RFID tag consists of a tiny radio
transponder; a radio receiver and transmitter. When triggered by an electromagnetic
interrogation pulse from a nearby RFID reader device, the tag transmits digital data,
usually an identifying inventory number, back to the reader. This number can be used to
inventory goods. There are two types. Passive tags are powered by energy from the RFID
reader's interrogating radio waves. Active tags are powered by a battery and thus can be
read at a greater range from the RFID reader; up to hundreds of meters. Unlike a barcode,
the tag doesn't need to be within the line of sight of the reader, so it may be embedded in
the tracked object. RFID is one method of automatic identification and data capture
(AIDC).

Fig 3.6 RFID

RFID tags are used in many industries. For example, an RFID tag attached to an automobile
during production can be used to track its progress through the assembly line; RFID-tagged
pharmaceuticals can be tracked through warehouses; and implanting RFID microchips in
livestock and pets enables positive identification of animals. Since RFID tags can be

DEPARTMENT OF ECS SKASC 17


IOT BASED HOME AUTOMATION USING ARDUINO

attached to cash, clothing, and possessions, or implanted in animals and people, the
possibility of reading personally-linked information without consent has raised serious
privacy concerns.[2] These concerns resulted in standard specifications development
addressing privacy and security issues.

RFID WORKING:
RFID belongs to a group of technologies referred to as Automatic Identification and Data
Capture (AIDC). AIDC methods automatically identify objects, collect data about them,
and enter those data directly into computer systems with little or no human intervention.
RFID methods utilize radio waves to accomplish this. At a simple level, RFID systems
consist of three components: an RFID tag or smart label, an RFID reader, and an antenna.
RFID tags contain an integrated circuit and an antenna, which are used to transmit data to
the RFID reader (also called an interrogator). The reader then converts the radio waves to a
more usable form of data. Information collected from the tags is then transferred through a
communications interface to a host computer system, where the data can be stored in a
database and analysed at a later time.
RFID tag consists of an integrated circuit and an antenna. The tag is also composed of a
protective material that holds the pieces together and shields them from various
environmental conditions. The protective material depends on the application. For example,
employee ID badges containing RFID tags are typically made from durable plastic, and the
tag is embedded between the layers of plastic. RFID tags come in a variety of shapes and
sizes and are either passive or active. Passive tags are the most widely used, as they are
smaller and less expensive to implement. Passive tags must be “powered up” by the RFID
reader before they can transmit data. Unlike passive tags, active RFID tags have an on-
board power supply (e.g., a battery), thereby enabling them to transmit data at all times. For
a more detailed discussion, refer to this article: Passive RFID Tags vs. Active RFID Tags.
Smart labels differ from RFID tags in that they incorporate both RFID and barcode
technologies. They’re made of an adhesive label embedded with an RFID tag inlay, and
they may also feature a barcode and/or other printed information. Smart labels can be
encoded and printed on-demand using desktop label printers, whereas programming RFID
tags are more time consuming and requires more advanced equipment.

DEPARTMENT OF ECS SKASC 18


IOT BASED HOME AUTOMATION USING ARDUINO

Fig 3.7 RFID Module


ACTIVE RFID
 Primary Frequency Range: 433 MHz, (Can use 2.45 GHz - under the Extremely High
Frequency Range)
 Read Range: 30 - 100+ Meters
 Average Cost Per Tag: $25.00 - $50.00
 Applications: Vehicle Tracking, Auto Manufacturing, Mining, Construction, Asset
Tracking
 Pros: Very Long Read Range, Lower Infrastructure Cost (vs. Passive RFID), Large
Memory Capacity, High Data Transmission Rates
 Cons: High Per Tag Cost, Shipping Restrictions (due to batteries), Complex Software may
be Required, High Interference from Metal and Liquids; Few Global Standards
PASSIVE RFID
 Primary Frequency Ranges: 860 - 960 MHz
 Read Range: Near Contact - 25 Meters
 Average Cost Per Tag: $0.09 - $20.00
 Applications: Supply Chain Tracking, Manufacturing, Pharmaceuticals,
Electronic Tolling, Inventory Tracking, Race Timing, Asset Tracking
 Pros: Long Read Range, Low Cost Per Tag, Wide Variety of Tag Sizes and Shapes,
Global Standards, High Data Transmission Rates
 Cons: High Equipment Costs, Moderate Memory Capacity, High Interference from
Metal and Liquids
TYPES OF RFID READERS
 The most common way to categorize readers is to classify them as either fixed or mobile.
Other ways to differentiate between RFID readers include categories like connectivity,
available utilities, features, processing capabilities, power options, antenna ports, etc.
 Frequency Range- 902 – 928 MHz US, 865 – 868 MHz EU, Etc.*
 Mobility– Fixed Readers, Integrated Readers; Mobile Readers

DEPARTMENT OF ECS SKASC 19


IOT BASED HOME AUTOMATION USING ARDUINO

 Connectivity Options– Wi-Fi, Bluetooth, LAN, Serial, USB, Auxiliary Port


 Available Utilities– HDMI, GPS, USB, Camera, GPS, GPIO, 1D/2D Barcode, Cellular
Capabilities
 Processing Capabilities– On-board Processing, No On-board Processing
 Power Options– Power Adapter, PoE, Battery, In-Vehicle, USB
 Available Antenna Ports– No External Ports, 1-Port, 2-Port, 4-Port, 8-Port, 16-Port
3.5 SERVO MOTOR
A servo motor is an electrical device which can push or rotate an object with great precision.
If you want to rotate and object at some specific angles or distance, then you use servo
motor. It is just made up of simple motor which run through servo mechanism. If motor is
used is DC powered then it is called DC servo motor, and if it is AC powered motor then it
is called AC servo motor. We can get a very high torque servo motor in a small and light
weight packages. Doe to these features they are being used in many applications like toy
car, RC helicopters and planes, Robotics, Machine etc.
SERVO MECHANISM:
It consists of three parts:
 Controlled device
 Output sensor
 Feedback system
It is a closed loop system where it uses positive feedback system to control motion and final
position of the shaft. Here the device is controlled by a feedback signal generated by
comparing output signal and reference input signal. Here reference input signal is compared
to reference output signal and the third signal is produces by feedback system. And this
third signal acts as input signal to control device. This signal is present as long as feedback
signal is generated or there is difference between reference input signal and reference output
signal. So, the main task of servomechanism is to maintain output of a system at desired
value at presence of noises.
WORKING PRINCIPLE OF SERVO MOTORS:
A servo consists of a Motor (DC or AC), a potentiometer, gear assembly and a controlling
circuit. First of all, we use gear assembly to reduce RPM and to increase torque of motor.
Say at initial position of servo motor shaft, the position of the potentiometer knob is such
that there is no electrical signal generated at the output port of the potentiometer. Now an
electrical signal is given to another input terminal of the error detector amplifier. Now
difference between these two signals, one comes from potentiometer and another comes

DEPARTMENT OF ECS SKASC 20


IOT BASED HOME AUTOMATION USING ARDUINO

from other source, will be processed in feedback mechanism and output will be provided in
term of error signal. This error signal acts as the input for motor and motor starts rotating.
Now motor shaft is connected with potentiometer and as motor rotates so the potentiometer
and it will generate a signal. So as the potentiometer’s angular position changes, its output
feedback signal changes. After sometime the position of potentiometer reaches at a position
that the output of potentiometer is same as external signal provided. At this condition, there
will be no output signal from the amplifier to the motor input as there is no difference
between external applied signal and the signal generated at potentiometer, and in this
situation motor stops rotating.

Fig 3.8 Internal Structure of a Servo Motor

CONTROLLING SERVO MOTOR:


All motors have three wires coming out of them. Out of which two will be used for Supply
(positive and negative) and one will be used for the signal that is to be sent from the MCU.
Servo motor is controlled by PWM (Pulse with Modulation) which is provided by the
control wires. There is a minimum pulse, a maximum pulse and a repetition rate. Servo
motor can turn 90 degrees from either direction form its neutral position. The servo motor
expects to see a pulse every 20 milliseconds (ms) and the length of the pulse will determine
how far the motor turns. For example, a 1.5ms pulse will make the motor turn to the 90°
position, such as if pulse is shorter than 1.5ms shaft moves to 0° and if it is longer than
1.5ms than it will turn the servo to 180°. Servo motor works on PWM (Pulse width
modulation) principle, means its angle of rotation is controlled by the duration of applied
pulse to its Control PIN. Basically, servo motor is made up of DC motor which is controlled
by a variable resistor (potentiometer) and some gears. High speed force of DC motor is
converted into torque by Gears. We know that WORK= FORCE X DISTANCE, in DC
motor Force is less and distance (speed) is high and in Servo, force is High and distance is
less. Potentiometer is connected to the output shaft of the Servo, to calculate the angle and
stop the DC motor on required angle. Servo motor can be rotated from 0 to 180 degree, but
it can go up to 210 degrees, depending on the manufacturing. This degree of rotation can be

DEPARTMENT OF ECS SKASC 21


IOT BASED HOME AUTOMATION USING ARDUINO

controlled by applying the Electrical Pulse of proper width, to its Control pin.

Fig 3.9 Angular Rotation of the Servo Motor according to the Electrical Pulses

Servo motor can be rotated from 0 to 180 degree, but it can go up to 210 degrees, depending

on the manufacturing. This degree of rotation can be controlled by applying the Electrical
Pulse of proper width, to its Control pin. Servo checks the pulse in every 20 milliseconds.
Pulse of 1ms (1 millisecond) width can rotate servo to 0 degree, 1.5ms can rotate to 90
degrees (neutral position) and 2ms pulse can rotate it to 180 degrees. All servo motors work
directly with your +5V supply rails but we have to be careful on the amount of current the
motor would consume, if you are planning to use more than two servo motors a proper servo
shield should be designed.
INSIDE THE SERVO MOTOR:
Inside there is a pretty simple set-up: a small DC motor, potentiometer, and a control circuit.
The motor is attached by gears to the control wheel. As the motor rotates, the
potentiometer's resistance changes, so the control circuit can precisely regulate how much
movement there is and in which direction.

Fig 3.10 Components inside a Servo Motor


When the shaft of the motor is at the desired position, power supplied to the motor is
stopped. If not, the motor is turned in the appropriate direction. The desired position is sent
via electrical pulses through the signal wire. The motor's speed is proportional to the

DEPARTMENT OF ECS SKASC 22


IOT BASED HOME AUTOMATION USING ARDUINO

difference between its actual position and desired position. So, if the motor is near the
desired position, it will turn slowly, otherwise it will turn fast. This is called proportional
control.

Fig 3.11 Parts of a Servo motor

WIRE CONFIGURATION:
● Brown-Ground wire connected to the ground of system
● Red -Powers the motor typically +5V is used
● Orange -PWM signal is given in through this wire to drive the motor.

Fig 3.12 Wire Configuration


APPLICATIONS:
Servos are used in radio-controlled airplanes to position control surfaces like elevators,
rudders, walking a robot, or operating grippers. Servo motors are small, have built-in control
circuitry and have good power for their size.
 The servo motor is used in robotics to activate movements, giving the arm to its precise
angle.
 The Servo motor is used to start, move and stop conveyor belts carrying the product along
with many stages. For instance, product labeling, bottling and packaging
 The servo motor is built into the camera to correct a lens of the camera to improve out of
focus images.
 The servo motor is used in robotic vehicle to control the robot wheels, producing plenty
torque to move, start and stop the vehicle and control its speed.
 The servo motor is used in solar tracking system to correct the angle of the panel so that

DEPARTMENT OF ECS SKASC 23


IOT BASED HOME AUTOMATION USING ARDUINO

each solar panel stays to face the sun


 The Servo motor is used in metal forming and cutting machines to provide specific motion
control for milling machines
 The Servo motor is used in Textiles to control spinning and weaving machines, knitting
machines and looms

 The Servo motor is used in automatic door openers to control the door in public places
like supermarkets, hospitals and theatres.

3.6 RELAY MODULE

Relay is one kind of electro-mechanical component that functions as a switch. The relay
coil is energized by DC so that contact switches can be opened or closed. A single channel
5V relay module generally includes a coil, and two contacts like normally open (NO) and
normally closed (NC). This article discusses an overview of the 5V relay module & its
working but before going to discuss what is relay module is, first we have to know what is
relay and its pin configuration. The pin configuration of the 5V relay module is shown
below. This module includes 6-pins where each pin and its functionality are discussed
below.

Fig 3.13: Relay Module Pin Diagram

Normally Open (NO): This pin is normally open unless we provide a signal to the relay
modules signal pin. So, the common contact pin smashes its link through the NC pin to
make a connection through the NO pin.
Common Contact: This pin is used to connect through the load that we desire to switch by
using the module.
Normally Closed (NC): This NC pin is connected through the COM pin to form a closed
circuit. However, this NC connection will break once the relay is switched through

DEPARTMENT OF ECS SKASC 24


IOT BASED HOME AUTOMATION USING ARDUINO

providing an active high/low signal toward the signal pin from a microcontroller.
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.
The components in a 5v relay module with a single channel include a relay, output terminal,
status LED, power LED, freewheeling diode, input connector & switching transistor.
SPECIFICATIONS
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
Working
The relay uses the current supply for opening or closing switch contacts. Usually, this can
be done through a coil to magnetize the switch contacts & drags them jointly once activated.
A spring drives them separately once the coil is not strengthened. By using this system,
there are mainly two benefits, the first one is, the required current for activating the relay is
less as compared to the current used by relay contacts for switching. The other benefit is,
both the contacts & the coil is isolated galvanically, which means there is no electrical
connection among them.
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.

DEPARTMENT OF ECS SKASC 25


IOT BASED HOME AUTOMATION USING ARDUINO

Fig 3.14: Single Channel Relay Module Circuit


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

DEPARTMENT OF ECS SKASC 26


IOT BASED HOME AUTOMATION USING ARDUINO

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

3.7 IoT (Internet of Things)


The Internet of Things (IoT) is the interconnection of uniquely identifiable embedded
computing devices within the existing Internet infrastructure. The "Internet of Things"
connects devices and vehicles using electronic sensors and the Internet.
3.7.1 MOBILE PHONES ARE IOT DEVICES
One of the most common in day to day life is mobile phones. Mobile phone is essentially
an embedded system with a processor at the core having display and keypad. They support
wide variety of sensors like ambient light Sensors, Accelerometer, Gyroscope and so on.
Mobile phones Gets IP addresses, when connected to internet. In other words it virtually
fits every description of IoT. In this future where everything is Web connected, mobile
phones will serve as the hub, or the remote control, for Internet of Things. So IoT is internet
connectivity of smart objects and embedded system other than mobile phones which can be
connected with external hardware and Mobiles Tablets, Laptops and PCs are remote control
access centre of IoT.

3.8 BLYNK APPLICATIONS


As a part of home automation, the Blynk application is used to operate the Arduino board.
From anywhere in the world (for example, operate LEDs, servos, receive data, etc.), we
may use a smartphone and the Blynk software to control an Arduino board linked to an
internet-connected PC (for example). To get Blynk, you'll need to go to Google Play (for

DEPARTMENT OF ECS SKASC 27


IOT BASED HOME AUTOMATION USING ARDUINO

Android). The dashboard and Arduino connectivity are provided by & app store (for Apple)
(it is a virtual connectivity). Pushing and dragging widgets from the tools bar and assigning
them pins on the Arduino board are the simplest ways to programme Blynk. A conventional
Arduino board, without an internet shield, can be used for such a project if it is connected
to a computer with internet access and a mobile phone. The PC is responsible for ensuring
that the Arduino board is connected to the Internet and for uploading the Arduino code.
Installing the Blynk library and configuring it are both required steps in this process. Blynk's
Arduino code is structured in the same way as normal Arduino code, but it contains unique
portions for Android devices.
The following steps are necessary for the project to be created.
1. The first step is to download the Blynk app on your smartphone and create a simple
application, such as controlling a single LED.
2. Download and install the blynk v0.3.1 library on your computer. Blynk's Blynk library
has a script that allows you to set the correct port on your PC to connect with your Arduino
board.
3. It's now time to download and run the Arduino code (from the examples presented in
this work, or other).
4. Use your smartphone to run Blynk.

Fig 3.15: BLYNK app project creation steps

DEPARTMENT OF ECS SKASC 28


IOT BASED HOME AUTOMATION USING ARDUINO

CHAPTER 4
SOFTWARE REQUIREMENTS

Software is a collection of instructions that enable the user to interact with a computer, its
hardware, or perform tasks. Without software, most computers would be useless. For
example, without your Internet browser software, you could not surf the Internet or read
this page and without an operating system, the browser could not run on your computer.
Software’s used are:
1. Arduino IDE
2. XAMPP
3. phpMyAdmin
4.1 ARDUINO IDE
The Arduino Integrated Development Environment - or Arduino Software (IDE) - contains
a text editor for writing code, a message area, a text console, a toolbar with buttons for
common functions and a series of menus. It connects to the Arduino and Genuino hardware
to upload programs and communicate with them.
Programs written using Arduino Software (IDE) are called sketches. These sketches are
written in the text editor and are saved with the file extension .ino. The editor has features
for cutting/pasting and for searching/replacing text. The message area gives feedback
while saving and exporting and also displays errors. The console displays text output by
the Arduino Software (IDE), including complete error messages and other information.
The bottom right hand corner of the window displays the configured board and serial port.
The toolbar buttons allow you to verify and upload programs, create, open, and save
sketches, and open the serial monitor

Fig.4.1. Arduino IDE

DEPARTMENT OF ECS SKASC 29


IOT BASED HOME AUTOMATION USING ARDUINO

Upload - Compiles your code and uploads it to the confiigured board. See uploading
below for details.
Note: If you are using an external programmer with your board, you can hold down the
"shift" key on your computer when using this icon. The text will change to "Upload using
Programmer"

New - Creates a new sketch.

Open - Presents a menu of all the sketches in your sketchbook. Clicking one will
open it within the current window overwriting its content. Note: Due to a bug in Java, this
menu doesn't scroll; if you need to open a sketch late in the list, use the File
| Sketchbook menu instead.

Save - Saves your sketch.

Serial Monitor - Opens the serial monitor.

4.2 FLOW CHART


A flowchart is a graphical representation of steps. It was originated from computer science
as a tool for representing algorithms and programming logic but had extended to use in all
other kinds of processes. Nowadays, flowcharts play an extremely important role in
displaying information and assisting reasoning. They help us visualize complex processes,
or make explicit the structure of problems and tasks. A flowchart can also be used to define
a process or project to be implemented.

DEPARTMENT OF ECS SKASC 30


IOT BASED HOME AUTOMATION USING ARDUINO

Fig.4.2 Flowchart – Arduino

DEPARTMENT OF ECS SKASC 31


IOT BASED HOME AUTOMATION USING ARDUINO

Fig.4.3 Flowchart – Node MCU

DEPARTMENT OF ECS SKASC 32


IOT BASED HOME AUTOMATION USING ARDUINO

4.3 SOURCE CODE


4.3.1 ARDUINO PROGRAM CARD READER

#include<LiquidCrystal_I2C.>
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9
#define SS_PIN 10 bytereadCard[4];
byte a = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2);
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup()
{
Serial.begin(9600);
lcd.init();
lcd.backlight();
while (!Serial);
SPI.begin();
mfrc522.PCD_Init();
delay(4);
mfrc522.PCD_DumpVersionToSerial();
lcd.setCursor(2, 0);
lcd.print("Put your card");
}
void loop()
{
if ( mfrc522.PICC_IsNewCardPresent())
{
return 0;
} if ( !mfrc522.PICC_ReadCardSerial())
{
return 0;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Scanned UID");
a = 0;
Serial.println(F("Scanned PICC's UID:"));
for ( uint8_t i = 0; i < 4; i++) // readCard[i] = mfrc522.uid.uidByte[i];
Serial.print(readCard[i], HEX); Serial.print(" "); lcd.setCursor(a, 1);
lcd.print(readCard[i], HEX); lcd.print(" ");
delay(500);
a += 3;
}
Serial.println("");
mfrc522.PICC_HaltA();
return 1;
}

DEPARTMENT OF ECS SKASC 33


IOT BASED HOME AUTOMATION USING ARDUINO

4.3.2 MAIN WORKING SOURCE CODE:-


#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
String UID = "BBAC2A13";
byte lock = 0;
Servo servo;
LiquidCrystal_I2C lcd(0x27,16,2);
MFRC522 rfid(SS_PIN, RST_PIN);
void setup() {
Serial.begin(9600);
servo.write(70);
lcd.init();
lcd.backlight();
servo.attach(3);
SPI.begin();
rfid.PCD_Init();
}
void loop(){
lcd.setCursor(0,0);
lcd.print("Welcome!");
lcd.setCursor(1,1);
lcd.print("Put your card");

4.3.3 NODEMCU ESP8266 WORKING CODE:-


#include "arduino_secrets.h"
#include "thingProperties.h"
// define the GPIO connected with Relays and switches
#define RelayPin1 5 //D1
#define RelayPin2 4 //D2
#define RelayPin3 14 //D5
#define RelayPin4 12 //D6
#define SwitchPin1 10 //SD3
#define SwitchPin2 0 //D3
#define SwitchPin3 13 //D7
#define SwitchPin4 3 //RX
#define wifiLed 16 //D0
int toggleState_1 = 0; //Define integer to remember the toggle state for relay 1
int toggleState_2 = 0; //Define integer to remember the toggle state for relay 2
int toggleState_3 = 0; //Define integer to remember the toggle state for relay 3
int toggleState_4 = 0; //Define integer to remember the toggle state for relay 4
void relayOnOff(int relay) {
switch (relay) {
case 1:
if (toggleState_1 == 0) {
digitalWrite(RelayPin1, LOW); // turn on relay 1
toggleState_1 = 1;
Serial.println("Device1 ON");

DEPARTMENT OF ECS SKASC 34


IOT BASED HOME AUTOMATION USING ARDUINO

}
else {
digitalWrite(RelayPin1, HIGH); // turn off relay 1
toggleState_1 = 0;
Serial.println("Device1 OFF");
}
delay(100);
break;
case 2:
if (toggleState_2 == 0) {
digitalWrite(RelayPin2, LOW); // turn on relay 2
toggleState_2 = 1;
Serial.println("Device2 ON");
}
else {
digitalWrite(RelayPin2, HIGH); // turn off relay 2
toggleState_2 = 0;
Serial.println("Device2 OFF");
}
delay(100);
break;
case 3:
if (toggleState_3 == 0) {
digitalWrite(RelayPin3, LOW); // turn on relay 3
toggleState_3 = 1;
Serial.println("Device3 ON");
} else {
digitalWrite(RelayPin3, HIGH); // turn off relay 3
toggleState_3 = 0;
Serial.println("Device3 OFF");
}
delay(100);
break;
case 4:
if (toggleState_4 == 0) {
digitalWrite(RelayPin4, LOW); // turn on relay 4
toggleState_4 = 1;
Serial.println("Device4 ON");
}
else {
digitalWrite(RelayPin4, HIGH); // turn off relay 4
toggleState_4 = 0;
Serial.println("Device4 OFF");
}
delay(100);
break;
default : break;
}
}

void manual_control() {

DEPARTMENT OF ECS SKASC 35


IOT BASED HOME AUTOMATION USING ARDUINO

//Manual Switch Control


if (digitalRead(SwitchPin1) == LOW) {
delay(200);
relayOnOff(1);
}
else if (digitalRead(SwitchPin2) == LOW) {
delay(200);
relayOnOff(2);
}
else if (digitalRead(SwitchPin3) == LOW) {
delay(200);
relayOnOff(3);
}
else if (digitalRead(SwitchPin4) == LOW) {
delay(200);
relayOnOff(4);
}
}
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is
found
delay(1500); // Defined in thingProperties.h
initProperties(); // Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
pinMode(RelayPin1, OUTPUT);
pinMode(RelayPin2, OUTPUT);
pinMode(RelayPin3, OUTPUT);
pinMode(RelayPin4, OUTPUT);
pinMode(wifiLed, OUTPUT);
pinMode(SwitchPin1, INPUT_PULLUP);
pinMode(SwitchPin2, INPUT_PULLUP);
pinMode(SwitchPin3, INPUT_PULLUP);
pinMode(SwitchPin4, INPUT_PULLUP);
//During Starting all Relays should TURN OFF
digitalWrite(RelayPin1, HIGH);
digitalWrite(RelayPin2, HIGH);
digitalWrite(RelayPin3, HIGH);
digitalWrite(RelayPin4, HIGH);
digitalWrite(wifiLed, HIGH); //Turn OFF WiFi LED
}
void loop() {
ArduinoCloud.update();
manual_control(); //Control relays manually
if (WiFi.status() != WL_CONNECTED)
{
digitalWrite(wifiLed, HIGH); //Turn OFF WiFi LED
}

DEPARTMENT OF ECS SKASC 36


IOT BASED HOME AUTOMATION USING ARDUINO

else{
digitalWrite(wifiLed, LOW); //Turn ON WiFi LED
}}
void onSwitch1Change() {
if (switch1 == 1)
{
digitalWrite(RelayPin1, LOW);
Serial.println("Device1 ON");
toggleState_1 = 1;
}
else
{
digitalWrite(RelayPin1, HIGH);
Serial.println("Device1 OFF");
toggleState_1 = 0;
}}
void onSwitch2Change() {
if (switch2 == 1)
{
digitalWrite(RelayPin2, LOW);
Serial.println("Device2 ON");
toggleState_2 = 1;
} else {
digitalWrite(RelayPin2, HIGH);
Serial.println("Device2 OFF");
toggleState_2 = 0;
}}
void onSwitch3Change() {
if (switch3 == 1)
{
digitalWrite(RelayPin3, LOW);
Serial.println("Device2 ON");
toggleState_3 = 1;}
else{
digitalWrite(RelayPin3, HIGH);
Serial.println("Device3 OFF");
toggleState_3 = 0;
}}
void onSwitch4Change() {
if (switch4 == 1)
{
digitalWrite(RelayPin4, LOW);
Serial.println("Device4 ON");
toggleState_4 = 1;
}
else{
digitalWrite(RelayPin4, HIGH);
Serial.println("Device4 OFF");
toggleState_4 = 0;
}}

DEPARTMENT OF ECS SKASC 37


IOT BASED HOME AUTOMATION USING ARDUINO

CHAPTER 5
RESULTS AND DISCUSSION
Home Automation devices based on the Internet of Things (IoT) are much more adaptable
than traditional wired systems. They have a number of advantages, such as being simple to
use and install, not requiring complicated wiring or loose electrical connections, being easy
to detect and trigger faults, and, perhaps most importantly, being mobile. The entire project
has been tested and ran in order to learn more about the findings. Other than that, it's an
evaluation of how well the project goes.
5.1 RFID BASED DOOR OPERATIONS:

Fig. 5.1: RFID-based Arduino access control system


The following is a step-by-step description of the RFID-based Arduino access control
system:
Step1: Once we have a master tag (college ID card) in place, the system goes into normal
mode and we can begin using it. Afterwards, restarting the system brings up a welcome
screen and allows you to insert a card message into the LCD display for display on the
screen.
Step 2: If the sensor detects a college ID card and displays a scanning message in the LDC
display after the card is presented for analysis.
Step3: In this step, if the card is accepted, a door will be unlocked and the object or person
will be allowed to pass through.
Step 4: The door will automatically close after a period of time.

DEPARTMENT OF ECS SKASC 38


IOT BASED HOME AUTOMATION USING ARDUINO

DEPARTMENT OF ECS SKASC 39


IOT BASED HOME AUTOMATION USING ARDUINO

Fig. 5.2: RFID-based Arduino access control system-denied


The door remains locked and the LCD display shows the message "Door Locked" if an
unknown tag is scanned.
5.2 IoT BASED HOME APPLIANCE OPERATIONS:
A Home automation is an integration of hardware, communication module and electronic
interfaces that work in our everyday life. IoT-based smart home automation systems are
designed to control the power of the interior and exterior of the home without our presence.
This IoT based system works with the help of Blynk app which can be installed in mobile
phone and access from anywhere around the world. The IOT based home automation system
communicates through the WiFi and controlled by the android apps from any smartphones.
In this proposed work we can able to control the lights of the outside and inside of the home
by having a low speed internet connectivity, Blynk mobile app and electronic interfacing
circuits. Fig 5.3 shows that the output from the system may control the lights either ON or
OFF through the blynk App. From the image there are three combination of controls are
obtained.
Case 1: Light ON inside the house
Case II: Light ON outside the house
Case III: Lights ON Inside and Outside the house
From this project the power of the lights can be controlled through the IoT based smart
automation system.

DEPARTMENT OF ECS SKASC 40


IOT BASED HOME AUTOMATION USING ARDUINO

Fig. 5.3: IoT-based Home appliances control system.

DEPARTMENT OF ECS SKASC 41


IOT BASED HOME AUTOMATION USING ARDUINO

CHAPTER 6
CONCLUSION

6.1 SUMMARY
Using RFID to close and open the door, the user can easily control their electrical home
appliances and home security as part of an IoT-based home automation system. The goal
of home automation is to use internet protocols to control all of the devices in the house.
We created this technology to be tested in a wide range of real-world situations. The data
is displayed on a liquid crystal display (LCD) to show whether or not it is correct. This
project uses an RFID sensor to open the door by scanning the student ID. When a person
correctly enters their id number, the LCD displays "door is open" and "door is closed" on
the screen, and the door opens. The LCD will display "wrong card" and the door will not
open if the id card is incorrect. To open and close the door, a servo motor is used. All of
these components are linked to an Arduino. NodeMCU was used to control the home
appliances via the blynk app, as well. The hotspot on your Android phone is what's keeping
it all together. The right people can be verified more quickly thanks to RFID. It reduces
the amount of time and money spent on manual labour. This project will be useful in the
future by modifying some of the devices that have already been developed.

6.2 FUTURE ENHANCEMENT

In the future, the RFID module may be replaced with an AI system that recognizes and
responds to human requirements. LCD panels have been phased out in favor of OLED
displays. Entering an incorrect user name or password will trigger a security alert. Sending
alert messages by email or phone call is done using the GSM module. Home security is
enhanced by the addition of additional sensors such as thermostats and humidity sensors
as well as smoke detectors, temperature and CO2 sensors. Google Cloud IoT Core can be
used instead of the Blynk IoT app. Valves and chemise will be controlled by the Google
cloud IoT.

DEPARTMENT OF ECS SKASC 42


IOT BASED HOME AUTOMATION USING ARDUINO

CHAPTER 7

BIBLIOGRAPHY

[1] K. Venkatesan and Dr. U. Ramachandraiah, Networked Switching and


PolymorphingControl of Electrical Loads with Web and Wireless Sensor Network, 2015
International Conference on Robotics, Automation, Control and Embedded Systems
(RACE), Chennai, (2015), 1-9.

[2] ShopanDey,Ayon Roy and SandipDas, Home Automation Using Internet of Thing ,
IRJET, 2(3) (2016),1965-1970.
[3] VishwatejaMudiam Reddy, NareshVinay, TapanPokharna and Shashank Shiva
Kumar Jha, Internet of Things Enabled Smart Switch, Thirteenth International
Conference on Wireless and Optical Communications Networks (WOCN), Hyderabad,
(2016),1-4

[4] Warsuzarina Mat Jubadi and NormaziahZulkifli, Programmable Infrared Accessory


Light Switch, International Conference on Intelligent and Advanced Systems, Kuala
Lumpur,(2007), 1130-1134.

[5] Shih-Pang Tseng, Bo-Rong Li, Jun-Long Pan, and Chia-Ju Lin, An Application of
Internet of Things with Motion Sensing on Smart House, International Conference on
Orange Technologies, Xian, (2014), 65-68.

[6] Mandurano, Justin, and Nicholas Haber. House Away: A home management system,
IEEE Long Island Systems, Applications and Technology Conference (LISAT),
Farmingdale, NY, (2012), 1-4.

[7] Zhen Bi, Smart home with ZigBee hardware simulation and performance evaluation,
International Conference on Mechatronic Sciences, Electric Engineering and Computer
(MEC), Shengyang, (2013), 2139-2142.

[8] S. Karaca, A. Şişman and İ. Savruk, A low cost smart security and home automation
system employing an embedded server and a wireless sensor network, International
Conference on Consumer Electronics - Berlin (ICCE-Berlin), Berlin,(2016), 73-77.

DEPARTMENT OF ECS SKASC 43


IOT BASED HOME AUTOMATION USING ARDUINO

[9] T. Thaker, ESP8266 based implementation of wireless sensor network with Linux
based web-server, Symposium on Colossal Data Analysis and Networking (CDAN),
Indore, (2016), 1-5

[10] Y. P. Zhang, T. Liu, Z. X. Yang, Y. Mou, Y. H. Wei and D. Chen, Design of remote
control plug, 2015 IEEE International Conference on Applied Superconductivity and
Electromagnetic Devices (ASEMD), Shanghai, (2015), 29-30.

[11] A. M. D. Celebre, A. Z. D. Dubouzet, I. B. A. Medina, A. N. M. Surposa and R. C.


Gustilo, Home automation using raspberry Pi through Siri enabled mobile devices,
International Conference on Humanoid, Nanotechnology, Information
Technology,Communication and Control, Environment and Management (HNICEM),

DEPARTMENT OF ECS SKASC 44

You might also like