You are on page 1of 42

A SIMPLE SMART HOME BASED ON IoT USING

NODEMCU AND BLYNK


ABSTRACT

 The Internet of Things (IoT) is connecting the devices and tools to the internet network to be
controlled by websites and smart phone applications remotely, also, to control tools and instruments
by codes and algorithms structures for artificial intelligence issues.

 In order to save energy and make loads monitored easily, this project suggests smart home project
based on IoT technology. This smart home is an Internet of Things (IoT) project that controls loads
with internet connection via Wireless Fidelity WIFI connection and Blynk application.

 To demonstrate the effectiveness and feasibility of this system, here we present a home automation
system using ArduinoIDE and ESP32 as connectivity module. It helps the user to control various
appliances such as light, fan, TV and can take decision based on the feedback of sensors remotely.
1. INTRODUCTION

 A smart phone connected to internet with Blynk application as a control panel, and NodeMCU
microcontroller kit in other side as a controller that receives control commands via WIFI signal.
 The WIFI receiver and microcontroller are built in one kit to be used as IoT project. It’s called
NodeMCU.
 NodeMCU kit is built with ESP32 WIFI receiver that able to process and analyze WIFI signal to
input the microcontroller.
 ESP32 is connected as built-in in the NodeMCU board that contains a firmware runs with the ESP32.
The firmware is a low-level control computer software.
 The NodeMCU is coded via Arduino Integrated Development Environment (IDE) with the Universal
Serial Bus port (USB) to tell the NodeMCU what to do, In this project NodeMCU controls relay kit
by Blynk hand phone application.
Overview of the System

Home automation offers a futuristic way of life in which


an individual gets to control his entire house using a smart
phone, from turning on a TV to locking/unlocking doors; it also
offers an efficient use of energy. But to get or acquire such
system installed will cost a lot of money and that is the major
reason of why home automation has not received much demand
and attention, adding to that also the complexity of installing it
and configuring it.
Thus it is essential to make it cost effective and easy to
configure, if this is granted to people then they will be willing
to acquire it in their homes, offices and schools. In other words,
a system modification for the home automation is required in
order to lower the price of applying it to houses.
Existing System

 The Existing system based on with the GSM Module & Bluetooth Module only. The recent
developments in technology which permit the Use of Bluetooth and Wi-Fi have enabled different
devices to have capabilities of connecting with each other.
 Using a WIFI shield to act as a Micro web server for the Arduino eliminates the need for wired
connections between the Arduino board and computer which reduces cost and enables it to work as a
standalone device.
 The Wi-Fi shield needs connection to the internet from a wireless router or wireless hotspot and this
would act as the gateway for the Arduino to communicate with the internet.
 With this in mind, an internet based home automation system for remote control of home appliances is
designed.
2. LITERATURE SURVEY

S.NO TITLE AUTHOR JOURNAL, YEAR


Internet of things: A survey on A. Al-Fuqaha, M. Guizani, M.
IEEE Communications Surveys & Tutorials, vol. 17, pp. 2347-
1 enabling technologies, protocols, and Mohammadi, M. Aledhari, and M. 2376, 2015
applications Ayyash

Internet of Things (IoT): A Literature Somayya Madakam, R. Ramaswamy,


2 Journal of Computer and Communications, 2015, 3, 164-173
Review Siddharth Tripathi,

ARES 08 proceedings of the 2008 Third International


3 NFC Devices: Security and Privacy Gerald, Josef,Christian and Josef Conference, IEEE Computing Society, Washington, DC, USA,
Scharinger
2008

Security and privacy challenges in IoT- H. C. Chen, M. A. A. Faruque and P. H. 2016 International Conference on Hardware/Software
4 based machine-to-machine collaborative Codesign and System Synthesis (CODES+ISSS), Pittsburgh,
Chou
scenarios PA, 2016, pp. 1-2
International conference on Signal Processing,
IoT in Connected Vehicles: Challenges
5 andIssues- A Review Y.Usha Devi, Dr. M.S.S.Rukmini Communication, Power and Embedded System (SCOPES)-
2016
RFID security and privacy: a research IEEE Journal on Selected Areas in Communications, vol.
6 survey A. Juels 24, no. 2, pp. 381-394, Feb. 2006

Research on the architecture of EEE International Conference on Advanced Computer


7 Miao W., Ting L., Fei L., ling S., Hui D Theory and Engineering (ICACTE), Sichuan province, China,
Internet of things Pages: 484-487
Science Direct journal of Computer Networks, Volume 54,
8 The Internet of Things: A survey Luigi A., Antonio I., Giacomo M Pages: 2787–2805
S.NO TITLE AUTHOR JOURNAL, YEAR

9 A. Identification of Human Driver G. Burnham, J. Seo G. Bekey IEEE Transactions on Automatic Control 19, 6, 1974, pp.
Models in Car Following 911–915.

Secure Code Distribution in Dynamically


10 Programmable Wireless Sensor J. Deng, R. Han, and S. Mishra Proc. of ACM/IEEE IPSN, 2006. pp. 292-300
Networks
A Vision of a Smart City in the Future,
11 J. Stankovic Vol. 1, Issue 10, Oct. 2013
Smart Cities
Optima Smart Home Energy
12 Management Consi- dering Energy Anvari-Moghaddam, A., Monsef, H. IEEE Transactions on Smart Grid, 6, 324-332.
and Rahimi-Kian, A
Saving and a Comfortable Lifestyle

Building the internet of things using rfid E. Welbourne, l. Battle, g. Cole, k.


13 the rfid ecosystem ̘experience Gould, k. Rector, s. Raymer, et ̘al. IEEE internet comput. 13 (2009) 48–55

14 RFID security and privacy: a research A. Juels IEEE j sel ̘areacomm. 24 (2006) 381–394
survey

International Journal of Technical Research and


15 A SURVEY: THE INTERNET OF THINGS Ruchi Parashar, Abid Khan, Neha Applications e-ISSN: 2320-8163, Volume 4, Issue 3
(May-June, 2016)

Abakós, Belo Horizonte,v. 1, n. 2, p. 78 – 95, maio 2013 –


16 A survey on Internet of Things Shashank Agrawal, Dario Vieira ISSN:2316–9451
3. DESCRIPTION OF PROPOSED SYSTEM

Flow of the System

 The NodeMCU is connected to the internet from the hotspot of the smart
phone via WIFI connection as the NodeMCU has ESP32 circuit to connect
with the internet.
 NodeMCU to be connected to the hotspot of the smart phone, needs to be
identified to the name of hotspot, the password and token code letting the
server of Blynk connects them together.
 We need the computer once to transfer code from Arduino IDE to the
NodeMCU kit to prepare the software part of the project. Figure shows that
the server of Blynk application will process the smartphone-NodeMCU
connection.
 Blynk libraries are ZIP files can be downloaded from Github website to be
imported to the Arduino IDE library.
 Blynk server will check for internet connection, NodeMCU with
android hotspot, the NodeMCU code includes the token code, the
name of hotspot and its password.
 The information included to the code must be match with the hotspot
information to allow ESP8266 connect with the WIFI to be as a
channel to exchange commands between smart phone and NodeMCU.
 Remaining processes are just commands sent from Blynk application
to NodeMCU to control loads those are connected to the relay kit And
sensor output value is sent reverse to the Blynk application from
NodeMCU kit.
 Blynk server will check for internet connection and hotspot name and
password, the sensor output value to show the temperature correctly.
Flowchart of Load ON/OFF
Block Diagram of the System

 The Power Supply will provide energy to the system through the
relay and NodeMCU ESP8266 modules, so that all equipment can
work and function properly.
 NodeMCU ESP8266 microcontroller will read the temperature by
the Temperature sensor LM35, and then send the data to the Blynk
server in TCP / IP format for display on the smart phone.
 NodeMCU ESP8266 microcontroller will also read commands
that have been sent by the Blynk Server in TCP / IP format which
will then be changed by giving the logic "HIGH" or "LOW" on
certain pins by relay to regulate the on / off of the home lights.
 Cloud (internet) by utilizing Wi-Fi becomes the central connection
between Blynk application and NodeMCU project.
BLYNK Application And Arduino IDE Preparation

 This project is running by Blynk application.


Download the application to a smart phone from
Google play store and then create a project on it
with four switches and one gauge to be as a
temperature scale.
 Set buttons to be switches on D1, D2, D3 and D4.
 Then set gauge on A0 because the sensor output is
on A0 in NodeMCU board. Figure shows
screenshots from Blynk application.
NodeMCU code via Arduino IDE
 To code NodeMCU via Arduino IDE, the NodeMCU needs to be added to Arduino IDE library first by
adding this address to Arduino IDE preferences.
 After this reference is added to Arduino IDE, download nodeMCU to boards manager and then select
NodeMCU 1.0 (ESP-12E Module).
 After nodeMCU is added to Arduino IDE library, upload this code with changing hotspot name and
password also token code.
 The code includes the hotspot name and password match with the android. The code does not need to
identify the relay input, as it is included in [Blynk.run();].
 When auth (autho token) is given by Blynk application sent as email and SSID is the name of smart
phone hotspot.
Hardware of the system

 NodeMCU needs 5VDC as a supply voltage Vin pin,


AC-DC step down converter 12V and DC-DC step
down converter 5V, in case using AC-DC step down
converter 5V, no need to use DC-DC converter.
 Output voltage of the power supply is connected to Vin
NodeMCU, Vcc of relay kit and VCC of LM35
temperature sensor.
 When the ground is common. D1, D2, D3 and D4 are
outputs and A0 is an analog signal input is connected to
the temperature sensor
Hardware of the system
The circuit diagram
Pins used:
 
1) Vin is connected to power supply output 5VDC.
2) GND is ground.
3) D1, D2, D3 and D4 are used as digital outputs.
4) A0 is used as analog signal input to input sensor signal.

Relay Module

 Relay module is being connected directly to digital circuits including microcontroller kits easily to control
big loads by a microcontroller.
 The inputs IN1, IN2, IN3 and IN4 operate four relays with voltage between 3-5 volts DC. Input and output
circuits are separated by Optocouplers to protect digital circuits in case connection mistakes happened or
short circuits
Relay Module Circuit Diagram
 
WI-FI ESP32

 ESP32 is designed for mobile, wearable electronics, and Internet-of-Things (IOT) applications. It features
all the state-of-the-art characteristics of low-power chips, including fine-grained clock gating, multiple
power modes, and dynamic power scaling. For instance, in a low-power IOT sensor hub application
scenario, ESP32 is woken up periodically and only when a specified condition is detected. Low-duty cycle
is used to minimize the amount of energy that the chip expends.
 The output of the power amplifier is also adjustable, thus contributing to an optimal trade-off between
communication range, data rate and power consumption.
 ESP32 integrates an antenna switch, RF balun, power amplifier, low-noise receive amplifier, filters, and
power management modules. As such, the entire solution occupies minimal Printed Circuit Board (PCB)
area.
 ESP32 uses CMOS for single-chip fully-integrated radio and baseband, while also integrating advanced
calibration circuitries that allow the solution to remove external circuit imperfections or adjust to changes in
external conditions.
ESP32 Pin Layout Functional Block Diagram
GPIO pins of ESP32 DEVKIT
Relay Switch

 A relay is an electrically operated switch with of a set of input terminals to


control single or multiple signals with a set of operating contact terminals.
Relays with usually calibrated operating characteristics and multiple operating
coils are used in the protection of electrical circuits from overloading. The
electric power systems in modern time’s uses digital instruments called
protective relays.
 Latching relays requires a single pulse of power control to operate the switch
persistently. Another pulse applied to a second set of control terminals, or a
pulse with opposite polarity, resets the switch and the repeated pulses of the
same kind has no effects. The Magnetic latching relays are used to control
interrupted power which affect the circuits in the relay.
4. SOFTWARE IMPLEMENTATION
ESP32 Development Board for Arduino IDE

Before starting this installation procedure, make sure you have the latest version of the Arduino IDE
installed in your computer. To install the ESP32 board in your Arduino IDE, follow these next instructions:

 In your Arduino IDE, go to File> Preferences

 Enter https://dl.espressif.com/dl/packa
ge_esp32_index.json into the
“Additional Board Manager URLs”
field as shown in the figure below.
Then, click the “OK” button.
 Open the Boards Manager.  Search for ESP32 and press install button for the
 Go to Tools > Board > Boards Manager “ESP32 by Espressif Systems”
 That’s it. It should be installed after a few seconds.  If everything went as expected, you should see a
“Done uploading.” message.
Blynk Cloud

 The availability of virtually unlimited storage and processing capabilities at low cost enabled the
realization of a new computing model, in which virtualized resources can be leased in an on-demand
fashion, being provided as general utilities.
 Large companies (like Amazon, Google, Facebook, etc.) widely adopted this paradigm for delivering
services over the Internet, gaining both economic and technical benefits. Specific issues have been
identified for each service models, which are mainly related to security (e.g., data security and
integrity, network security), privacy (e.g., data confidentiality), and service-level agreements, which
could scare away part of potential users.
 Moreover, the lack of standard APIs prevents customers to easily extract code and data from a site to
run on another. Cloud computing model is attractive since it frees the business owner from the need to
invest in the infrastructure, renting resources according to needs and only paying for the usage.
Moreover, it allows decreasing operating costs.
Cloud and IOT: Factors for their Integration

 Cloud facilitates the flow between IOT data collection and data processing, and enables rapid setup and
integration of new things, while maintaining low costs for deployment and for complex data processing.
 Automation can be applied to both data collection and distribution at low cost. Cloud offers an effective and
cheap solution to connect, track, and manage anything from anywhere at any time by using customized
portals and built-in apps.
 The availability of high speed networks enables effective monitoring and control of remote things, their
coordination, their communications, and real-time access to the produced data.
Create a New Project

 After successfully logged into the account, the next


step is to start by creating a new project. User need
to select the hardware model to be used.
 Blynk supports more than 400 boards already,
including support for Arduino, ESP8266 (Generic,
NodeMCU, Witty Cloud, Huzzah, WeMos D1, Seeed
Wio Link, etc.), ESP32 (WiFi, BLE), Raspberry Pi,
BeagleBone Black, Particle, ARM mbed, TI Energia,
MicroPython, Node.js, OpenWRT and many Single
Board Computers.
User will find the project canvas empty and thus required
to add widgets or blocks to their project. For that purpose, user
needs to tap anywhere on the canvas to open up the widget box.
All the available widgets are located here. Users need to pick
and place the widget of their choice.
 Drag-n-Drop – User need to tap and hold the Widget to drag
it to the new position
 Widget Settings - Each Widget has its own settings and user
need to tap on the widget to get to them
The most important parameter to set is PIN. The list of pins
reflects physical pins defined by the user’s hardware. If the
LED is connected to Digital Pin 8, then select D8 where D
means Digital.
5. HARDWARE IMPLEMENTATION
Working Process of the Module

 The home automation circuit is built in the Arduino IDE, W-Fi module ESP32 and a 4-channel relay board.
Arduino IDE is powered with a 12V DC adaptor/power source.
 The relay module and Wi-Fi modules are powered using Arduino IDE, via the USB cable or a battery.
Arduino consists of 14 digital input/output pins, six analogue inputs, a USB connection for programming
the on board MCU, a power jack, an ICSP header and a reset button.
 It is operated with a 16MHz crystal oscillator and contains everything needed to support the MCU. It is
simple to connect it to a computer using a USB cable, or power it with an AC-to-DC adapter or battery to
get started. The MCU on board is programmed in Arduino programming language using Arduino IDE.
Arduino Connectivity with ESP32

 Connect the Arduino’s 3.3V pin output to the red line on


a breadboard. ESP8266 is connected to 3.3V and not 5V,
as it is standard.
 To connect components that use 5V, connect the 5V
output to the other red line of the bread board. Connect
GND (ground) to the blue line.
 Then Connect the RES pin to the blue line and ground
the reset pin. The Arduino works with the USB to serial
connector. Connect the RXD pin of the Arduino to the
RX pin of the ESP32.
WI-FI ESP32 Connectivity with Sensor Modules

 Connection of Wi-Fi module to the sensor is simple when compared to Arduino. VCC pin provides the
3.3V current that is extended using the bread board.
 Then digital pins are connected to send the signals to perform the operation. The sensors are connected
to the ESP32 via the jumper cables.
 The voltage is provided either by connecting to the Wi-Fi VCC or directly to the Arduino board where
it has 3.3V and 5V pin. The sensors send the data to the ESP32 and then to the Arduino board where it
is processed and the tasks are executed.
 Connect the TXD pin of the Arduino to the TX pin of the ESP. To communicate each other over serial,
we connect the TX one to the RX of the other which send goes to receive and the total opposite to it.
WI-FI ESP32 Connectivity with Smart Device

 The Android phone is used in connection of sensors to Wi-


Fi. ESP326 has the advantage of working with android
application without any dependency on any
microcontrollers but it can’t be used in automation.
 Arduino software has inbuilt library function of Wi-Fi
ESP32 Shield which enables the connectivity of Wi-Fi to
the Android devices.
 The Arduino code opens up a network connection, then it
is detected by the Android W-Fi and it doesn’t require any
other modules. Arduino board enables the automated
program code to be implemented in the ESP32 and is set to
automatic detecting and connecting to the network.
Mini Project Working Video
6. RESULTS AND SYSTEM ANALYSIS

Light Control Test Results

 The Light Control Test is done by pressing the


ON / OFF button widget on the Blynk application
on the respective Android smart phone for lights
and fans.
 This is done after the system is turned on and
connected to a Wi-Fi internet connection.
 If at any time the internet connection is lost or
bad signal, then it also affects system
performance. Table shows switches test results.
System Analysis

 From testing the entire system above, the smart home works according to what is the purpose of this
research. Comparison of this research with previous studies, namely this study uses temperature sensor
and control buttons, thus increasing the diversity of the smart home system itself.
 Also, used a microcontroller that is different from previous studies that is the NodeMCU ESP8266
module which has advantages compared to other microcontrollers.
 The smart home has been successfully built with hardware arranged in such a way that it can achieve
results that are as expected.
 In this case the hardware that plays a very important role as the main device is the NodeMCU ESP8266
module.
 The advantages of using the NodeMCU ESP8266 are more practical than buying various components and
then assembling them by yourself.
7. PROGRAMMING CODE
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h> // THESE 3 LIBRARIES FOR USING BLYNK CLOUD
#include <SimpleTimer.h>
#include <SPI.h>
#include<Servo.h> // SERVO MOTOR LIBRARY
#include <ESP8266WiFi.h> //NODEMCU WIFI MODULE LIBRARY
#include <DHT.h> //DHT11 SENSOR LIBRARY

char auth[] = "ms-7JXRFHoFYKmxOsglX4rL1"; //AUTHENTICATION KEY PROVIDED BY BLYNK CLOUD


char ssid[] = "naani"; //WIFI SSID
char pass[] = "12345677"; //WIFI PASSWORD

#define DHTPIN 2 //DHT 11 - TEMPERATURE AND HUMIDITY SENSOR


#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

SimpleTimer timer; //SIMPLE TIMER

void Sensor() //FUNTION TO READ DHT11 SENSOR VALUES


{
int h = dht.readHumidity();
int t = dht.readTemperature();
if (isnan(h) || isnan(t))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.println(h); //TO PRINT HUMIDITY VALUES ON SERIAL MONITOR
Serial.println(t); //TO PRINT TEMPERATURE VALUES ON SERIAL MONITOR
Blynk.virtualWrite(V7,h); //TO PUBLISH HUMIDITY VALUES TO BLYNK CLOUD
Blynk.virtualWrite(V8,t); //TO PUBLISH TEMPERATURE VALUES TO BLYNK CLOUD
}

Servo servo; //TO DECLARE SERVO

void setup()
{
Serial.begin(9600); //TO BEGIN SERIAL MONITOR
Blynk.begin(auth, ssid, pass);//TO BEGIN BLYNK CLOUD CONNECTION
dht.begin(); // TO BEGIN DHT11 SENSOR
timer.setInterval(1000L,Sensor); //TO EXECUTE THE FUNTION Sensor FOR EVERY SECOND
servo.attach(D8); //TO DECLARE THAT THE SERVO IS CONNECTED TO PIN D8
servo.write(0);
}

void loop()
{
Blynk.run(); //TO START PUBLISHING DATA TO BLYNK CLOUD
timer.run(); //TO START TIMER
}

BLYNK_WRITE(V1) //THIS FUNCTION IS TO WRITE THE VALUES OF SERVO FROM BLYNK MOBILE INTERFACE
{
servo.write(param.asInt());
}
8. APPLICATIONS
9. CONCLUSION
Based on the results of analysis of all data obtained by testing the smart home with the Internet of Things
based NodeMCU ESP32 module, the following conclusions can be drawn:
 Smart Home with Internet of Things (IOT) based NodeMCU ESP32 Module can be designed with various
components hardware and software support so that it can be arranged into a smart home system that is
controlled with the Blynk android application according to what is intended.
 The Smart Home with this Internet of Things (IOT) based NodeMCU ESP32 Module can be implemented
to control some of the home electronics performance including lighting controls, fan control, temperature
monitoring, early warning systems and etc.
 Optimizing the power control consumption of the NodeMCU ESP32 module to be further developed in
wireless-based technology application, considering the current technology prioritizes low cost but efficient.
 The development of an internet-based smart home system of things needs to be tested on other electronic
devices in everyday life.
10. REFERENCES

1) Arduino Temperature Sensor Using LM35. Groups of Electronics Hobbyist, Roboticist. We Developed
Electronics Project Tutorials Make Open for Everyone.
2) BOHORA, Bharat; MAHARJAN, Sunil; SHRESTHA, Bibek Raj. IoT Based Smart Home Using Blynk
Framework. Zerone Scholar, [S.l.], v. 1, n. 1, p. 26-30, dec. 2016. ISSN 2542-2774. google scholar.
3) DC-DC Step Down Converter Power Supply Provides Regulated 5VDC Output with Range Input of 10-
32VDC, Model GTD21088L-1505-T2.
4) Home Automation Using Internet of Thing 2016 IEEE 7th Annual Ubiquitous Computing, Electronics &
Mobile Communication Conference (UEMCON) Published: 2016. Google Scholar.
5) Internet of Things in Home Automation and Energy Efficient Smart Home Technologies Simon G. M. Koo
Department of Computer Engineering, Santa Clara University, CA 95053, USA .
6) 15-17 March 2018 U. Venkanna IoT Based Smart Home Automation System Using Sensor Node. Google
Scholar.
THANK YOU

You might also like