I have completed Smart Home Automation project in which we are combining the concept of smart home and automated home
with the help of IoT.In this project we have used Microcontroller to control our automation components.We have also used Adafruit.io cloud service IoT platform and IFTTT triggers
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Smart home automation
1. PRESENTED BY :-
Group-12
FIDA E ZEHRA(1673520024)
PRAVEEN KUMAR SINGH(1673520034)
RAHUL KUMAR(1673520035)
SHEKHAR KUMAR(1673520045)
VIVEK KUMAR(1673520057)
PRESENTED TO :-
Project in-charge: Dr. NAVNEET KUMAR
(EE Department)
Supervisor: Mrs. ARCHANA SHARMA
(EE Department)
SMART HOME AUTOMATION
2. As mentioned in the paper “IOT Based Smart Security and Smart Home Automation” published by Sudha Kousalya , G.
Reddi Priya, R. Vasanthi, B Venkatesh Dept. of ECE Aditya College of Engineering Madanapalle ,Chittoor , India in
International Journal of Engineering Research & Technology (IJERT) .
[1] “Internet of Things” is fast becoming a disruptive technology business opportunity, with standards emerging primarily for
wireless communication between devices and gadgets in day to day human life.
[2] This project aims at controlling home appliances and building a smart wireless home security system using Wi-Fi as
communication protocol.
[3] The Home Automation can be implemented using different types of wireless communication techniques such as ZigBee,
Wi-Fi, Bluetooth, GSM, etc.
[4] These existing methods have drawbacks as they work in short range. To overcome this drawbacks, we are going to
implement this project “IOT based Smart security and Smart Home Automation”.
[5] The project focuses on controlling lights and fans referred as Home Automation and providing Smart security by sending
an captured image through an E-mail to the owner using internet when an object is detected. By using “Node MCU” Module
we are going to implement this project. This will be more helpful for Handicapped and aged people These existing methods
have drawbacks as they work in short range.
Literature survey
3. ▪ Home Automation Refers To Handling And Controlling Home Appliances By Using
Microcontrollers Or Computer Technology. Automation & Smart-Automation
▪ There Is An Increasing Demand For Smart Homes, Where Appliance React Automatically
To Environment condition.Control Devices By Using Their Mobile Phones, Internet And
Virtual Assistance.
▪ Control Devices By Using Their Mobile Phones, InternetAnd Virtual Assistance.
Introduction
4. ▪ There Is An Increasing Demand For Smart Homes, Where Appliances React
Automatically To Change Environmental Conditions And Can Be Easily Controlled
Through One Common Device.
▪ Smart System Has A Remote Mobile Host Controller And Several
Client Module.
▪ The Client Modules Communicates With Host Controllers Through A Wireless
Device SuchAs Wi-Fi UsingASmart Phone.
Home Automation
5. Components Of Automation System
• MICROCONTROLLER
• RELAY MODULE
• REALTIME MODULE
• PIR SENSOR
• AC DIMMER MODULES
6. Microcontroller
➢Node Microcontroller Unit Is An Open Source
Software And Hardware Development
Environment Around That Is Built On A Very
Inexpensive System On A Chip Called The
Esp8266.
▪ An Arduino Like Device
▪ With Programmable Pins
▪ Built In Wi-Fi
▪ Powered Via USB
▪ Low Cost
7. Power & Ram
• Input Voltage: 3.3v
• DC Current: 80ma
• RAM 128kb
• 4Mb ROM
• 80 MHz processing
• 2.4 GHz connectivity
• Program It Via C Or LUA
• Access It Via Wi-fi ( Http)
8. ➢Esp8266 Is A Highly Integrated Chip Designed For
The Need Of New Connected World.
➢It Offers Complete And Self Contained Wi-Fi
Networking Solution .
➢I/O Pins:
❖Digital Pins: Pin D0 – Pin D10 Digital Pins
❖PWM Pins: 12 Pins
❖Analog Pins: Pin A0
➢Power Pins:
❖Ground: 5 Pins
❖3.3v: 3
❖Vin PIN: 1 ADDING SUPPLY OF +5V ( IS NOT
CONNECTED TO USB)
9. Relay Module
➢An Electrical Switch That Reads
Input, Uses Electromagnet To Turn
The Switch On Or Off.
➢ESP 01 Is A Bit Particular With The
Pins It Has Two Of The 4 I/O Pins
That Need To Be Pulled High On
Startup.
➢Remaining Two Pins Esp8266-01
And UART .
➢These Can Be Used By GPIO.
➢Esp-01 Needs 3.3 Volt
10. ➢IT USES I2C INTERFACE TO COMMUNICATE
WITH THE NODE MCU BOARD.
➢THIS CIRCUIT HAS TWO PUSH BUTTONS FOR
SETTING TIME AND DATE OF THE REAL TIME
CLOCK.
➢OPERATING VOLTAGE: 3.3 -5V
➢CURRENT 15 MA.
➢FOR SETUP IT REQUIRED WIFI TO CONNECT ,
FETCHES CURREMT DATE AND TIME FROM
REAL TIME CLOCK AND DISPLAY.
➢FOR RESET REMOVE ALL WIRES AND BATTERY
FROM MODULE FROM 10 SECONDS.
Real Time Clock Module
11. PIR Sensor
➢Pyroelectric / Passive Infrared Sensor Allow To Sense
Motion.
➢Inexpensive , Small, Low Power, Easy To Use
➢It Acts As Digital Output.
➢It Has 3 Pins Connection At The Side Or Bottom.
➢Power Is Usually 3- 5 DC Input.
➢VCC To +3n Of MCU.
➢GND Pin To GND Pin.
12. AC Dimmer Module
• The compact ac light dimmer module with zero-crossing detector
• Use as Microcontroller-based ac voltage controlling applications
• Contains a TRIAC triggering coupled with zero-crossing signal detection
mechanism for programming the intensity of incandescent lamps and/or fan
speed.
14. WHAT ELSE CAN WE ADD?
• FAN SPEED
• FIT BAND
• VOICE RECOGNITION
• FACIAL RECOGNITION
• FINGERPRINT FOR
AUTHENTICATION
BEFORE A SAFE LOCK
• ALERT AGAINST
EMERGENCY (GSM
MODULE)
16. Advantages
▪ Low CostAnd Energy Saving.
▪ Helpful For HandicappedAndAged People.
▪ Devices Can Be Controlled From Long Distance.
▪ Highly SecuredAnd Time Saving.
▪ Connect Home Appliances.
▪ No Auxiliary remote are required.
18. Conclusion and Future Scope
▪ Home Automation Is Undeniably A Resource Which Can Make A Home
EnvironmentAutomated.
▪ People Can Control Their Devices And Setup Controlling Action Through
Mobile.
▪ In Future This Product May Have High Potential For Marketing.
19. [1] Ravi Kishore Kodali and Vishal Jain “ IOT based smart security and Home Automation system”
International conference on computing, communication and automation (ICCCA 2016)
[2] R. Piyare and M. Tazil, "Bluetooth based home automation system using cell phone," Consumer
Electronics (ISCE), 2011 IEEE 15th International Symposium on, Singapore, 2011, pp.192-195.
[3] S. Sen, S. Chakrabarty, R. Toshniwal, A. Bhaumik, “Design of an intelligent voice controlled home
automation system”,International Journal of Computer Applications, vol. 121,no.15, pp. 39-42, 2015
[4] H. AlShu'eili, G. S. Gupta and S. Mukhopadhyay, "Voice recognition based wireless home automation
system,"Mechatronics (ICOM), 2011 4th International Conference On, Kuala Lumpur, 2011, pp. 1-6.
[6] A. R. . C. Y. . O. K. Withanage, C., “A comparison of the popular home automation technologies,” pp. 1 –
11, may 2014
[7] https://ifttt.com-google_assistant
[8] https://io.adafruit.com/
References
21. SMART HOME AUTOMATION
BY
FIDA E ZEHRA (1673520024)
PRAVEEN KUMAR SINGH (1673520034)
RAHUL KUMAR (1673520035)
SHEKHAR KUMAR (1673520045)
VIVEK KUMAR (1673520057)
Department of Electrical Engineering
Rajkiya Engineering College,
Chandpur, Bijnor (246725)
JUNE,2020
22. JUNE,2020
Project Report
on
SMART HOME AUTOMATION
Submitted for partial fulfilment of the requirement for the degree of
BACHELOR OF TECHNOLOGY
in
Electrical Engineering
By
FIDA E ZEHRA (Roll No: 1673520024)
PRAVEEN KUMAR SINGH (Roll No: 1673520034)
RAHUL KUMAR (Roll No: 1673520035)
SHEKHAR KUMAR (Roll No: 1673520045)
VIVEK KUMAR (Roll No: 1673520057)
under the supervision of
Mrs. ARCHANA SHARMA
(Asst. Professor REC Bijnor)
project in-charge
Dr. NAVNEET KUMAR
(Asst. Professor REC Bijnor)
Department of Electrical Engineering
RAJKIYA ENGINEERING COLLEGE, BIJNOR
DR. A.P.J ABDUL KALAM TECHNICAL UNIVERSITY, UP, LUCKNOW
23. ii
DECLARATION
I hereby declare that this submission is our own work and that, to the best of our
knowledge and belief, it contains no material previously publishes or written by another person
nor material which to a substantial extent has been accepted for the award of any other degree
or diploma of the university or other institute of higher learning, except where due
acknowledgement has been made in the text.
Signature:
Name:Fida E Zehra
Roll No:1673520024
Date:
Signature:
Name:Praveen Kumar Singh
Roll No:1673520034
Date:
Signature:
Name:Rahul Kumar
Roll No:1673520035
Date:
Signature:
Name:Shekhar Kumar
Roll No:1673520045
Date:
Signature:
Name:Vivek Kumar
Roll No:1673520057
Date:
24. iii
CERTIFICATE
This is to certify that Project Report entitled “SMART HOME AUTOMATION”
which is submitted by Rahul Kumar, Fida E Zehra, Praveen Kumar Singh, Shekhar
Kumar and Vivek Kumar in partial fulfilment of the requirement for the award of degree
B.Tech. in Department of Electrical Engineering of Dr. A.P.J Abdul Kalam Technical
University, U.P., Lucknow., is a record of the candidate own work carried out by him under
my/our supervision. The matter embodies in this thesis is original and has not been submitted
for the award of any other degree.
Date: Supervisor: Mrs. Archana Sharma
25. iv
ACKNOWLEDGEMENT
It gives us a great sense of pleasure to present the report of the B. Tech Project
undertaken during B. Tech. Final Year. We owe special debt of gratitude to our guides
Professor Mrs. Archana Sharma, Dr. Navneet Kumar, Department of Electrical Engineering,
Rajkiya Engineering College, Bijnor for his constant support and guidance throughout the
course of our work. His sincerity, thoroughness and perseverance have been a constant source
of inspiration for us. It is only his cognizant efforts that our endeavour have seen light of the
day.
We also take the opportunity to acknowledge the contribution of Professor Mohmmad
Ahmad, Department of Electrical Engineering, Rajkiya Engineering College, Bijnor for his full
support and assistance during the development of the project.
We also do not like to miss the opportunity to acknowledge the contribution of all
faculty members of the department for their kind assistance and cooperation during the
development of our project. Last but not the least, we acknowledge our friends for their
contribution in the completion of the project.
26. v
ABSTRACT
Smart Home Automation refers to handling and controlling home appliances by using
micro-controller or computer technology. Automation is popular now days because it provides
ease,security and efficiency. In this, a sensor senses the status of appliances and updates to web
server. If user is far away from home, he can access and change status of appliances i.e.
switches it on/off. User can use local PC. This project will describe approach of controlling
home appliances by using web server.This IOT based smart home automation systems are
trying to achieve comfort combined with simplicity.Wireless Smart Home and automated
home are the dual aspects of this project. In the currently built prototype of the system the user
himself enters the room and by virtue of the system he can make arrangements from his
doorstep such that as soon as he enters his house he can make himself at full comfort without
manually having to switch on the electrical appliances or his favourite T.V. channel for an
example. Thus using the same set of sensors the smart home automation can be solved on a
complementary basis. One of the main advantage of this IOT is even though Wi-Fi is not
available we can go through 3G or 4G services. In other existing methods it is not possible so,
by overcoming all the drawbacks we have implemented a project IOT based Smart Home
Automation. This project provides more comfort combined with simplicity.
27. vi
Table of Contents
CHAPTER 1. INTRODUCTION..........................................................................................1
1.1. History .......................................................................................................................1
1.2. Applications and technologies...................................................................................2
1.3. Wireless Home Automation using IOT.....................................................................3
CHAPTER 2. MICROCONTROLLER...............................................................................4
2.1. Introduction ...........................................................................................................4
2.2. Key Features of Microcontrollers..........................................................................5
2.3. Development Boards .............................................................................................6
2.4. Choosing a Microcontroller...................................................................................6
2.5. NODE MCU..........................................................................................................8
2.6. NODEMCU PINOUT & SPECIFICATIONS ......................................................9
CHAPTER 3. SENSORS & MODULES............................................................................14
3.1. INTRODUCTION.............................................................................................14
3.2. PIR SENSOR.....................................................................................................15
3.3. RTC MODULE .................................................................................................18
3.4. RELAY MODULE............................................................................................20
3.5. AC DIMMER MODULES................................................................................23
CHAPTER 4. SOFTWARE APPLICATION & ONLINE SERVICES..........................25
4.1. ARDUINO Integrated Development Environment (IDE) .........................25
4.2. ADAFRUIT................................................................................................28
4.3. IFTTT.........................................................................................................31
4.4. GOOGLE ASSISTANT SDK....................................................................35
CHAPTER 5. DESIGN AND IMPLEMENTATION .......................................................38
5.1. SCHEMATIC & WIRING ........................................................................38
5.2. BLOCK DIAGRAM..................................................................................39
5.3. CREATING ADAFRUIT FEED FOR NODEMCU .................................39
28. vii
5.4. CONFIGURE IFTTT.................................................................................42
5.5. PROGRAMMING NODEMCU................................................................45
5.6. WORKING & FLOW DIAGRAM............................................................72
CHAPTER 6. RESULT AND CONCLUSION..................................................................75
CHAPTER 7. REFERNCES AND BIBLIOGRAPHY.....................................................77
31. x
List of Tables-
Table 2-1:GPIO PIN & INDEX NO. ...................................................................................10
Table 2-2:GPIO PINS & NODEMCU PINS LEVEL ........................................................13
Table 3-1:RTC PINOUT Description..................................................................................19
32. xi
List of symbols
A Ampere
Ω Ohm
V Volt
HZ Hertz
°C Degree Celsius
+ Plus
= Is Equal To
< Less Than to
> Greater Than To
% Percentage
& Ampersand
* Asterisk
# Hashtag
/ Slash
Backlash
_ Underline
33. xii
LIST OF ABBREVIATIONS
IoT Internet Of Things
IPS Indoor Positioning System
MCU Microcontroller Unit
RAM Random Access Memory
GPIO General Purpose Input /Output Pins
RTC Real Time Clock
UART Universal Asynchronous Receiver
Transmitter
LCD Liquid Crystal Display
I/O Input/ Output
ESP Extra Sensory Perception
TCP/IP Transmission Control Protocol/
Internet Protocol
GPS Global Positioning System
SD Secure Digital
PIR Passive Infrared Sensor
IC Integrated Circuit
GND Ground
SDA Serial Data
SCL Serial Clock
SQW Square Wave Output
COM Common
34. xiii
NC Normally Closed
NO Normally Open
GUI Graphical User Interface
IDE Integrated Development
Environment
API Application Programming Interface
35. 1
CHAPTER 1.INTRODUCTION
Home automation or domotics is building automation for a home, called a smart
home or smart house. A home automation system will control lighting, climate, entertainment
systems, and appliances. It may also include home security such as access control and alarm
systems. When connected with the Internet, home devices are an important constituent of
the Internet of Things ("IoT").
A home automation system typically connects controlled devices to a central hub or
"gateway". The user interface for control of the system uses either wall-mounted terminals,
tablet or desktop computers, a mobile phone application or a Web interface, that may also be
accessible off-site through the Internet.
While there are many competing vendors, there are very few worldwide accepted
industry standards and the smart home space is heavily fragmented. Manufacturers often
prevent independent implementations by withholding documentation and by litigation.
The home automation market was worth US$5.77 billion in 2013, predicted to reach a
market value of US$12.81 billion by the year 2020.
1.1. History
Early home automation began with labor-saving machines. Self-contained electrical or
gas power-driven home appliances became viable within the decade with the introduction of
electrical power distribution and light-emitting diode to the introduction of laundry machines
(1904), water heaters (1889), refrigerators, stitching machines, dishwashers, and garments
dryers.
In 1975, the primary general purpose home automation network technology, X10, was
developed. it's a communication protocol for electronic devices. It primarily uses power
transmission wiring for signalling and management, wherever the signals involve transient
oftenness bursts of digital knowledge, and remains the foremost wide obtainable. By 1978,
X10 product enclosed a sixteen channel command console, a lamp module, Associate in
Nursingd an appliance module. presently once came the wall switch module and also the initial
X10 timer.
36. 2
By 2012, within the us, in line with ABI analysis, 1.5 million home automation systems
were put in. Per analysis firm Statista over fourty five million sensible home devices are going
to be put in in U.S. homes by the top of the year 2018.
The word "domotics" (and "domotica" when used as a verb) is a contraction of the
Latin word for a home (domus) and the word robotics.
1.2. Applications and technologies
Heating, ventilation and air conditioning (HVAC): It is possible to have remote
control of all home energy monitors over the internet incorporating a simple and friendly user
interface.
Lighting control system: A "smart" network that incorporates communication
between various lighting system inputs and outputs, using one or more central computing
devices.
Occupancy-aware control system: It is possible to sense the occupancy of the home
using smart meters and environmental sensors like CO2 sensors, which can be integrated into
the building automation system to trigger automatic responses for energy efficiency and
building comfort applications.
Appliance control: Integration with the smart grid and a smart meter, taking
advantage, for instance, of high solar panel output in the middle of the day to run washing
machines.
Home robots and security: A household security system integrated with a home
automation system can provide additional services such as remote surveillance of security
cameras over the Internet, or access control and central locking of all perimeter doors
,windows, Leak detection, smoke and CO detectors, Indoor positioning systems (IPS),Home
automation for the elderly and disabled.
Pet and Baby Care: For example tracking the pets and babies' movements and
controlling pet access rights.
Air quality control: For example, Air Quality Egg is used by people at home to
monitor the air quality and pollution level in the city and create a map of the pollution.
Smart Kitchen and Connected Cooking: Using voice control devices like Amazon
Alexa or Google Home to kitchen appliances.
37. 3
1.3. Wireless Home Automation using IOT
There are various techniques to control home appliances such as IOT based home
automation over the cloud, home automation under WiFi through android apps from any
smartphone, Arduino based home automation, home automation by android application based
remote control, home automation using digital control, RF based home automation system and
touch screen based home automation.
Figure 1-1:Various type of home automation system
Wireless home automation using IOT is an innovative application of internet of
things developed to control home appliances remotely over the cloud. The home automation
system project can be developed by following simple steps shown below.
CONCLUSION: In the future home automation system would be smarter, faster and
offer more ease to scale them. Also a lot of work is being done to incorporate Artificial
Intelligence technology into this field. This will have drastic effect on this field and hopefully
we will than have a fully capable smart home system.
38. 4
CHAPTER 2.MICROCONTROLLER
2.1. Introduction
For automation like this micro controller is the heart of the project as it not only control
the peripheral connected to it also communicate with them
Most IoT applications require more than just adding a sensor to a physical object. When
people talk about ‘smart objects,' they are usually talking about the addition of an Internet-
connected microcontroller (also known as an MCU).
Microcontrollers can be thought of as tiny computers that are added to any physical
object or space to give it a ‘brain.' They contain one or more computer processors, along
with memory and programmable input/output peripherals — all in a single integrated circuit.
MCUs are different from the microprocessors that are found in personal computers
because they are specifically designed for embedded applications where computing is not the
sole purpose of the application.
While MCUs have less capability than a standard computer processor, their low cost
makes them a more practical option for adding computing capabilities to an object, space, or
process that doesn’t have them.
Think of something like a warehouse, bridge, or industrial machine that typically
doesn’t contain a computer. In cases like these, adding an Internet-connected microcontroller
provides enough computing power to enhance these things without adding the higher cost and
complexity of standard computer processors.
39. 5
2.2. Key Features of Microcontrollers
Figure 2-1:Microcontrollers
In order to be able to determine which microcontroller will work the best with your application,
you’ll need to know some of the key features of microcontrollers and what they do. Below are
some of the specs that you’ll encounter and need to make sense of when looking at a data sheet
for an MCU:
Bits: Microcontrollers are typically sold by the number of bits that they offer. This impacts the
speed at which they are able to perform non-trivial computations.
RAM: RAM is a fast-access memory that does not retain data in an absence of power. All
MCUs come with certain amounts of RAM, which allows your microcontroller to quickly
perform various actions. The more you have, the better, but the added RAM increases the cost
of the MCU.
Flash: Flash is computer memory that retains data in the absence of power. At least some of
this is essential, and it’s very useful for features like offline storage.
GPIO: GPIO stands for general-purpose input/output pins. These are the pins that you will use
for connecting your sensors and actuators to the MCU and the internet. The number of pins
can range from one to the hundreds, depending on the microcontroller.
Connectivity: This is how the board (and application) connects to the Internet via Wi-Fi,
Ethernet, or some other means. This is an important aspect of connected sensor applications,
so we’ll go over this topic in greater detail later.
Power consumption: Power consumption is critically important for connected sensor
applications, particularly when your device has to rely on something like a battery or solar
power. This spec will tell you how power hungry the MCU is by default and whether or not it
supports power-conscious programming techniques.
40. 6
Development tools and community: It’s important that there is a mature set of tools,
documentation, and community support to help build programs that will run on the MCU you
select for your application.
2.3. Development Boards
Figure 2-2:Development Board
MCUs are most commonly brought along with what is known as a “development
board." A development board provides everything necessary to program the MCU. They’re
the perfect starting point for building connected systems.
Development boards are printed circuit boards containing an MCU and the supporting
components needed to program the MCU.They include things like a power source, support for
connecting sensors, and sometimes even on board sensors and actuators.They’re useful for
prototyping before final manufacture of a custom solution and popular for various engineers
working on embedded systems development.
Development boards enable users to quickly connect sensors and actuators (if they’re
not already included on the board) and their accompanying software facilitates the creation and
deployment of code.
2.4. Choosing a Microcontroller
It is very important to choose a right development board.There are many different
development boards and microcontrollers available from a variety of
41. 7
companies: TI, Samsung, Arduino, Raspberry Pi and more. Choosing which one is right for
you depends on a number of factors that vary depending on the nature of your application.
Compatibility: Does the MCU support the sensors and actuators you want to use? Depending
on your sensors and actuators, you might need many or just a few ports. You’ll want to make
sure that you have enough input/output ports available.
Architecture: Is the architecture sophisticated enough to handle the complexity of your
program? Most applications use either ARM, MIPS, or X86. Choosing one depends on the
functional requirements of your application and how much computing power your system
needs.
Memory: Does the MCU come with enough memory – RAM and Flash – for your program?
It is highly recommended that you choose an MCU with a comfortable amount of extra memory
for future updates. This will save you time, money, and some major headaches in the long run!
Availability: Can you easily get the MCU that you want and in the quantity that you need?
This is important to consider at the beginning of the process, especially if you plan on scaling
up your system later on.
Power: How much power will the MCU need? Will it need to be wired or can you use batteries?
Energy efficiency is extremely important to consider for industrial IoT applications because
you’ll want to minimize the need for sending maintenance crews to inspect edge infrastructure.
Cost: How much does each unit cost? Does the price make sense based on the value it will
deliver? Again, you’ll want to think about scaling the project up later on. Make sure that your
IoT budget support including more of the MCUs you choose.
Development Kit: Is a development kit available? Development kits are an excellent way to
get started with the MCU you choose because they are designed to give customers an out-of-
box experience. This will make the development of your IoT application much easier.
Development Support: Is good documentation for your MCU available? What is the
community surrounding this board like? These factors are crucial in order to make informed
decisions on how to use your MCU properly. A good online community can help guide you
when you are stuck or encounter a problem with your implementation.
So on investigating and finding out the all required facilities we decided to use NODE MCU.
42. 8
2.5. NODE MCU
NodeMCU is an open source LUA based firmware developed for ESP8266 wifi chip. By
exploring functionality with ESP8266 chip, NodeMCU firmware comes with ESP8266
Development board/kit i.e. NodeMCU Development board.
Figure 2-3:NodeMCU v0.9
Since NodeMCU is open source platform, their hardware design is open for
edit/modify/build.NodeMCU Dev Kit/board consist of ESP8266 wifi enabled chip.
The ESP8266 is a low-cost Wi-Fi chip developed by Espressif Systems with TCP/IP protocol.
For more information about ESP8266, you can refer ESP8266 WiFi Module.
There is Version2 (V2) available for NodeMCU Dev Kit i.e. NodeMCU Development
Board v1.0 (Version2), which usually comes in black colored PCB.
43. 9
Figure 2-4:NodeMCU v1.0
NodeMCU 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
display, Magnetometer HMC5883, MPU-6050 Gyro meter + Accelerometer, RTC chips, GPS
modules, touch screen displays, SD cards etc.
Also it is less with programming capability . so that whole system can be reconfigured
as per the requirement. NodeMCU Development board is featured with wifi 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.
2.6. NODEMCU PINOUT & SPECIFICATIONS
While writing GPIO code on NodeMCU, you can’t address them with actual GPIO Pin
Numbers. There are different I/O Index numbers assigned to each GPIO Pin which is used for
GPIO Pin addressing. Refer following table to check I/O Index of NodeMCU GPIO Pins-
45. 11
Figure 2-5:NodeMCU pinout
One important thing to notice about ESP8266 is that the GPIO number doesn’t match
the label on the board silkscreen. For example, D0 corresponds to GPIO16 and D1 corresponds
to GPIO5.
The following table shows the correspondence between the labels on the silkscreen and
the GPIO number as well as what pins are the best to use in your projects, and which ones you
need to be cautious.
The pins highlighted in green are OK to use. The ones highlighted in yellow are OK to
use, but you need to pay attention because they may have unexpected behavior mainly at boot.
The pins highlighted in red are not recommended to use as inputs or outputs.
46. 12
Label GPIO Input Output Notes
D0 GPIO16 no interrupt no PWM or I2C support
HIGH at boot
used to wake up from deep sleep
D1 GPIO5 OK OK often used as SCL (I2C)
D2 GPIO4 OK OK often used as SDA (I2C)
D3 GPIO0 pulled up OK
connected to FLASH button,
boot fails if pulled LOW
D4 GPIO2 pulled up OK
HIGH at boot
connected to on-board LED,
boot fails if pulled LOW
D5 GPIO14 OK OK SPI (SCLK)
D6 GPIO12 OK OK SPI (MISO)
D7 GPIO13 OK OK SPI (MOSI)
D8 GPIO15 pulled to GND OK
SPI (CS)
Boot fails if pulled HIGH
RX GPIO3 OK RX pin HIGH at boot
TX GPIO1 TX pin OK
HIGH at boot
debug output at boot, boot fails
if pulled LOW
47. 13
A0 ADC0 Analog Input X
Table 2-2:GPIO PINS & NODEMCU PINS LEVEL
CONCLUSION: This study is very useful in understanding the basics of the Micro controller
& development boards. We have studied so far about the development boards but we are going
to use only one of them i.e. NodeMCU.
48. 14
CHAPTER 3.SENSORS & MODULES
3.1. INTRODUCTION
In the broadest definition, a sensor is a device, module, machine, or subsystem whose
purpose is to detect events or changes in its environment and send the information to other
electronics, frequently a computer processor. A sensor is always used with other electronics.
Sensors are used in everyday objects such as touch-sensitive elevator buttons (tactile
sensor) and lamps which dim or brighten by touching the base, besides innumerable
applications of which most people are never aware. With advances in micromachinery and
easy-to-use microcontroller platforms, the uses of sensors have expanded beyond the
traditional fields of temperature, pressure or flow measurement, for example into MARG
sensors. Moreover, analog sensors such as potentiometers and force-sensing resistors are still
widely used. Applications include manufacturing and machinery, airplanes and aerospace,
cars, medicine, robotics and many other aspects of our day-to-day life. There are a wide range
of other sensors, measuring chemical & physical properties of materials. A few examples
include optical sensors for Refractive index measurement, vibrational sensors for fluid
viscosity measurement and electro-chemical sensor for monitoring pH of fluids.
A sensor's sensitivity indicates how much the sensor's output changes when the input
quantity being measured changes. For instance, if the mercury in a thermometer moves 1 cm
when the temperature changes by 1 °C, the sensitivity is 1 cm/°C (it is basically the
slope dy/dx assuming a linear characteristic). Some sensors can also affect what they measure;
for instance, a room temperature thermometer inserted into a hot cup of liquid cools the liquid
while the liquid heats the thermometer. Sensors are usually designed to have a small effect on
what is measured; making the sensor smaller often improves this and may introduce other
advantages.
Technological progress allows more and more sensors to be manufactured on
a microscopic scale as micro sensors using MEMS technology. In most cases, a micro sensor
reaches a significantly faster measurement time and higher sensitivity compared
49. 15
with macroscopic approaches. Due the increasing demand for rapid, affordable and reliable
information in today's world, disposable sensors—low-cost and easy‐to‐use devices for short‐
term monitoring or single‐shot measurements—have recently gained growing importance.
Using this class of sensors, critical analytical information can be obtained by anyone, anywhere
and at any time, without the need for recalibration and worrying about contamination.
3.2. PIR SENSOR
PIR sensors allow you to sense motion, almost always used to detect whether a human has
moved in or out of the sensors range. They are small, inexpensive, low-power, easy to use and
don't wear out. For that reason they are commonly found in appliances and gadgets used in
homes or businesses. They are often referred to as PIR, "Passive Infrared", "Pyroelectric", or
"IR motion" sensors.
Figure 3-1:PIR Sensor
PIRs are basically made of a pyroelectric sensor (which you can see below as the
round metal can with a rectangular crystal in the center), which can detect levels of infrared
radiation. Everything emits some low level radiation, and the hotter something is, the more
radiation is emitted. The sensor in a motion detector is actually split in two halves. The reason
for that is that we are looking to detect motion (change) not average IR levels. The two halves
50. 16
are wired up so that they cancel each other out. If one half sees more or less IR radiation than
the other, the output will swing high or low.
Figure 3-2:PIROELECTRIC Sensor & fresnel lense
Along with the pyroelectic sensor is a bunch of supporting circuitry, resistors and
capacitors. It seems that most small hobbyist sensors use the BISS0001 ("Micro Power PIR
Motion Detector IC"), undoubtedly a very inexpensive chip. This chip takes the output of the
sensor and does some minor processing on it to emit a digital output pulse from the analog
sensor.
Figure 3-3:PIR Internal Circuit
51. 17
Our new PIRs have more adjustable settings and have a header installed in the 3-pin
ground/out/power pads.
Figure 3-4:PIR PIN out & adjusting knob
For many basic projects or products that need to detect when a person has left or entered
the area, or has approached, PIR sensors are great. They are low power and low cost, pretty
rugged, have a wide lens range, and are easy to interface with. Note that PIRs won't tell you
how many people are around or how close they are to the sensor, the lens is often fixed to a
certain sweep and distance (although it can be hacked somewhere) and they are also sometimes
set off by housepets.
Output: Digital pulse high (3V) when triggered (motion detected) digital low when idle (no
motion detected). Pulse lengths are determined by resistors and capacitors on the PCB and
differ from sensor to sensor.
Sensitivity range: up to 20 feet (6 meters) 110° x 70° detection range.
Power supply: 5V-12V input voltage for most modules (they have a 3.3V regulator), but 5V
is ideal in case the regulator has different specs.
52. 18
3.3. RTC MODULE
Real time clocks (RTC), as the name recommends are clock modules. The DS1307 real
time clock (RTC) IC is an 8 pin device using an I2C interface. The DS1307 is a low-power
clock/calendar with 56 bytes of battery backup SRAM. The clock/calendar provides seconds,
minutes, hours, day, date, month and year qualified data. The end date of each month is
automatically adjusted, especially for months with less than 31 days.
They are available as integrated circuits (ICs) and supervise timing like a clock and also
operate date like a calendar. The main advantage of RTC is that they have an arrangement of
battery backup which keeps the clock/calendar running even if there is power failure. An
exceptionally little current is required for keeping the RTC animated. We can find these RTCs
in many applications like embedded systems and computer mother boards, etc. In this article
we are going to see about one of the real time clock (RTC), i.e. DS1307.
Figure 3-5:DS3231 RTC Module
DS3231 is a six terminal device, out of them two pins are not compulsory to use. So we have
mainly four pins. These four pins are given out on other side of module sharing the same name.
53. 19
Pin Name Description
VCC Connected to positive of power source.
GND Connected to ground.
SDA Serial Data pin (I2C interface)
SCL Serial Clock pin (I2C interface)
SQW Square Wave output pin
32K 32K oscillator output
Table 3-1:RTC PINOUT Description
Figure 3-6:RTC MODULE PINOUT
54. 20
DS3231 RTC MODULE Features-
RTC counts seconds, minutes, hours and year
Accuracy: +2ppm to -2ppm for 0ºC to +40ºC , +3.5ppm to -3.5ppm for -40ºC to +85ºC
Digital temperature sensor with ±3ºC accuracy
Two Time-of-day alarms
Programmable square wave output
Register for Aging trim
400Khz I2C interface
Low power consumption
Automatic power failure battery switch circuitry
CR2032 battery backup with two to three year life
Potable size
3.4. RELAY MODULE
A relay is an electrically operated switch that can be turned on or off, letting the current go
through or not, and can be controlled with low voltages, like the 5V provided by the Arduino
pins. Controlling a relay module with the Arduino is as simple as controlling any other output
as we’ll see later on.
Figure 3-7:2-Channel Relay Module
55. 21
This relay module has two channels (those blue cubes). There are other models with one,
four and eight channels. This module should be powered with 5V, which is appropriate to use
with an Arduino. There are other relay modules that are powered using 3.3V, which is ideal
for ESP32, ESP8266, and other microcontrollers.
The following figure shows the relay module pinout.
Figure 3-8:Relay Module PINOUT
The six pins on the left side of the relay module connect high voltage, and the pins on
the right side connect the component that requires low voltage the Arduino pins.
The high-voltage side has two connectors, each with three sockets: common (COM),
normally closed (NC), and normally open (NO).
Figure 3-9:High Voltage side pinout
56. 22
COM: common pin
NC (Normally Closed): the normally closed configuration is used when you want the relay to
be closed by default, meaning the current is flowing unless you send a signal from the Arduino
to the relay module to open the circuit and stop the current.
NO (Normally Open): the normally open configuration works the other way around: the relay
is always open, so the circuit is broken unless you send a signal from the Arduino to close the
circuit.
If you just want to light up a lamp occasionally, it is better to use a normally-open circuit
configuration.The low-voltage side has a set of four pins and a set of three pins.
Figure 3-10:Control PINOUT
The set at the right consists of VCC and GND to power up the module, and input 1 (IN1) and
input 2 (IN2) to control the bottom and top relays, respectively.The second set of pins consists
of GND, VCC, and JD-VCC pins. The JD-VCC pin powers the electromagnet of the relay.
57. 23
3.5. AC DIMMER MODULES
The compact ac light dimmer module with zero-crossing detector described here is ideal
for microcontroller-based ac voltage controlling applications and projects. This module
contains a triac triggering coupled with zero-crossing signal detection mechanism for
programming the intensity of incandescent lamps and/or fan speed controlled through a
microcontroller circuitry.
Figure 3-11:AC Dimmer Module
Circuit of the module shown here offers improved performance and reliableness using
very little power and just a few plain vanilla components.
Figure 3-12:Circuit Diagram
58. 24
It is clear from the circuit diagram that the key component of the design is a standard
triac (TR1). The circuitry which is linked to the microcontroller via the signal input header
(H1) drives an optoisolator triac driver (OC1). One set of terminals of this component is
connected to the triac, whereas the set of terminals at the otherside is switched via the I/O line
of the external microcontroller and an integral current-limiting resistor (R1). Since the triac
incorporate a snubber network, the dimmer can be used for controlling inductive loads,too. The
next optocoupler (OC2) serves to detect the mains zero-crossing.
Zero-crossing is used for synchronizing the dimmer. The optoisolator is linked directly
to the mains supply since a transformer causes an unwanted small phase shift that may induce
anomalies in the performance. The synchronizing pulse is buffered by a small signal transistor
(T1) and routed to the signal output header (H2).
The circuit can be assembled on a small perfboard, and the work is straight forward as
long as the specified components are used. Since several tracks carry the full mains voltage,
extreme care is required in the assembly. Always unplug the module from the mains before
doing any work or checking some thing after assembly. Also note that to ensure correct
operation the module should be connected to a frequency-stable mains supply only. The
dimmer module may be used for stage lighting, for controlling domestic lights, for illuminating
aquariums, or for mood lighting.
CONCLUSION: The study of sensors and modules helps for the project work . so we can
use these sensors and modules in our project without any problem.
59. 25
CHAPTER 4.SOFTWARE APPLICATION &
ONLINE SERVICES
4.1. ARDUINO Integrated Development Environment (IDE)
An integrated development environment (IDE) is software for building applications that
combines common developer tools into a single graphical user interface (GUI). An IDE
typically consists of:
Source code editor: A text editor that can assist in writing software code with features such
as syntax highlighting with visual cues, providing language specific auto-completion, and
checking for bugs as code is being written.
Local build automation: Utilities that automate simple, repeatable tasks as part of creating
a local build of the software for use by the developer, like compiling computer source code
into binary code, packaging binary code, and running automated tests.
Debugger: A program for testing other programs that can graphically display the location of
a bug in the original code.
Figure 4-1:Arduino IDE software
60. 26
Arduino is an open-source electronics platform based on easy-to-use hardware and
software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a
Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing
something online. You can tell your board what to do by sending a set of instructions to the
microcontroller on the board. To do so you use the Arduino programming language (based
on Wiring), and the Arduino Software (IDE), based on Processing.
Over the years Arduino has been the brain of thousands of projects, from everyday
objects to complex scientific instruments. A worldwide community of makers - students,
hobbyists, artists, programmers, and professionals - has gathered around this open-source
platform, their contributions have added up to an incredible amount of accessible
knowledge that can be of great help to novices and experts alike.
Figure 4-2:Arduino LOGO
Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast
prototyping, aimed at students without a background in electronics and programming. As soon
as it reached a wider community, the Arduino board started changing to adapt to new needs
and challenges, differentiating its offer from simple 8-bit boards to products
for IoT applications, wearable, 3D printing, and embedded environments. All Arduino boards
are completely open-source, empowering users to build them independently and eventually
adapt them to their particular needs. The software, too, is open-source, and it is growing
through the contributions of users worldwide.
61. 27
Figure 4-3:Arduino Library
There are many other microcontrollers and microcontroller platforms available for
physical computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard,
and many others offer similar functionality. All of these tools take the messy details of
microcontroller programming and wrap it up in an easy-to-use package. Arduino also
simplifies the process of working with microcontrollers, but it offers some advantage for
teachers, students, and interested amateurs over other systems:
Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller
platforms. The least expensive version of the Arduino module can be assembled by hand, and
even the pre-assembled Arduino modules cost less than $50
Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux
operating systems. Most microcontroller systems are limited to Windows.
Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for
beginners, yet flexible enough for advanced users to take advantage of as well. For teachers,
62. 28
it's conveniently based on the Processing programming environment, so students learning to
program in that environment will be familiar with how the Arduino IDE works.
Open source and extensible software - The Arduino software is published as open source
tools, available for extension by experienced programmers. The language can be expanded
through C++ libraries, and people wanting to understand the technical details can make the
leap from Arduino to the AVR C programming language on which it's based. Similarly, you
can add AVR-C code directly into your Arduino programs if you want to.
Open source and extensible hardware - The plans of the Arduino boards are published under
a Creative Commons license, so experienced circuit designers can make their own version of
the module, extending it and improving it. Even relatively inexperienced users can build
the breadboard version of the module in order to understand how it works and save money.
4.2. ADAFRUIT
Adafruit Industries is an open-source hardware company based in New York City. It was
founded by Limor Fried in 2005. The company designs, manufactures and sells a number of
electronics products, electronics components, tools and accessories. It also produces a number
of learning resources, including live and recorded videos related to electronics, technology,
and programming.
Figure 4-4:Adafruit Logo
In addition to distributing third party components and boards such as the Raspberry Pi,
Adafruit develops and sells its own development boards for educational and hobbyist purposes.
63. 29
In 2016, the company released the Circuit Playground, a board with
an Atmel ATmega32u4 microcontroller and a variety of sensors, followed in 2017 by the more
powerful Atmel SAMD21 based Circuit Playground Express. They, like many Adafruit
products, are circular in shape for ease of use in education and wearable
electronics projects, along with the FLORA and Gemma, the companies wearable electronics
development platforms. In 2017, Adafruit Industries best selling product was the Circuit
Playground Express
It is a solution for the construction of applications IoT created by Adafruit Industries,
the well-known open-source hardware marketer, have created this platform for the internet of
things based on platforms known as Arduino, Raspberry pi, ESP8266, Intel Galileo, Serial
devices And Wifi among others. The Communication API is based on MQTT client with
Adafruit servers.
Figure 4-5:Adafruit IO dashboard
64. 30
Dashboards allow you to visualize data and control Adafruit IO connected projects
from any modern web browser. Widgets such as charts, sliders, and buttons are available to
help you quickly get your IoT project up and running without the need for any custom code.
If you are new to Adafruit IO, you may want to start with the Adafruit IO Feeds
guide before you continue with this guide. If you are comfortable with feeds, then you are
ready to create your first dashboard.
Figure 4-6:Adafruit IO feeds
Feeds are the core of the Adafruit IO system. The feed holds metadata about the data you
push to Adafruit IO. This includes settings for whether the data is public or private, what
license the stored sensor data falls under, and a general description of the data. The feed also
contains the sensor data values that get pushed to Adafruit IO from your device.
You will need to create one feed for each unique source of data you send to the system. For
example, if you have a project with one temperature sensor and two humidity sensors, you
would need to create three feeds. One feed for the temperature sensor, and one feed for each
humidity sensor.
65. 31
4.3. IFTTT
IFTTT derives its name from the programming conditional statement “if this, then that.”
What the company provides is a software platform that connects apps, devices and services
from different developers in order to trigger one or more automations involving those apps,
devices and services.
Figure 4-7:IFTTT dashboard
Here are just three if this, then that automations you can run with IFTTT:
If you make a call on your Android phone, then a log of that call is added to a Google
spreadsheet.
If you add a new task to your Amazon Alexa to-dos, then it will be added to your iOS
Reminders app.
If the International Space Station passes over your house, then you’ll get a smartphone
notification about it. (Yes, this is an actual IFTTT applet.)
Currently, there are 54 million IFTTT applets, according to IFTTT
66. 32
Figure 4-8:IFTTT trigger & action
The automations are accomplished via applets — which are sort of like macros that
connect multiple apps to run automated tasks. You can turn on or off an applet using IFTTT’s
website or mobile apps (and/or the mobile apps’ IFTTT widgets). You can also create your
own applets or make variations of existing ones via IFTTT’s user-friendly, straightforward
interface.
IFTTT has posted a YouTube video (See below) explaining in more detail how applets
are made.
Developers as varied as Ring and BMW pay IFTTT an annual fee to provide applets
on the IFTTT platform. There is even a partnership with UK startup bank Monzo, which,
among other things, lets users automatically withdraw funds from a “rainy day” savings pot
when it is raining, or “reward” themselves each time they go to the gym.
The IFTTT service is free for users.
Typically, developers launch their IFTTT presence with applets they create, and then
the user community “builds stuff the developers never expected,” said Tibbets. IFTTT applets
can use JavaScript, advanced filtering and other tools to create new interactions.
Support for JavaScript helps IFTTT partners create robust applets compared to the more
limited IFTTT recipes of yesteryear, Tibbets said. You could create some custom JavaScript
that will filter things automatically, so that an applet will, for example, turn on multiple lights
in your home if you arrive after 6 p.m. or just the porch light if you arrive home before 6 p.m.,
67. 33
Tibbets said. That sort of functionality wasn’t possible with the simpler recipes but is doable
with applets.
“For users, applets are easier, and for developers, they’re much more powerful,”
Tibbets said.
To date, IFTTT has more than 550 partner services, including Facebook, Domino’s
Pizza — even the city of Louisville, Ky. IFTTT’s community of 11 million users run over 1
billion applets each month, according to the company.
IFTTT has a vast library of existing applets created by other users you can use with
your own apps. Alternatively, you can create your own applet from scratch.
Figure 4-9:IFTTT Applets
Some of the most popular apps that can work with IFTTT include:
Blogger
Medium
Tumblr
WordPress
Bitly
Pocket
68. 34
MailChimp
Salesforce
Google Calendar
Amazon Cloud Drive
Dropbox
Google Docs
Google Sheets
Google Drive
Facebook
Messenger
Skype
Slack
GitHub
Email
Gmail
Fitbit
iOS Calendar
iOS Health
SoundCloud
Spotify
Feedly
NPR
TIME
Wikipedia
Evernote
SMS
VoIP Calls
Android Photos
Flickr
Google Photos
iOS Photos
Vimeo
YouTube
69. 35
4.4. GOOGLE ASSISTANT SDK
Google Assistant is an artificial intelligence–powered virtual assistant developed
by Google that is primarily available on mobile and smart home devices. Unlike the company's
previous virtual assistant, Google Now, the Google Assistant can engage in two-way
conversations.
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 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.
Users primarily interact with the 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. In 2020, Google
Assistant is already available on more than 1 billion devices. Google Assistant is available in
more than 90 countries and in over 30 languages, and is used by more than 500 million users
monthly.
70. 36
Figure 4-10:Google SDK logo
The Google Assistant SDK lets you add voice control, natural language understanding
and Google’s smarts to your ideas. Your project captures an utterance (a spoken audio
request, such as What's on my calendar?), sends it to the Google Assistant, and receives a
spoken audio response in addition to the raw text of the utterance.
Figure 4-11:Google Assistant speech processing
71. 37
The Google Assistant Service exposes a low level API that lets you directly manipulate
the audio bytes of an Assistant request and response. Bindings for this API can be generated
for languages like Node.js, Go, C++, Java for all platforms that support gRPC.
Reference code is provided in Python for audio capture, audio playback, and
conversation state management.
CONCLUSION : Study of all the related services and software is very usefull for the
project work . it helps out to interface hardware with the software .
72. 38
CHAPTER 5.DESIGN AND IMPLEMENTATION
5.1. SCHEMATIC & WIRING
To do wiring firstly we use a online platform circuit .io .Here we can choose the components
and microcontrollers and do a virtual wiring so that it can be used as reference for the final
wiring.
Figure 5-1:Circuit Diagram
+5v & gnd pin of all modules and are connected to the +5v & gnd pin of the bread
board Scl pin of rtc to d1 in nodemcu Out pin of pir to d3 In1,in2,in3,in4 pin of relay module
to d4,d5,d6,d7 Of the nodemcu respectively.
73. 39
5.2. BLOCK DIAGRAM
Figure 5-2:Block Diagram
Block shows how all the services and harwares are interconnected and how they will
communicate with each other to perform a automated task.
5.3. CREATING ADAFRUIT FEED FOR NODEMCU
In order to give command to nodemcu online we have to setup the adafruit . And create a
feed for the node mcu.
First, created an account at www.adafruit.io.
Now, create a dashboard. This dashboard is a user interface to control things
remotely.
74. 40
After following the above steps, provide a name to the dashboard and save it.
Now, create feed (user interface) to control light On-Off. To create it, just click on
the ‘+’ symbol and select the toggle feed shown below.
76. 42
Here, I used 0(OFF) and 1(ON) text for button and then click on create. This will create
a toggle button on your dashboard which can be used to control things remotely.
5.4. CONFIGURE IFTTT
The first step is creating anaccount on IFTTT.
Note: Create an account on IFTTT byusing the same e-mail id which you have used for
Adafruit.
After account creation, click on My Applets and then select New Applet.
After selecting a new applet, we get a new page in which we should click on to This is
shown in the below image.
77. 43
Then search for Google Assistant and select it.
Now, enter voice phrases which we will use as a command for google assistant.
78. 44
We can enter any phrase as per our application. As you can see, the phrases entered in the
above fields are 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.
Then search for Adafruit and select it.
After selecting Adafruit, choose action. Now enter what data we need to send to which
feed of Adafruit dashboard.
Figure 5-3:IFTTT Project applets
79. 45
Click on Create Action.
So, when I use Google Assistant on my mobile and give voice command as “Ok Google,
Turn LED ON”, applet created in IFTTT receives this command and will send data ‘1’ to the
Adafruit feed. This will trigger the event on the Adafruit dashboard which is continuously
monitored by the microcontroller (here NodeMCU). This microcontroller will take action as
per the data change on the Adafruit dashboard.
5.5. PROGRAMMING NODEMCU
Coding for nodemcu has been done on arduino ide software. After taking help of some
other pre existing codes and some modification according to the project and its applications .
We included all the libraries and wire up the hardware to the nodemcu . We uploaded the
programme to the nodemcu.
SCRIPT-
#include "PIR.h"
PIR::PIR(int PIRPin) : signalPin(PIRPin)
{
pinMode(signalPin, INPUT);
}
bool PIR::read()
{
return digitalRead(signalPin);
}
/** addtogroup PIRGeneric
80. 46
* @{
*/
#ifndef PIR_H
#define PIR_H
#include <Arduino.h>
class PIR
{
public:
PIR(int PIRPin);
bool read();
private:
const int signalPin;
};
#endif //PIR_H
/** @}*/
// Code by JeeLabs http://news.jeelabs.org/code/
// Released to the public domain! Enjoy!
#include <Wire.h>
#include "RTClib.h"
#ifdef __AVR__
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#elif defined(ARDUINO_ARCH_SAMD)
// nothing special needed
#elif defined(ARDUINO_SAM_DUE)
#define PROGMEM
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
81. 47
#define Wire Wire1
#endif
#if (ARDUINO >= 100)
#include <Arduino.h> // capital A so it is error prone on case-sensitive filesystems
// Macro to deal with the difference in I2C write functions from old and new Arduino
versions.
#define _I2C_WRITE write
#define _I2C_READ read
#else
#include <WProgram.h>
#define _I2C_WRITE send
#define _I2C_READ receive
#endif
static uint8_t read_i2c_register(uint8_t addr, uint8_t reg) {
Wire.beginTransmission(addr);
Wire._I2C_WRITE((byte)reg);
Wire.endTransmission();
Wire.requestFrom(addr, (byte)1);
return Wire._I2C_READ();
}
static void write_i2c_register(uint8_t addr, uint8_t reg, uint8_t val) {
Wire.beginTransmission(addr);
Wire._I2C_WRITE((byte)reg);
Wire._I2C_WRITE((byte)val);
Wire.endTransmission();
82. 48
}
////////////////////////////////////////////////////////////////////////////////
// utility code, some of this could be exposed in the DateTime API if needed
const uint8_t daysInMonth [] PROGMEM = { 31,28,31,30,31,30,31,31,30,31,30,31 };
// number of days since 2000/01/01, valid for 2001..2099
static uint16_t date2days(uint16_t y, uint8_t m, uint8_t d) {
if (y >= 2000)
y -= 2000;
uint16_t days = d;
for (uint8_t i = 1; i < m; ++i)
days += pgm_read_byte(daysInMonth + i - 1);
if (m > 2 && y % 4 == 0)
++days;
return days + 365 * y + (y + 3) / 4 - 1;
}
static long time2long(uint16_t days, uint8_t h, uint8_t m, uint8_t s) {
return ((days * 24L + h) * 60 + m) * 60 + s;
}
////////////////////////////////////////////////////////////////////////////////
// DateTime implementation - ignores time zones and DST changes
// NOTE: also ignores leap seconds, see http://en.wikipedia.org/wiki/Leap_second
DateTime::DateTime (uint32_t t) {
t -= SECONDS_FROM_1970_TO_2000; // bring to 2000 timestamp from 1970
ss = t % 60;
83. 49
t /= 60;
mm = t % 60;
t /= 60;
hh = t % 24;
uint16_t days = t / 24;
uint8_t leap;
for (yOff = 0; ; ++yOff) {
leap = yOff % 4 == 0;
if (days < 365 + leap)
break;
days -= 365 + leap;
}
for (m = 1; ; ++m) {
uint8_t daysPerMonth = pgm_read_byte(daysInMonth + m - 1);
if (leap && m == 2)
++daysPerMonth;
if (days < daysPerMonth)
break;
days -= daysPerMonth;
}
d = days + 1;
}
DateTime::DateTime (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min,
uint8_t sec) {
if (year >= 2000)
year -= 2000;
yOff = year;
m = month;
d = day;
hh = hour;
mm = min;
84. 50
ss = sec;
}
DateTime::DateTime (const DateTime& copy):
yOff(copy.yOff),
m(copy.m),
d(copy.d),
hh(copy.hh),
mm(copy.mm),
ss(copy.ss)
{}
static uint8_t conv2d(const char* p) {
uint8_t v = 0;
if ('0' <= *p && *p <= '9')
v = *p - '0';
return 10 * v + *++p - '0';
}
// A convenient constructor for using "the compiler's time":
// DateTime now (__DATE__, __TIME__);
// NOTE: using F() would further reduce the RAM footprint, see below.
DateTime::DateTime (const char* date, const char* time) {
// sample input: date = "Dec 26 2009", time = "12:34:56"
yOff = conv2d(date + 9);
// Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
switch (date[0]) {
case 'J': m = (date[1] == 'a') ? 1 : ((date[2] == 'n') ? 6 : 7); break;
case 'F': m = 2; break;
case 'A': m = date[2] == 'r' ? 4 : 8; break;
case 'M': m = date[2] == 'r' ? 3 : 5; break;
case 'S': m = 9; break;
85. 51
case 'O': m = 10; break;
case 'N': m = 11; break;
case 'D': m = 12; break;
}
d = conv2d(date + 4);
hh = conv2d(time);
mm = conv2d(time + 3);
ss = conv2d(time + 6);
}
// A convenient constructor for using "the compiler's time":
// This version will save RAM by using PROGMEM to store it by using the F macro.
// DateTime now (F(__DATE__), F(__TIME__));
DateTime::DateTime (const __FlashStringHelper* date, const __FlashStringHelper* time) {
// sample input: date = "Dec 26 2009", time = "12:34:56"
char buff[11];
memcpy_P(buff, date, 11);
yOff = conv2d(buff + 9);
// Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
switch (buff[0]) {
case 'J': m = (buff[1] == 'a') ? 1 : ((buff[2] == 'n') ? 6 : 7); break;
case 'F': m = 2; break;
case 'A': m = buff[2] == 'r' ? 4 : 8; break;
case 'M': m = buff[2] == 'r' ? 3 : 5; break;
case 'S': m = 9; break;
case 'O': m = 10; break;
case 'N': m = 11; break;
case 'D': m = 12; break;
}
d = conv2d(buff + 4);
memcpy_P(buff, time, 8);
hh = conv2d(buff);
86. 52
mm = conv2d(buff + 3);
ss = conv2d(buff + 6);
}
uint8_t DateTime::dayOfTheWeek() const {
uint16_t day = date2days(yOff, m, d);
return (day + 6) % 7; // Jan 1, 2000 is a Saturday, i.e. returns 6
}
uint32_t DateTime::unixtime(void) const {
uint32_t t;
uint16_t days = date2days(yOff, m, d);
t = time2long(days, hh, mm, ss);
t += SECONDS_FROM_1970_TO_2000; // seconds from 1970 to 2000
return t;
}
long DateTime::secondstime(void) const {
long t;
uint16_t days = date2days(yOff, m, d);
t = time2long(days, hh, mm, ss);
return t;
}
DateTime DateTime::operator+(const TimeSpan& span) {
return DateTime(unixtime()+span.totalseconds());
}
DateTime DateTime::operator-(const TimeSpan& span) {
return DateTime(unixtime()-span.totalseconds());
}
100. 66
PCF8523_SquareWave4kHz = 3, PCF8523_SquareWave8kHz = 2,
PCF8523_SquareWave16kHz = 1, PCF8523_SquareWave32kHz = 0 };
class RTC_PCF8523 {
public:
boolean begin(void);
void adjust(const DateTime& dt);
boolean initialized(void);
static DateTime now();
Pcf8523SqwPinMode readSqwPinMode();
void writeSqwPinMode(Pcf8523SqwPinMode mode);
};
// RTC using the internal millis() clock, has to be initialized before use
// NOTE: this clock won't be correct once the millis() timer rolls over (>49d?)
class RTC_Millis {
public:
static void begin(const DateTime& dt) { adjust(dt); }
static void adjust(const DateTime& dt);
static DateTime now();
protected:
static long offset;
};
#endif // _RTCLIB_H_
// Include Libraries
#include "Arduino.h"
#include "PIR.h"
#include "Wire.h"
101. 67
#include "RTClib.h"
// Pin Definitions
#define PIR_PIN_SIG 0
#define RELAYMODULE4CH_PIN_IN1 2
#define RELAYMODULE4CH_PIN_IN2 14
#define RELAYMODULE4CH_PIN_IN4 13
#define RELAYMODULE4CH_PIN_IN3 12
// Global variables and defines
//define an array for the 4ch relay module pins
int RelayModule4chPins[] = { RELAYMODULE4CH_PIN_IN1,
RELAYMODULE4CH_PIN_IN2, RELAYMODULE4CH_PIN_IN3,
RELAYMODULE4CH_PIN_IN4 };
// object initialization
PIR pir(PIR_PIN_SIG);
RTC_DS3231 rtcDS;
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered
with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
102. 68
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println("start");
if (! rtcDS.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtcDS.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
rtcDS.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtcDS.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
pinMode(RELAYMODULE4CH_PIN_IN1, OUTPUT);
pinMode(RELAYMODULE4CH_PIN_IN2, OUTPUT);
pinMode(RELAYMODULE4CH_PIN_IN3, OUTPUT);
pinMode(RELAYMODULE4CH_PIN_IN4, OUTPUT);
menuOption = menu();
}
// Main logic of your circuit. It defines the interaction between the components you selected.
After setup, it runs over and over again, in an eternal loop.
void loop()
{
if(menuOption == '1') {
// Infrared PIR Motion Sensor Module - Test Code
103. 69
bool pirVal = pir.read();
Serial.print(F("Val: ")); Serial.println(pirVal);
}
else if(menuOption == '2') {
// RTC - Real Time Clock - Test Code
//This will display the time and date of the RTC. see RTC.h for more functions such as
rtcDS.hour(), rtcDS.month() etc.
DateTime now = rtcDS.now();
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
}
else if(menuOption == '3') {
// Relay Module 4-Ch - Test Code
//This loop will turn on and off each relay in the array for 0.5 sec
for (int i = 0; i < 4; i++) {
digitalWrite(RelayModule4chPins[i],HIGH);
delay(500);
digitalWrite(RelayModule4chPins[i],LOW);
delay(500);
}
104. 70
}
if (millis() - time0 > timeout)
{
menuOption = menu();
}
}
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{
Serial.println(F("nWhich component would you like to test?"));
Serial.println(F("(1) Infrared PIR Motion Sensor Module"));
Serial.println(F("(2) RTC - Real Time Clock"));
Serial.println(F("(3) Relay Module 4-Ch"));
Serial.println(F("(menu) send anything else or press on board reset buttonn"));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if(c == '1')
Serial.println(F("Now Testing Infrared PIR Motion Sensor Module"));
106. 72
5.6. WORKING & FLOW DIAGRAM
As we are adding the concept of Smart home and Automated home. An automated home
is essentially, and truly a smart home, whereas the term, ‘smart home’ could be used to refer
to a residence that comprises a plethora of smart devices— devices that don’t necessarily
function by themselves. They’re also generally connected to the Internet, which enables these
devices to be ‘smart’.
Even though the terms aren’t very different, knowing exactly what each means will help
get you what you want when it comes to automated homes. If you have any more queries
regarding home automation please feel free to write to us, and we’ll be happy to clear any
doubts you have.
Figure 5-5:Communication Diagram
107. 73
Smart Home Working- In smart home we will control the room light,fan and other home
appliances by using smartphone and google assistant. Firstly microcontroller(NODE MCU) is
connected through local wifi network for providing the internet connectivity to NODEMCU
After that the NODEMCU is ready to give and take request via internet . The internet
connectivity is provide through a local host or wifi hotspot ., the ssid and the wifi password is
already mention in the sketch uploaded to the NODE MCU .
Figure 5-6:Google Assistant Controlled Home Automation
Additionally a third party website named Adafruit is used for controlling NODE MCU
and give request or command to NODEMCU. This means we connect our node mcu to adafruit
website via internet . For the authentication the user id and authentication key is provided by
the Adafruit. Also the id and authentication key is mentioned in the NODEMCU sketch . As
shown There are feed which were do the job of controlling . These feed were already defined
in the sketch . Here we will defined the value and how this value varies . More than one feed
can be used for the multiple operation After completion one can control the NODE MCU
through any device by log in to Adafruit website Our Nodemcu id interfaced with relay module
which turn on and off as per command received by Adafruit .here a term IFTTT comes it refers
to “ if this then that “ it is also a website. This provide triggers from google assistant. So in
IFTTT we define some specific speech which when sent from google assistant via smartphone
will perform a specific task.
109. 75
CHAPTER 6.RESULT AND CONCLUSION
In this project the implemented system is developed using ESP 8266 12E and by using
Wi-Fi as mode of transmission. The implemented system design specifications are chosen in
such a way that it is flexible in terms of number of devices that could be controlled and at the
same time could be controlled from anywhere in the world. In the future home automation
system would be smarter, faster and offer more ease to scale them. Also a lot of work is being
done to incorporate Artificial Intelligence technology into this field. This will have drastic
effect on this field and hopefully we will than have a fully capable smart home system.
In this project, voice commands are given to the Google assistant. The voice commands
for Google assistant have been added through IFTTT website and the Adafruit account is also
linked to it. In this home automation, user have given commands to the Google assistant. Home
appliances like Bulb, Fan and Motor etc., are controlled according to the given commands. The
commands given through the Google assistant are decoded and then sent to the microcontroller
and it control the relays. The device connected to the respective relay turned On or OFF as per
the users request to the Google Assistant. The microcontroller used is NodeMCU (ESP8266)
and the communication between the microcontroller and the application is established via Wi-
Fi (Internet). There has been tremendous growth in the home automation sector, and many
reputed companies utilizing their opportunity to work with IFTTT to deliver an elegant way to
connect families to their homes. Consumers are looking to secure their home environment in
today’s unpredictable world, and the new Home automation service gives them the peace of
mind that they need to protect their family’s well-being.
This project is about wireless home automation using Android mobile helps us to
implement such a fantastic system in our home at a very reasonable price using cost-effective
devices. Thus, it overcomes many problems like costs, inflexibility, security etc. In addition,
will provide greater advantages like it decrease our energy costs, it improves home security. In
addition, it is very convenient to use and will improve the comfort of our home. The project
has proposed the idea of smart homes that can support a lot of home automation systems. C#
programming language and Node microcontroller have been used to connect the sensors circuit
110. 76
to the home. Also, in home and building automation systems, the use of wireless technologies
gives several advantages which cannot be achieved by using a wired network.
1) Reduced installation costs.
2) Easy deployment, installation, and coverage.
3) System scalability and easy extension.
4) Aesthetical benefits.
5) Integration of mobile devices.
For all these reasons, wireless technology is not only an attractive choice in renovation and
refurbishment, but also for new installations.
111. 77
CHAPTER 7.REFERNCES AND BIBLIOGRAPHY
1. ^ Jump up to:a
Hill, Jim (12 September 2015). "The smart home: a glossary guide for
the perplexed". T3. Retrieved 27 March 2017.
2. ^ "5 Open Source Home Automation Projects We Love". Fast Company. 2014-12-01.
Retrieved 2016-11-22.
3. ^ Fahmy, Hossam Mahmoud Ahmad (2016). Wireless Sensor Networks: Concepts,
Applications, Experimentation and Analysis. p. 108. ISBN 978-981-10-0412-4. The
use of standardized, with open standards over proprietary protocols provides the
industry with the freedom to choose between suppliers with guaranteed
interoperability. Standardized solutions usually have a much longer lifespan than
proprietary solutions.
4. ^ "Research and Markets: Global Home Automation and Control Market 2014-2020 -
Lighting Control, Security & Access Control, HVAC Control Analysis of the $5.77
Billion Industry". Reuters. 2015-01-19. Archived from the originalon 2016-05-05.
5. ^ Home Automation & Wiring (1 ed.). New York: McGraw-Hill/TAB Electronics.
1999-03-31. ISBN 978-0-07-024674-4.
6. ^ Rye, Dave (October 1999). "My Life at X10". AV and Automation Industry
eMagazine. AV and Automation Industry eMagazine. Archived from the original on
September 30, 2014. Retrieved October 8, 2014.
7. ^ "1.5 Million Home Automation Systems Installed in the US This
Year". www.abiresearch.com. Retrieved 2016-11-22.
8. ^ "Smart Home - United States | Statista Market Forecast". Statista. Retrieved 2019-
11-07.
9. ^ Caccavale, Michael. "The Impact Of The Digital Revolution On The Smart Home
Industry". Forbes. Retrieved 2019-11-07.