Home Automation
Home Automation
On
Bachelor of Technology
In
Electrical Engineering
Submitted By
GURUMEHAR PRINCE
(Roll No-1217778) (Roll No-1217786)
FIROJ JAKHAL SAGAR
(Roll No-1217774) (Roll No-1216718)
Month, Yea
CANDIDATE’S DECLARATION
I hereby declare that the work presented in this report entitled “Iot Based Home Automation”,
in fulfilment of the requirement for the award of the degree Bachelor of Technology in Electrical
Engineering, submitted in Electrical Department, JMIT affiliated to Kurukshetra University, is
an authentic record of my own work carried out during my degree under the guidance of
Mr.Rishi Swaroop Sharma
The work reported in this has not been submitted by me for award of another degree or diploma.
Sagar (1216718)
CERTIFICATE
This is to certify that the Project work entitled “Iot Based Home Automation” submitted by
Gurumehar (1217778),Prince (1217786),Firoj Jakhal (1217774),Sagar (1216718) in fulfilment
for the requirements of the award of Bachelor of Technology Degree in Electrical Engineering at
JMIT, Radaur is an authentic work carried out by his/her under my supervision and guidance. To
the best of my knowledge, the matter embodied in the project has not been submitted to any
other University / Institute for the award of any Degree.
I express my sincere gratitude to Dr. Nidhika Birla (HOD, EE) and Mr. Rishi Swaroop Sharma
(A.P, EE) for his valuable guidance and timely suggestions during the entire duration of my
dissertation work, without which this work would not have been possible. I would also like to
convey my deep regards to all other faculty members of department of EE, who have bestowed
their great effort and guidance at appropriate times without which it would have been very
difficult on my part to finish this work. Finally I would also like to thank my friends for their
advice and pointing out my mistakes.
CONTENTS
Candidate’s declaration.......................................................................................................i
Certificate..............................................................................................................................ii
Acknowledgement................................................................................................................iii
List of figures........................................................................................................................iv
List of tables..........................................................................................................................v
Chapter 01 Introduction......................................................................................................1
1.1 Home Automation 1
1.2 Role of IOT in Home Automation 2
Chapter 02 Hardware and Circuit Description.................................................................5
2.1 Hardware Required
2.1.1 NodeMCU(ESP8266)
2.1.2 2 Channels Relay Module
2.1.3 Two Bulb Holders
2.1.4 Light Bulbs
2.1.5 Jumper Wires
2.2 Software
2.2.1 Adafruit
2.2.2 IFTTT
2.2.3 Google Assistant
Moreover, it would be better if everything such as warming bath water and adjusting the
room temperature were already done before they reach their home just by giving a voice
command. So, when people would arrive home, they would find the room temperature, the
bath water adjusted to their suitable preferences, and they could relax right away and feel
cozier and rather, feel morehomely.
Human assistants like housekeepers were a way for millionaires to keep up their homes in
the past. Even now when technology is handy enough only the well to do people of the
society are blessed with these new smart home devices, as these devices costs are a bit high.
However, not everyone is wealthy enough to be able to afford a human assistant, or some
smart home kit. Hence, the need for finding an inexpensive and smart assistant for normal
families keeps growing.
This paper proposes such inexpensive system. It uses the Google Assistant, the IFTTT
application, the Adafruit application and the Node-MCU microcontroller as the major
components along with a relay board comprising of 2 channels relays . Natural language
voice is used to give commands to the Google Assistant. All of the components are
connected over the internet using Wi-Fi which puts this system under the Internet of things
(IOT).
1.2 ROLE OF IOT IN HOME AUTOMATION
Today in the headway of Automation innovation, life is getting simpler and less demanding in all
spheres. Home automation is a modern technology that modifies your home to perform different
sets of task automatically. Today Automatic frameworks are being favored over manual
frameworks. No wonders, home automation in India is already the buzz word, especially as the
wave of second generation home owners grows, they want more than shelter, water, and
electricity. The first and most obvious advantage of Smart Homes is comfort and convenience, as
more gadgets can deal with more operations (lighting, temperature, and so on) which in turn
frees up the resident to perform other tasks. Smart homes filled with connected products are
loaded with possibilities to make our lives easier, more convenient, and more comfortable. There
is no shortage of possibilities for smart home IoT devices as home automation seems to be the
wave of the future. The requirement for Office and Home automation arises due to the advent of
IoT, in a big way in homes and office space. The smart home/office gadgets interact, seamlessly
and securely; control, monitor and improve accessibility, from anywhere across the globe. These
smart automation devices happen to have an interface with IoT. IT automation will be the key to
bridging the gap between human limitations and technology’s capabilities. With automation, data
can be instantly collected and seamlessly passed between devices as it’s simultaneously
analyzed. Home automation is an appealing context for the Internet of Things (IoT), by
connecting the IP gateway directly to the Internet or through a home/residential gateway; this
system can be managed remotely using a PC, Smart phone, Tablet or other devices
The IoT based Home Automation will enable the user to use a Home Automation System based
on Internet of Things (IoT). The modern homes are automated through the internet and the home
appliances are controlled. The user commands over the internet will be obtained by the Wi-Fi
modems. The Microcontroller has an interface with this modem. The system status is displayed
through the LCD display, along with the system data. This is a typical IoT based Home
Automation system, for controlling all your home appliances. The smart home market is taking
off as IoT device prices come down and the general public comes to understand the benefits of
these products. And from smart homes, the next logical step is smart cities, which would take the
IoT to the next level. And yet, smart homes are just one small part of our daily lives that the
Internet of Things will transform in the coming years.
We have already witnessed some early commercial success in the IoT industry where today,
everyone is talking about Internet of Things which is the “next big” thing in the world of
technology. The prospect of 30 billion objects connected to the Internet by the year 2020 is
staggering, as the opportunities for new lines of service and new business models grow out of
this realm. IoT is based on the inclusion of devices in the world of connected environments. The
devices are embedded and connected, based on a unique identity. The IoT devices in Home
Automation have the maximum applications in energy. The home heating devices are able to
control the temperature with the devices like laptops, tablets or smart phones and all of these
appliances, systems, and devices contain sensors that connect them to a network. This is where
IoT comes into place, and makes it such an integral part of the home automation. With the help
of IoT technology, you can control devices as and when you want.
The beauty of the Home Automation system lies in the fact that the settings are manageable from
your smart phones and other remote-control devices. Smart home IoT devices can help reduce
costs and conserve energy. The Home Automation segment includes smart lighting, smart TVs
and other appliances. Wearable’s (Smart Watch, fitness brands, smart headphones, smart
clothing) are also expected to witness the growth in the future. IoT is really the secret that makes
this whole system work. Today in India, nearly 22.5 per cent of the consumers surveyed were
familiar with the concept of IoT, with maximum awareness seen in the 36-55 age group which
clearly indicates that there is immense opportunity for increased adoption of such technologies.
The future of the Home automation market will happen with few key upgradations in the
Automation technology. For example, Wireless Automation solutions as well as lowering of
price points as the market begins to accept Home automation usage in larger volumes. With an
increased internet penetration and data usage, the connected devices segment is expected to
witness a huge growth by 2020. Home Automation in India is creating big opportunities, not
only for Indian automation companies, but also for foreign companies. The rapid development of
home-based automations, along with M2M (machine-to-machine) communications will continue
to create billions of new connected objects over the next 5 years and beyond.
CHAPTER -2
As the popularity of Arduino boards increased, the demand for boards which comes embedded
with some of the add-ons used with the Arduino increased. One of the most popular add-ons
were the WiFi modules which are used to connect Arduino boards to the internet. Several boards
were released by different manufacturers which used the Arduino form factor and had onboard
WiFi module, but none of these boards became as popular as the NodeMCU. Today, we will be
exploring how to use the NodeMCU board in projects and especially how to easily program the
board using the Arduino IDE.
The NodeMCU is an ESP8266 WiFi based microcontroller board that helped overcome some of
the difficulties associated with several versions of boards based on the ESP8266 WiFi
module/chips from Espressif.
The Arduino came at a time when the IOT revolution was starting out and it gave makers the
opportunity to be part of that revolution by building simple connected devices, combining the
Arduino and several different kinds of WiFi and Ethernet modules/shields. All those modules
were either too expensive or quite complex to use. So when the first version of the ESP8266
module (ESP-01) came to market, it was an absolute delight as the low price and quality drove
the popularity of the chip. Users, however, quickly discovered several constraints from the power
requirements to the breadboard unfriendliness of the chip. The chips had little (written in
Chinese) or no documentation and this made them even more difficult to use. Several other
versions of the modules were made but they all had similar constraints.
To resolve some of the issues associated with these modules, several breakout and development
boards based on these modules were made such as the Wemos D1 (which worked like the
Arduino Uno) and Wemos Mini boards, but none of them quite achieved the same level of
popularity as the NodeMCU.
The NodeMCU board is essentially a breakout/development board for the ESP12E module by
AI-thinker.
ESP-12E
The ESP-12E itself, just like the previous modules, was difficult to work with, due to factors
including: breadboard unfriendliness, it requires header pins that were not common on the
market, and the only solution to these problems, that was envisioned at the time, was an adapter
coupled with an FTDI breakout board and some other connections to make it breadboard friendly
and easy to program.
The NodeMCU was the product of that search, incorporating all the required components on a
single breadboard friendly, ready to use board while retaining the low cost with which the ESP-
based boards were associated.
The ESP8266 NodeMCU has total 30 pins that interface it to the outside world. The connections are as
follows:
For the sake of simplicity, we will make groups of pins with similar functionalities.
Power Pins There are four power pins viz. one VIN pin & three 3.3V pins. The VIN pin can be
used to directly supply the ESP8266 and its peripherals, if you have a regulated 5V voltage
source. The 3.3V pins are the output of an on-board voltage regulator. These pins can be used to
supply power to external components.
GND is a ground pin of ESP8266 NodeMCU development board.
I2C Pins are used to hook up all sorts of I2C sensors and peripherals in your project. Both I2C
Master and I2C Slave are supported. I2C interface functionality can be realized
programmatically, and the clock frequency is 100 kHz at a maximum. It should be noted that I2C
clock frequency should be higher than the slowest clock frequency of the slave device.
GPIO Pins ESP8266 NodeMCU has 17 GPIO pins which can be assigned to various functions
such as I2C, I2S, UART, PWM, IR Remote Control, LED Light and Button programmatically.
Each digital enabled GPIO can be configured to internal pull-up or pull-down, or set to high
impedance. When configured as an input, it can also be set to edge-trigger or level-trigger to
generate CPU interrupts.
ADC Channel The NodeMCU is embedded with a 10-bit precision SAR ADC. The two
functions can be implemented using ADC viz. Testing power supply voltage of VDD3P3 pin and
testing input voltage of TOUT pin. However, they cannot be implemented at the same time.
UART Pins ESP8266 NodeMCU has 2 UART interfaces, i.e. UART0 and UART1, which
provide asynchronous communication (RS232 and RS485), and can communicate at up to 4.5
Mbps. UART0 (TXD0, RXD0, RST0 & CTS0 pins) can be used for communication. It supports
fluid control. However, UART1 (TXD1 pin) features only data transmit signal so, it is usually
used for printing log.
SPI Pins ESP8266 features two SPIs (SPI and HSPI) in slave and master modes. These SPIs also
support the following general-purpose SPI features:
Up to 64-Byte FIFO
SDIO Pins ESP8266 features Secure Digital Input/Output Interface (SDIO) which is used to
directly interface SD cards. 4-bit 25 MHz SDIO v1.1 and 4-bit 50 MHz SDIO v2.0 are
supported.
PWM Pins The board has 4 channels of Pulse Width Modulation (PWM). The PWM output can
be implemented programmatically and used for driving digital motors and LEDs. PWM
frequency range is adjustable from 1000 μs to 10000 μs, i.e., between 100 Hz and 1 kHz.
Control Pins are used to control ESP8266. These pins include Chip Enable pin (EN), Reset pin
(RST) and WAKE pin.
EN pin – The ESP8266 chip is enabled when EN pin is pulled HIGH. When pulled LOW the
chip works at minimum power.
WAKE pin – Wake pin is used to wake the chip from deep-sleep.
This is a LOW Level 5V 2-channel relay interface board, and each channel needs a 15-20mA
driver current. It can be used to control various appliances and equipment with large current. It is
equiped with high-current relays that work under AC250V 10A or DC30V 10A. It has a standard
interface that can be controlled directly by microcontroller
Features
Schematic
VCC and RY-VCC are also the power supply of the relay module. When you need to drive a
large power load, you can take the jumper cap off and connect an extra power to RY-VCC to
supply the relay; connect VCC to 5V of the MCU board to supply input signals.
Principle
See the picture below: A is an electromagnet, B armature, C spring, D moving contact, and E
fixed contacts. There are two fixed contacts, a normally closed one and a normally open one.
When the coil is not energized, the normally open contact is the one that is off, while the
normally closed one is the other that is on.
Add a certain voltage to the coil and some currents will pass through the coil thus generating the
electromagnetic effect. So the armature overcomes the tension of the spring and is attracted to
the core, thus closing the moving contact of the armature and the normally open contact (or you
may say releasing the former and the normally closed contact). After the coil is de-energized, the
electromagnetic force disappears and the armature moves back to the original position, releasing
the moving contact and normally closed contact. The closing and releasing of the contacts results
in power on and off of the circuit.
Input:
VCC : Connected to positive supply voltage (supply power according to relay voltage)
GND : Connected to negative supply voltage
IN1: Signal triggering terminal 1 of relay module
IN2: Signal triggering terminal 2 of relay module
Output:
Each sub modular of the relay has one NC(normal close), one NO(normal open) and one
COM(Common). So there are 2 NC, 2 NO and 2 COM of the channel relay in total. NC stands
for the normal close port contact and the state without power; No stands for the normal open port
contact and the state with power. COM means the common port. You can choose NC port or NO
port according to whether power or not.
The bulb fits into the bulb holder, the bulb holder ‘holds’ the bulb.The bulb holder contains the
electrical connection from the supply to the bulb. The metal end of the bulb comes into contact
with the supply when the bulb is screwed into the bulb holder.
How the bulb connects to the electrical supply is shown in the image below.
The image below shows 3 different types of electrical contacts.
The electrical contacts are inside the bulb holder at the top of the bulb holderThe different types
of bulb holder electrical contact will ‘match’ the electrical contact on the bulb.The screw fitting
in the image would have a bulb holder with a single electrical contact – the right hand electrical
contact.The electrical contact is usually made from copper.
The light bulbs have been illuminating our homes, offices, and buildings since Thomas Edison
and Joseph Swan invented the first incandescent bulb in the 19th century. Two century after, the
lights bulbs have seen tremendous development and significant improvement regarding
efficiency, quality of light, density, and energy conservation. Even though, we still carry the basic
image of a light bulb in our mind; the light bulbs are available in different shapes, sizes, voltages,
and material. The Electrical and Lighting Distributor Bay Area offer lamps and light bulbs
manufactured by General Electric, Philips, Cooper Lighting, Dialights, etc.
Here is the common types of Light Bulbs along with their respective advantages.
Incandescent Bulbs:
Incandescent bulbs are the typical bulbs. In an incandescent bulb, a tungsten filament glows when
the current passes through it, illuminating the bulb. The tungsten filament is surrounded by
vacuum or nitrogen gas. The bulbs are available in different sizes including GLS, globe, candies,
mushroom. However, the sudden flow of current causes the filament to heat and burn out.
Incandescent bulbs only work for 700–1000 hours and are cause energy waste.The incandescent
bulbs have been the most common type of bulbs in the buildings since the invention of bulbs and
are only recently replaced by the newer form of technology including LEDs, Fluorescent and HID
bulbs.
The CFL are designed to replace incandescent bulbs in homes and commercial building. Working
on the principle of fluorescent lamps, the CFL produces the same amount of light with less power.
It consists of multiple tubular loops, filled with mercury and has a resemblance to the
incandescent bulb.
As compared to incandescent bulbs, CFLs have a longer lifespan up to 10000 hours, are more
energy efficient, and have higher luminous efficiency. But, the mercury in the loops makes them
difficult to dispose of.
Jumper wires are simply wires that have connector pins at each end, allowing them to be used to
connect two points to each other without soldering. Jumper wires are typically used
with breadboards and other prototyping tools in order to make it easy to change a circuit as
needed. Fairly simple. In fact, it doesn’t get much more basic than jumper wires.
Jumper wires typically come in three versions: male-to-male, male-to-female and female-to-
female. The difference between each is in the end point of the wire. Male ends have a pin
protruding and can plug into things, while female ends do not and are used to plug things into.
Male-to-male jumper wires are the most common and what you likely will use most often. When
connecting two ports on a breadboard, a male-to-male wire is what you’ll need.
2.2 SOFTWARE
2.2.1 ADAFRUIT
Adafruit.io is a cloud service - that just means we run it for you and you don't have to
manage it. You can connect to it over the Internet. It's meant primarily for storing and then
retrieving data but it can do a lot more than just that!
Adafruit IO is currently in beta. If you would like to join the beta, head over
to io.adafruit.com to sign up.
Adafruit.io is a cloud service - that just means we run it for you and you don't have
to manage it. You can connect to it over the Internet. It's meant primarily for storing
and then retrieving data but it can do a lot more than just that!
After following above steps, provide name to the dashboard and save it. We can see our
dashboard as follows,
Now, create feed (user interface) to control light On-Off. To create it, just click on ‘+’ symbol
and select toggle feed shown below,
After selecting toggle feed, pop-up window appears as shown below.
Enter name of our feed (shown in red box) and create it. After creation, select the created feed
(here mine is light) and then click on Next step.
In the next step configure the feed which is shown below,
Here, I used 0(OFF) and 1(ON) text for button and then click on create. This will create toggle
button on your dashboard which can be used to control things remotely.
2.2.2 IFTTT (IF THIS THEN THAT)
If This Then That, also known as IFTTT is a free web-based service to create chains of simple
conditional statements, called applets. An applet is triggered by changes that occur within other
web services such as Gmail, Facebook, Telegram, Instagram, or Pinterest.
For example, an applet may send an e-mail message if the user tweets using a hashtag or copy a
photo on Facebook to a user's archive if someone tags a user in a photo.
Here, I used IFTTT to use google assistant service and Adafruit service in chain. So, when I use
google assistant to control light of my home by saying Ok google, turn the light ON or OFF.
Then IFTTT interpret the message and can send it to Adafruit’s dashboard as a understandable
command to the created feed.
Configure IFTTT
Note: Create account on IFTTT by using same e-mail id which you have used for Adafruit.
After account creation, click on My Applets and then select New Applet shown below,
After selecting a new applet, we get a new page in which we should click on to This as shown in
below image.
Now, enter voice phrases which we will use as a command for google assistant.
We can enter any phrase as per our application. As you can see, the phrases entered in the above
fields is for making Light ON. For making Light OFF, we have to create another applet with
different phrases.
Now, we get another page on which we have to click on that option which is used to connect
Google Assistant with Adafruit.
Assistant initially debuted in May 2016 as part of Google's messaging app Allo, and its voice-
activated speaker Google Home. After a period of exclusivity on the Pixel and Pixel
XL smartphones, it began to be deployed on other Android devices in February 2017, including
third-party smartphones and Android Wear (now Wear OS), and was released as a standalone
app on the iOS operating system in May 2017. Alongside the announcement of a software
development kit in April 2017, the Assistant has been, and is being, further extended to support a
large variety of devices, including cars and third party smart home appliances. The functionality
of the Assistant can also be enhanced by third-party developers.
In 2017, Google Assistant was installed on more than 400 million devices.
Users primarily interact with Google Assistant through natural voice, though keyboard input is
also supported. In the same nature and manner as Google Now, the Assistant is able to search the
Internet, schedule events and alarms, adjust hardware settings on the user's device, and show
information from the user's Google account. Google has also announced that the Assistant will
be able to identify objects and gather visual information through the device's camera, and support
purchasing products and sending money, as well as identifying songs.
At CES 2018, the first Assistant-powered smart displays (smart speakers with video screens)
were announced, with the first one being released in July 2018.
2.3 PROGRAMMIMG USING MQTT PROTOCOL
Here, I used the Adafruit MQTT library for receiving data from the Adafruit server. To install
this library, select option Sketch -> Include Library -> Manage Libraries.
In that library, search for Adafruit MQTT and installed it.
#include <ESP8266WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#define Relay1 D6
#define Relay2 D5
#define Relay3 D2
#define Relay4 D1
// Setup the MQTT client class by passing in the WiFi client and MQTT
server and login details.
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT,
AIO_USERNAME, AIO_KEY);
/****************************** Feeds
***************************************/
void MQTT_connect();
void setup() {
Serial.begin(115200);
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
pinMode(Relay4, OUTPUT);
WiFi.begin(WLAN_SSID, WLAN_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
void loop() {
MQTT_connect();
Adafruit_MQTT_Subscribe *subscription;
while ((subscription = mqtt.readSubscription(20000))) {
if (subscription == &Light1) {
Serial.print(F("Got: "));
Serial.println((char *)Light1.lastread);
int Light1_State = atoi((char *)Light1.lastread);
digitalWrite(Relay1, Light1_State);
}
if (subscription == &Light2) {
Serial.print(F("Got: "));
Serial.println((char *)Light2.lastread);
int Light2_State = atoi((char *)Light2.lastread);
digitalWrite(Relay2, Light2_State);
}
if (subscription == &Light3) {
Serial.print(F("Got: "));
CHAPTER-3