A Simple Smart Home Based On Iot Using Nodemcu
A Simple Smart Home Based On Iot Using Nodemcu
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
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
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
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.
14 RFID security and privacy: a research A. Juels IEEE j sel ̘areacomm. 24 (2006) 381–394
survey
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
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
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:
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
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
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
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
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