Professional Documents
Culture Documents
NODEMCU
Submitted in fulfillment for the J-Component of CSE2006(D1) –
Microprocessors and Interfacing
S. No. Section
1. Abstract
2. Introduction
3. Overview
4. Goals
5. Lean Canvas
6. HRS
7. Software Specifications
9. Code
10. Tinkercad Simulation
12. Dashboard
13. Innovation
14. Applications
16. Conclusion
Abstract
Home automation involves introducing a degree of computerized or automatic control to
certain electrical and electronic systems in a home. It uses a combination of hardware and
software technologies that enable control and management over appliances and devices
within a home. These include lighting, temperature control, entertainment systems,
appliances, ventilation, etc. This project demonstrates a simple home automation system
that contains a remote mobile host controller and several client modules (home
appliances). The client modules communicate with the host controller (here, an android
smartphone) through wireless networks, like Wi-Fi or Bluetooth, via the third-party web
application Adafruit or a voice assistant. The devices in your homes can be controlled from
anywhere in the world from a smartphone. However, it is not necessary to manually control
the devices as the devices are triggered automatically with the help of sensors such as like
LDR, Ultrasonic sensor, and PIR motion sensor. The purpose of this Home Automation is for
homeowners to have centralized control over the electrical and electronic devices in the
home and thus provide comfort, convenience, security, and a better quality of life. It also
helps save energy and resources which in turn saves money and has a positive effect on
the environment. It is especially useful for the elderly and disabled as their dependency on
others reduces and patients can live in the comfort of their homes rather than moving to a
healthcare facility. Home Automation has countless other applications, such as air and
water quality control, pet and baby care, gardening management, smart locks, and security
robots.
Introduction
Home automation is also known as domotics, and a home with an
automation system is known as a smart home.
The working principle of an LDR (Light Dependent Resistor) is photoconductivity i.e. when
the light is absorbed by the material then the conductivity of the material enhances. The
light incident on LDR must have ample energy to make the electrons jump from one band
to another band (valence to conduction). As more electrons are excited to the conduction
band the number of charge carriers is also large and due to this the current flowing
increases and thus the conductance of the device increases.
PIR (Passive Infrared) Motion Sensor is made of a pyroelectric sensor, which can detect
different levels of infrared radiation. Any object with temperature is constantly radiating
infrared rays to the outside world. Once there is infrared radiation from the human body
particle with temperature, focusing on the optical system causes the pyroelectric device to
generate a sudden electrical signal. So, when a human or animal passes by, then it
intercepts the first slot of the PIR sensor which causes a positive differential change
between the two bisects. Whereas when the human or animal leaves the sensing area, the
sensor generates a negative differential change between the two bisects.
Servo Motor consists of a DC Motor, a Gear system, a position sensor, and a control circuit.
The DC motors get powered by a battery and run at high speed and low torque. The Gear
and shaft assembly connected to the DC motors lower this speed into sufficient speed and
higher torque. The position sensor senses the position of the shaft from its definite
position and feeds the information to the control circuit. The control circuit accordingly
decodes the signals from the position sensor and compares the actual position of the
motors with the desired position and accordingly controls the direction of rotation of the
DC motor to get the required position.
The predominant part of this system is the Node MCU (ESP8266). Node MCU is an
open-source IoT platform. It is simple & smart, interactive, programmable & Wi-Fi enabled
and that's why we choose Node MCU over Raspberry Pi. Node MCU is cheaper than other
devices available in the market. Inbuilt Wi-Fi helps with remote access and makes the
system accessible from any remote location around the globe providing an internet
connection.
Lastly, the device also includes voice automation for LEDs which can be used by Google
assistant and a third-party web application called Adafruit. It can be used for mobile data
from anywhere around the world.
Goals
1. All the home functions can be managed by one single user and the only thing we
have to do is learn the use of an app on our smartphones and tablets.
2. It will be environment friendly i.e., minimizing the use of resources, not only do we
reduce our spending, but also decrease our carbon footprint. This is one of our
objectives to use IoT.
3. To use IOT based home to increase the comfort of the user by giving the algorithms
that will enable the decision, making capability of the smart home. Thus, making life
easier for the user.
4. Using smart home technology, we can use our home appliances even at times when
we are not present in town.
5. A smart home can save you a lot of time. Imagine having all control of your home on
a remote, it is time-saving and will help you in increasing your efficiency.
6. By using web control in your home, you can increase the protection and security of
your home.
LEAN CANVAS MODEL
Problem Solution
In industries, such as automobile plants, automation has In this project, we demonstrate the operation of a simple home automation system that consists
reached a high level of sophistication. However, automation of a remote mobile host controller and several client modules (home appliances).
has not yet reached homes, especially in India. By using wireless networks, like
A home automation system would simplify everyday life if it Wi-Fi or Bluetooth, the client modules communicate with the host controller (here, an android
were used. People sometimes forget to lock the doors after smartphone).Thus providing access to home applicances to the target customers.
leaving their homes or turn off the gas knob after walking
away from home which may result in hazardous gas leaks.
So we have decided to make a low-cost Embedded System
in which smartphones can be used to help automate the
entire home.
In this system, the user will have remote access and control
over all the subsystems present in the house
3. LED 4
5. Arduino UNO R3 1
6. Node MCU(Microcontroller-unit) 1
7. Servo Motor(SG90) 1
6. Node MCU(Microcontroller-unit) 1
7. Servo Motor(SG90) 1
9. Bread Board 1
I. Arduino IDE
It is a cross-platform application that is written in functions from C and C++. The
Arduino code written in the IDE is uploaded to the microcontroller which executes
the code by interacting with inputs and outputs.
II. NodeMCU
NodeMCU is an open-source development board and firmware based on the widely
used ESP8266 -12E WiFi module. It allows you to program the ESP8266 WiFi module
with the simple and powerful LUA programming language or Arduino IDE.
Software Implementation
The system is controlled using a Web Page that is based on an IoT platform. The intended
device can be powered ON or OFF using the above application. Also, it provides the facility
to set the intensities of different appliances. The system becomes platform-independent
due to the use of a web application. It can be operated from any location by just opening
the IoT platform web application. The web application also serves as a platform for
managing devices and data.
Flowchart of the Simulation
The block diagram of the system shows that the input will be given through a Web App which will be
based on an IoT platform. Through this web app, besides the regular on or off operation, the
intensity of different devices can be controlled. Also, depending on the environment and outdoor
conditions, the devices will change their working. The LDR (Light Dependent Resistor)sensor will
detect outdoor light. If not found sufficient, the system will start the tube light. Besides all this, the
system will also support manual operation. The IR sensor will sense some aspects of the
surroundings. If the person enters the room, the IR sensor will automatically start the prescribed
devices.
Code
const int pResistor = A0; // Photoresistor at Arduino analog pin A0 const int
ledPin=9; // Led pin at Arduino pin 9
void setup()
{
void loop() {
sen2Value = digitalRead(5);
if (sen2Value == 0)
if (sen2Value == 1)
value = analogRead(pResistor);
else{
}
void ultra(){ digitalWrite(trigPin, LOW); delayMicroseconds(2);
Serial.println(distance); delay(100); digitalWrite(trigPin, HIGH);
delayMicroseconds(10); digitalWrite(trigPin, LOW);
NodeMcu:
WiFiClient client;
digitalWrite(LED_BUILTIN, LOW);
Serial.print(">"); delay(50);
Serial.println("OK!");
mqtt.subscribe(&onoff);
}
void loop()
LightsStatus.publish("ON");
}
else
LightsStatus.publish("ERROR");
else
//LightsStatus.publish("ERROR");
// if (!mqtt.ping())
// {
// mqtt.disconnect();
// }
}
void MQTT_connect()
// mqtt.disconnect();
return;
int8_t ret;
mqtt.disconnect();
if (retries == 0)
{
ESP.reset();
Serial.println("MQTT Connected!");
Simulation
Tinkercad Code:
#include <Servo.h>
int output1Value = 0;
int sen1Value = 0;
int sen2Value = 0;
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);
// Reads the echo pin, and returns the sound wave travel time in microseconds
Servo servo_7;
void setup()
void loop()
//--------------------------------------------------------------
digitalWrite(13, LOW);
Serial.print("Bulb ON = ");
Serial.print(val1);
else
digitalWrite(13, HIGH);
Serial.print(val1);
}
int val = analogRead(gas_sensor); //read sensor value
tone(8, 650);
delay(300);
noTone(8);
//--------------------------------------------------------------
//--------------------------------------------------------------
sen2Value = digitalRead(9);
if (sen2Value == 0)
if (sen2Value == 1)
delay(5000);
//---------------------------------------------------------------
//---------------------------------------------------------------
//--------------------------------------------------------------
//-------------------------------------------------------------
servo_7.write(90);
Serial.print(sen1Value);
Serial.print("\n");
else
servo_7.write(0);
Serial.print(sen1Value);
Serial.print("\n");
}
Hardware snippets
Dashboard
Simulation video link:
https://drive.google.com/file/d/1-AUvw6Vcw7rlclTLVztAhF
1FFlFqW50U/view?usp=sharing
Innovation
We have used Node MCU boards in our project that is used to build a web
server through which all the GPIOs of the board can be controlled over Wi-Fi.
The advantage here is that the system is controlled using a Web Page that is
based on an IoT platform. The intended device can be powered ON or OFF
using the above application. Also, it provides the facility to set the intensities
of different appliances. The system becomes platform-independent due to
the use of a web application. It can be operated from any location by just
opening the IoT platform web application. The web application also serves as
a platform for managing the devices and the data. We have also added voice
control on our application through which we can easily access the system. All
we need is to say which appliances are to be turned ON/OFF.
Applications
Rebuilding consumer expectations, home automation has been projected to
target a wide array of applications for the new digital consumer in a variety of
different realms, including:
● Appliance control and integration with the smart grid and a smart meter It
is the management, control, and optimization of electrical loads through
twoway communication between smart appliances and smart grid, through
smart metering. For instance, taking advantage of high solar panel output in
the middle of the day to run washing machines.
● For the elderly and disabled: Elderly, handicapped patients and people
with disabilities who have problems with locomotion difficulty can benefit
from a smart home to operate, with high performance, all appliances, and
devices from anywhere in the house. This way, they might not have to
depend on someone else and patients can live in the comfort of their homes
rather than moving to a healthcare facility.
● Pet and baby care: Tracking the pets’ and babies' movements, controlling
pet access rights, live video streaming of their activities, temperature, light
and humidity control, protection from hot object hazards, etc. makes it easier
to care for them. Moreover, automatic pet feeders and water dispensers,
smart pet doors, houses, beds, leashes, trackers, etc. make the overall
quality of life for your pets better.
● Air quality control (inside and outside): Gas sensor and humidity sensor
along with a microcontroller enable users to sense the environment for
gases, measure and improve air quality. It follows strict air quality
regulations, saves energy, and helps maintain the user's health and wellness.
It can also be used to monitor the air quality and pollution level outdoors.
● Smart kitchen When it comes to a kitchen, smart products can make things
more efficient, more precise, and safer. A smart kitchen may include
refrigerator inventory, pre-made cooking programs, cooking surveillance, etc.
Moreover, the existence of gas leakage, uncontrolled fire, and excessive
temperatures is quickly identified and addressed.
● Voice control devices Voice control devices like Amazon Alexa or Google
Home are used to control home appliances or systems with simple voice
commands. This is very useful for people with disabilities. The
information-gathering smart speakers double up as conduits for sending
voice commands to thermostats, light switches, whole-home music systems,
security systems, and more.
● Smart Switches A smart switch is a light switch with advanced features that
help automate homes like app or voice control. Some may have extra
buttons for more specific light control, while others may come with
additional sensors or light indicators.
Result/Inference
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 and control buttons, thus increasing the
diversity of the smart home system itself. It has been observed that smooth
output has been seen, when sensors play their role, it’s been observed on
screen easily. Also, we have used a microcontroller that is different from
previous studies that are the Node MCU 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 Node MCU ESP8266 module. The
advantages of using the Node MCU ESP8266 are more practical than buying
various components and then assembling them by yourself. The Light
Control Test is done by pressing the ON / OFF button widget on the Adafruit
application on the respective Android smartphone for lights and fans. Using
components and materials mentioned above shows the project that’s used
as a system controlled by the Adafruit application is running. Loads used in
this project can be changed with other devices with AC plugs to connect
home-use devices or equipment. The home appliances could be remotely
switched over a Wi-Fi network. Both the switch mode and the voice mode
control methodologies were successfully achieved. The Adafruit application
was also successful in displaying the status of every application.
Conclusion
Home automation installed in houses allows centralized control of heating,
ventilation, airconditioning, and lighting. It provides homeowners security,
comfort, convenience, overall cost reduction, and energy efficiency by
allowing them to control smart devices. By incorporating sensors in our
project, the devices don’t need to be controlled manually using the app or
voice assistant. However, for the convenience of the elderly who might be
less familiar with the technology, we have that option available too. Finally, a
conclusion can be drawn that there is immense scope for home automation
in the near future. It also leads to the development of smart appliances, for
example, some smart refrigerators, allow you to scan grocery store receipts
and keep an inventory of your items, and alert you if an item is over or about
to expire. They suggest recipes based on your refrigerator’s contents and
smart ovens synch with your smartphone and automatically preheat to the
correct temperature based on a recipe selected. Thus, home automation will
eventually lead to the development of a technology-friendly environment