Major Project - Report
Major Project - Report
On
Home Automation using Esp8266 with Google Assistant
Submitted in partial fulfilment of the requirements for the award of the
Degree of
BACHELOR OF TECHNOLOGY
in
By
A. NITHIN (Regd.No.20891A0403)
MR. J. RAMESH
Assistant Professor
Near Ramoji film city, Deshmuki village, Pochampally Mandal, Yadadri Bhuvanagiri District.
AN AUTONOMOUS INSTITUTION
2023-24
CERTIFICATE
This is to certify that the project report entitled – Home Automation using Esp8266
with Google Assistant submitted by-A.Nithin (20891A0403) ,B.Charan kumar
(20891A0408) , K.Vinod Kumar (20891A0428) , Y.Sai krishna
Reddy(20891A0459) the Vignan Institute of Technology & Science, Yadadri,
Bhuvanagiri Dist., in partial fulfilment for the award of the degree of B. Tech in
Electronics & Communication Engineering is a bonafide record of project work carried
out by him/her under my supervision. The contents of this report, in full or in parts, have
not been submitted to any other Institution or University for the award of any degree or
diploma.
(External Examiner)
i
DECLARATION
A.Nithin 20891A0403
Date: Hyderabad.
ii
ACKNOWLEDGEMENT
Every project big or small is successful largely due to the effort of a number of
wonderful people who have always given their valuable advice or lent a helping hand.
We sincerely appreciate the inspiration; support and guidance of all those people who
have been instrument as in making this project a success.
We thank CEO, Mr. Boyapati Shravan, we remember him for his valuable
ideas and facilities available in college during the development of the project.
1
ABSTRACT
2
TABLE OF CONTENTS
DECRIPTION PAGE NUMBER
CERTIFICATE i
DECLARATION ii
ACKNOWLEDGEMENTS 1
ABSTARACT 2
TABLE OF CONTENTS 3
LIST OF FIGURES 4
LIST OF TABLES 5
1. INTRODUCTION 6
2. Literature survey 8
3.1. Introduction 9
3.4. History 10
3.5. Specifications 11
3.6.1.2. Rectification 15
3.6.1.3. DC filtration 16
3.6.1.4. Regulation 17
4. Implemention 22
3
4.1. Hardware implemention 22
5. Software discription 33
6.3. Moving on 55
6.6. Dubbing 57
7.1. Applications 58
7.2. Advantages 59
8. Conclusion 60
4
LIST OF FIGURES
3.6.1.2. Rectification 15
3.6.1.3. DC filtration 17
3.7 Relay 19
6.3 Moving on 56
LIST OF TABLES
5
CHAPTER 1
INTRODUCTION TO PROJECT
1.1. INTRODUCTION:
World’s demand for electricity had grown 85% between 2010 and 2017 this
increase is more than today’s total use of electricity in India, USA, Japan, Australia
combined. We can’t decrease the electricity growth rate but we can lessen the
amount of electricity wasted each year by turning off our home appliances when
not in use. This project presents a design and prototype of Home Automation
system that will use ESP8266 Wi-Fi module as a network provider in connecting
with other appliances.
The proposed system has two main components. The first main part is
Arduino, which controls and manages input of Wi-Fi module. The other main
component is Wi-Fi module through Wi-Fi module a web server can be added to
the module which will help in controlling of devices over Internet. One server can
manage many hardware interface modules as long as it exists on Wi-Fi network
coverage.
It supports a wide range of home automation devices like power
management components, and security components. We want to make this
automation system centralized and artificially intelligent. Further we will connect
the specific home to our database and it can be accessed from anywhere through a
specific IP address or website. Also, an app would be developed which will allow
the user to control their devices using the Google Assistant.
6
Block Diagram:
Hardware Components:
NodeMCU Module
Relay Driver
Power Supply
Software:
Arduino IDE
7
CHAPTER 2
LITERATURE SURVEY
In their paper, Tan, Lee and Soh (2002) proposed the development of an
Internet-based system to allow monitoring of important process variables from a
distributed control system (DCS). This paper proposes hardware and software
design considerations which enable the user to access the process variables on the
DCS, remotely and effectively rent designations.
8
Potamitis, Georgila, Fakotakis, and Kokkinoss, G. (2003) suggested the use
of speech to interact remotely with the home appliances to perform a particular
action on behalf of the user. The approach is inclined for people with disability to
perform real-life operations at home by directing appliances through speech. Voice
separation strategy is selected to take appropriate decision by speech recognition.
CHAPTER 3
3.1.
INTRODUCTION:
The flowchart explains the home automation system. The controlling device
will be connected with the Wi-Fi module through hotspot created by the module
(fig 1.2). The module will be connected with the microcontroller .The controller
will give the required command to the relay board and the relay board acts as
switch between the circuit. The appliances will be connected with the relay board.
Now, the appliances can be controlled using internet of things.
9
Block Diagram:
History:
NodeMCU was created shortly after the ESP8266 came out. On December
30, 2013, Express if Systems began production of the ESP8266. The ESP8266 is a
Wi-Fi SoC integrated with a Tensilica Xtensa LX106 core, widely used in IOT
applications. NodeMCU started on 13 Oct 2014, when Hong committed the first
10
file of NodeMCU-firmware to GitHub. Two months later, the project expanded to
include an open-hardware platform when developer Huang R committed
the gerber file of an ESP8266 board, named devkit v0.9. Later that month, Tuan
PM ported MQTT client library from Contiki to the ESP8266 SoC platform, and
committed to NodeMCU project, then NodeMCU was able to support the MQTT
IOT protocol, using Lua to access the MQTT broker. Another important update
was made on 30 Jan 2015, when Devsaurus ported the u8glib to NodeMCU
project, enabling NodeMCU to easily drive LCD, Screen, OLED, even VGA
displays.
In summer 2015 the creators abandoned the firmware project and a group of
independent but dedicated contributors took over. By summer 2016 the NodeMCU
included more than 40 different modules. Due to resource constraints users need to
select the modules relevant for their project and build a firmware tailored to their
needs.
Specifications:
NodeMCU Dev Board is based on widely explored esp8266 System on Chip
from Express if. It combined features of WIFI access point and station +
microcontroller and uses simple LUA based programming language. ESP8266
NodeMCU offers-
-- Arduino-like hardware IO
-- Event-driven API for network applications
--10 GPIOs D0-D10, PWM functionality, IIC and SPI communication, 1-Wire and
ADC A0 etc. all in one board
--Wi-Fi networking (can be uses as access point and/or station, host a webserver),
connect to internet to fetch or upload data.
--excellent few $ system on board for Internet of Things (IOT) projects.
11
Recently, there has been interest in programming ESP8266 systems using
Arduino IDE. Programming, of ESP8266 using Arduino IDE is not very straight
forward, until it is properly configured. Especially because, the Input and output
pins have different mapping on NodeMCU than those on actual ESP8266 chip.
I had request about showing how to program ESP-12E NodeMCU using
Arduino IDE. I struggled myself earlier in the beginning, so thought of making this
Instruct able for beginners. This is quick guide/tutorial for getting started with
Arduino and ESP8266 NodeMCU V2 ESP-12Ewifi module. (I think, this method
can be used for other NodeMCU boards too. (or only ESP8266 boards, but with
necessary hardware modifications and using FTDI modules for programming- not
covered in this tutorial because, this is only for NodeMCU development boards).
This Instruct able gives quick intro to-
1) Installing Arduino core for ESP8266 Wi-Fi chip in Arduino IDE and Getting
started with sketches written using latest stable Arduino IDE 1.6.7
2) Run/modify basic LED blink sketch to blink onboard LED and/or externally
connected LED at pin D0 or GPIO-16 as per the pin configuration mentioned
here and here.
NOTE- To use NodeMCU V1 or V2 or V3 development boards using Arduino
IDE, we do not need to flash it with firmware using NodeMCU flasher. It is
required only if we intend to program NodeMCU using Lua script with esplorer
etc.
First and foremost word of - CAUTION!
* The ESP8266 chip requires 3.3V power supply voltage. It should not be powered
with 5 volts like other Arduino boards.
* NodeMCU ESP-12E development board can be connected to 5Vusing micro
USB connector or Vin pin available on board.
* The I/O pins of ESP8266 communicate or input/output max 3.3V only. The pins
are NOT 5V tolerant inputs.
12
NodeMCU Pin out:
13
A regulated power supply is an embedded circuit; it converts unregulated
AC into a constant DC. With the help of a rectifier it converts AC supply into DC.
Its function is to supply a stable voltage (or less often current), to a circuit or
device that must be operated within certain power supply limits. The output from
the regulated power supply may be alternating or unidirectional, but is nearly
always DC.
The regulated power supply will accept an AC input and give a constant DC
output. Figure below shows the block diagram of a typical regulated DC power
supply.
14
1. A step down transformer
2. A rectifier
3. A DC filter
4. A regulator
3.6.1.2. Rectification:
Rectifier is an electronic circuit consisting of diodes which carries out the
rectification process. Rectification is the process of converting an alternating
voltage or current into corresponding direct (DC) quantity. The input to a rectifier
is ac whereas its output is unidirectional pulsating DC. Usually a full wave rectifier
or a bridge rectifier is used to rectify both the half cycles of the ac supply (full
wave rectification). Figure below shows a full wave bridge rectifier.
15
A bridge rectifier consists of four p-n junction diodes connected in the above
shown manner. In the positive half cycle of the supply the voltage induced across
the secondary of the electrical transformer i.e. VMN is positive. Therefore point E
is positive with respect to F. Hence, diodes D 3 and D2 are reversed biased and
diodes D1 and D4 are forward biased. The diode D3 and D2 will act as open
switches (practically there is some voltage drop) and diodes D1 andD4 will act as
closed switches and will start conducting. Hence a rectified waveform appears at
the output of the rectifier as shown in the first figure. When voltage induced in
secondary i.e. VMN is negative than D3 and D2 are forward biased with the other
two reversed biased and a positive voltage appears at the input of the filter.
3.6.1.3. DC Filtration:
The rectified voltage from the rectifier is a pulsating DC voltage having very
high ripple content. But this is not we want, we want a pure ripple free DC
waveform. Hence a filter is used. Different types of filters are used such as
capacitor filter, LC filter, Choke input filter, π type filter. Figure below shows a
capacitor filter connected along the output of the rectifier and the resultant output
waveform.
16
As the instantaneous voltage starts increasing the capacitor charges, it
charges till the waveform reaches its peak value. When the instantaneous value
starts reducing the capacitor starts discharging exponentially and slowly through
the load (input of the regulator in this case). Hence, an almost constant DC value
having very less ripple content is obtained.
3.6.1.4. Regulation:
This is the last block in a regulated DC power supply. The output voltage or
current will change or fluctuate when there is change in the input from ac mains or
due to change in load current at the output of the regulated power supply or due to
other factors like temperature changes. This problem can be eliminated by using a
regulator. A regulator will maintain the output constant even when changes at the
input or any other changes occur. Transistor series regulator, Fixed and variable IC
regulators or a Zener diode operated in the zener region can be used depending on
17
their applications. IC’s like 78XX and 79XX are used to obtained fixed values of
voltages at the output.
The coil of a relay passes relatively large current, typically 30mA for a 12v
relay, but it can be as much as 100mA for relays designed to operate from lower
voltages. Most chips cannot provide this current and transistor. Usually used to
amplify the small IC current to the larger value required for the relay coil. The
maximum output current for the popular 555timer IC is 200ma, so these devices
can supply relay coils directly without amplifications.
Relays usually SPDT or DPDT but they can have more sets of switch
contacts, for example relays with four sets of change over contacts are readily
available.
Most relays are designed for PCB mounting but you can solder wires
directly to the pins providing you take care to avoid melting the plastic case of the
relay.
18
The supplier’s catalogue should show you relay connection. The coil will
be obvious and it may be connected either way round. Relay coils produce brief
high voltage spikes. When they are switched off and this can be destroying
transistors and IC’s in the circuit. To prevent damage, we must connect a
protection diode across a relay coil. The figure shows a working relay with its coil
and switch contacts. You can see the lever on the being attracted by magnetism
when the coil is switched on. This lever moves the switches contacts.
The relay’s switch connections are usually labeled COM, NC, and NO:
COM= common, always connect to this; it is the moving part of the switch.
Connect to COM and NO if you want the switched circuit to be on when the
relay coil is on.
Connect to COM and NC if you want the switched circuit to be on when the
relay coil is off.
Choosing a Relay:
19
1. Physical size and pin arrangement:
If you are choosing a relay for an existing PCB you will need to ensures
that its dimension and pin arrangement are suitable.
2. Coil voltage:
The relays coil voltage rating and resistance must suite the circuit
powering the relay coil. Many relay coil. Many relays have a coil rated for a 12v
supply but 5v and 12v relays are readily available. Some relays operate perfectly
well with a supply voltage which is little lower than rated value.
3. Coil resistance:
The circuit must be able to supply the current required by the relay coil.
We can use ohms law to calculate:
For example: A 12v supply relay with a coil resistance of 400ohms passes a
current of 30ma. This is ok for 555timer IC (maximum output current 200ma), but
it is too much for most ICs and they will require a transistor to amplify the current.
The relays switch contacts must be suitable for the circuit they are to
control. We will need to check the voltage and current ratings. Note that the
voltage rating is usually higher for AC, for example:”5A AT 24VDC OR 125V
AC”.
20
Most relays are SPDT or DPDT which are often described as’ single pole
changeover” (SPCO) or” double pole changeover”(DPCO).
Advantages of relays:
Relays can switch AC and CD, transistors can only switch CD.
Relays can switch high voltages, transistors cannot.
Relay are a better choice for switching large currents (>5a).
Relay can switch many contacts at once.
Disadvantages of relays:
21
CHAPTER 4
IMPLEMENTATION
The ATmega328 on the Arduino Uno comes pre burned with a boot loader
that allows you to upload new code to it without the use of an external hardware
programmer. It communicates using the original STK500 protocol (reference, C
header files). You can also bypass the boot loader and program the microcontroller
through the ICSP (In-Circuit Serial Programming) header; see these instructions
for details. The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware
source code is available. The ATmega16U2/8U2 is loaded with a DFU boot
loader, which can be activated by:
On Rev1 boards: connecting the solder jumper on the back of the board (near
the map of Italy) and then resetting the 8U2.
On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB
line to ground, making it easier to put into DFU mode. You can then use
Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X and
Linux) to load a new firmware. Or you can use the ISP header with an external
programmer (overwriting the DFU boot loader). See this user-contributed
tutorial for more information.
22
on a connected computer. One of the hardware flow control lines (DTR) of the
ATmega8U2/16U2 is connected to the reset line of the ATmega328via a 100 nano
farad capacitor. When this line is asserted (taken low), the reset line drops long
enough to reset the chip. The Arduino software uses this capability to allow you to
upload code by simply pressing the upload button in the Arduino environment.
This means that the boot loader can have a shorter timeout, as the lowering of DTR
can be well-coordinated with the start of the upload. This setup has other
implications. When the Uno is connected to either a computer running Mac OS X
or Linux, it resets each time a connection is made to it from software (via USB).
For the following half-second or so, the boot loader is running on the Uno. While it
is programmed to ignore malformed data (i.e. anything besides an upload of new
code), it will intercept the first few bytes of data sent to the board after a
connection is opened. If a sketch running on the board receives one-time
configuration or other data when it first starts, make sure that the software with
which it communicates waits a second after opening the connection and before
sending this data. The Uno contains a trace that can be cut to disable the auto-reset.
The pads on either side of the trace can be soldered together to re-enable it. It's
labeled "RESET-EN". You may also be able to disable the auto-reset by
connecting a 110 ohm resistor from 5V to the reset line; see this forum thread for
details.
The Arduino Uno has a resettable poly fuse that protects your computer's
USB ports from shorts and over current. Although most computers provide their
own internal protection, the fuse provides an extra layer of protection. If more than
500 mA is applied to the USB port, the fuse will automatically break the
connection until the short or overload is removed.
23
4.1.3. Physical Characteristics:
The maximum length and width of the Uno PCB are 2.7 and 2.1 inches
respectively, with the USB connector and power jack extending beyond the former
dimension. Four screw holes allow the board to be attached to a surface or case.
Note that the distance between digital pins 7 and 8 is 160 mil (0.16"), not an even
multiple of the 100 mil spacing of the other pins.
So, you decided to go and buy yourself an Arduino, but once it arrived,
you realized you have no idea what to do with it. Do not panic, for help is at
hand! In this how-to, we will look at how to get started with Arduino
microcontroller boards. We’ll cover software installation, as well as connecting
and configuring the Arduino IDE.
Arduino Uno
USB B Cable
Arduino IDE
About 15 minutes
You can download the IDE from the official Arduino website. Since the
Arduino uses a USB to serial converter (which allow it to communicate with the
host computer), the Arduino board is compatible with most computers that have
a USB port. Of course, you will need the IDE first. Luckily, the Arduino
24
designers have released multiple versions of the IDE for different operating
systems, including Windows, Mac, and Linux. In this tutorial, we will use
Window 10, so ensure that you download the correct version of the IDE if you
do not have Windows 10.
Once downloaded, install the IDE and ensure that you enable most (if not
all) of the options, INCLUDING the drivers.
Next, you’ll need to connect the Arduino Uno board to the computer. This
is done via a USB B connection. Thanks to the wonderful world of USB, we do
not need to provide power to the Arduino, as the USB provides 5V up to 2A.
When the Arduino is connected, the operating system should recognize the
board as a generic COM port (for example, my Arduino Uno uses a CH340G,
which is an RS-232 serial to USB converter). Once it’s recognized, we will need
to find out what port number it has been assigned. The easiest way to do this is
to type “device manager” into Windows Search and select Device Manager
when it shows.
25
Finding the device manager option in Windows 10
In the Device Manager Window, look for a device under “Ports (COM &
LPT) and chances are the Arduino will be the only device on the list. In my
Device Manager, the Arduino shows up as COM7 (I know this because CH340
is in the device name).
26
In the window that appears, click “Search automatically”.
So, if you can’t find your Arduino on the port that you usually use, just go
to your Device Manager and check what port it’s actually on and, if necessary,
update your driver.
27
Step 3: Configure the IDE:
Now that we have determined the COM port that the Arduino is on, it’s
time to load the Arduino IDE and configure it to use the same device and port.
Start by loading the IDE. Once it’s loaded, navigate to Tools > Board > Arduino
Uno. However, if you are using a different board (i.e., not the Arduino Uno),
you must select the proper board!
28
Next, you must tell the IDE which COM port the Arduino is on. To do
this, navigate to Tools > Port > COM7. Obviously, if your Arduino is on a
different port, select that port instead.
For the sake of simplicity, we will load an example project that the
Arduino IDE comes with. This example will make the onboard LED blink for a
second continuously. To load this example, click File > Examples > 01.Basics >
Blink.
29
With the example loaded, it’s time to verify and upload the code. The
verify stage checks the code for errors, and then compiles the ready-for-
uploading code to the Arduino. The upload stage actually takes the binary data,
which was created from the code, and uploads it to the Arduino via the serial
port. To verify and compile the code, press the check mark button in the upper
left window.
30
If the compilation stage was successful, you should see the following
message in the output window at the bottom of the IDE. You might also see a
similar message—just it’s one that does not have words like “ERROR” and
“WARNING”.
With the code compiled, you must now upload it the Arduino Uno. To do
this, click the arrow next to the check mark.
The “Upload” button will program the Arduino with your code.
31
1.4. SOFTWARE IMPLEMENTATION:
32
Arduino programs are written in C or C++. The Arduino IDE comes with a
software library called "Wiring" from the original Wiring project, which makes
many common input/output operations much efficient. Users only need define two
functions to make a runnable cyclic executive program:
setup(): a function run once at the start of a program that can initialize settings
loop(): a function called repeatedly until the board powers off
33
4. Write the sketch in Arduino IDE
34
GETTING STARTED WITH NODEMCU USING ARDUINO IDE:
Introduction:
35
First Download Arduino IDE (version
1.6+) https://www.arduino.cc/en/Main/Software
http://arduino.esp8266.com/stable/package_esp8266com_index.json
36
Now close Preference window and go to Tools -> Board -> Boards
Manager
37
In Boards Manager window, Type esp in the search box, esp8266 will be
listed there below. Now select latest version of board and click on install.
38
Now Your Arduino IDE is ready for NodeMCU
Example:
Let’s see how to write simple serial print sketch using Arduino IDE for
NodeMCU.
39
NodeMCU connection with PC
After setting up Arduino IDE for NodeMCU, open Arduino IDE and write
simple sketch of serial print as shown in below figure.
40
Arduino Sketch:
void setup() {
void loop() {
delay(1000);
41
Ensure that you have selected the correct board as shown in below
figure. Also make sure that you have selected the appropriate COM
port.
Now compile & upload the written sketch directly to the NodeMCU Dev
Kit by clicking on upload button.
42
Now Click on Serial Monitor (upper right corner) option to check output
on serial monitor window of Arduino IDE.
Serial monitor output window will pop up with output as shown in below
figure.
43
CHAPTER 5
SOFTWARE DESCRIPTION
Embedded C Programming
Earlier, many embedded applications were developed using assembly level
programming. However, they did not provide portability. This disadvantage was
overcome by the advent of various high level languages like C, Pascal, and
44
COBOL. However, it was the C language that got extensive acceptance for
embedded systems, and it continues to do so. The C code written is more reliable,
scalable, and portable; and in fact, much easier to understand.
About C Language:
45
5.1.1. Differences between C and Embedded C:
The basic additional features of the embedded software
Data types:
The data type refers to an extensive system for declaring variables of
different types like integer, character, float, etc. The embedded C software uses
four data types that are used to store data in the memory.
The ‘char’ is used to store any single character; ‘int’ is used to store integer
value, and ‘float’ is used to store any precision floating point value.
The size and range of different data types on a 32-bit machine is given in the
following table. The size and range may vary on machines with different word
sizes.
46
Data types
Keywords:
There are certain words that are reserved for doing specific tasks. These
words are known as keywords. They are standard and predefined in the Embedded
C.
Keywords
sbit: This data type is used in case of accessing a single bit of SFR register.
Syntax: sbit variable name = SFR bit;
Ex: sbit a=P2^1;
47
Explanation: If we assign p2.1 as ‘a’ variable, then we can use ‘a’ instead of
p2.1 anywhere in the program, which reduces the complexity of the
program.
Bit: This data type is used for accessing the bit addressable memory of RAM (20h-
2fh).
Syntax: bit variable name;
Ex: bit c;
Explanation: It is a bit sequence setting in a small data area that is used by a
program to remember something.
SFR: This data type is used for accessing a SFR register by another name. All the
SFR registers must be declared with capital letters.
Syntax: SFR variable name = SFR address of SFR register;
Ex: SFR port0=0x80;
Explanation: If we assign 0x80 as ‘port0’, then we can use 0x80 instead of
port0 anywhere in the program, which reduces the complexity of the
program.
SFR Register: The SFR stands for ‘Special Function Register’. Microcontroller
8051 has 256 bytes of RAM memory. This RAM is divided into two parts: the first
part of 128 bytes is used for data storage, and the other of 128 bytes is used for
SFR registers. All peripheral devices like I/O ports, timers and counters are stored
in the SFR register, and each element has a unique address.
Comments
preprocessor directives
48
global variables
main() function
{
local variables
statements
…………..
…………..
}
fun(1)
{
local variables
statements
…………..
…………..
}
49
Global variable: A global variable is a variable that is declared before the main
function, and can be accessed on any function in the program.
Global variable
Local variable: A local variable is a variable declared within a function, and it is
valid only to be used within that function.
Local variable
Main () function: The execution of a program starts with the main function. Every
program uses only one main () function.
Advantages of embedded C program
50
understanding of the Embedded C programming is the most essential prerequisite
for designing embedded based projects.
51
5.3. ESP8266 FRAMEWORK:
ESP modules are available from a variety of sources, and the firmware
contained in the ESP8266 chips on the modules is almost always outdated and
often of questionable origin. The firmware "updates" and tools that are available
from these same sources are also sometimes suspect. Consequently, it is the aim of
this article to document a procedure for downloading the latest available firmware
directly from Espresso if and installing it on an ESP8266 using the flash tool
provided by Espresso. In order to update the firmware on any ESP8266, it is
necessary to have it properly powered and connected to a PC. In addition, a means
of resetting the IC and putting it in the download mode must be provided. The
schematic diagram and photograph below show the recommended setup; note that
the wire colors in the schematic correspond to the wire colors.
52
CHAPTER 6
Connect your Arduino to the computer with the USB cable. You do not
need the battery for now. The green PWR LED will light. If there was already a
program burned into the Arduino, it will run. Start the Arduino development
environment. In Arduino-speak, programs are called “sketches”, but here we
will just call them programs.
53
In the editing window that comes up, enter the following program, paying
attention to where semi-colons appear at the end of command lines.
void setup() {
Serial.begin(9600);
Serial.println("Hello World");
void loop() {
Click the Upload button or Ctrl-U to compile the program and load on
the Arduino board.
Click the Serial Monitor button . If all has gone well, the monitor
window will show your message and look something like this
54
1.4. TROUBLE SHOOTING:
If there is a syntax error in the program caused by a mistake in typing, an
error message will appear in the bottom of the program window. Generally,
staring at the error will reveal the problem. If you continue to have problems, try
this idea
55
1.5. FLASHING AN LED:
Light emitting diodes (LED's) are handy for checking out what the Arduino can
do.. For this task, you need an LED, a 330 ohm resistor, and some short pieces of
22 or 24 g wire. The figure to the right is a sketch of an LED and its symbol used
in electronic schematics Using 22 g solid wire, connect the 5V power pin on the
Arduino to the bottom red power bus on the breadboard and the Gnd pin on the
Arduino to the bottom blue power buss on the breadboard. Connect the notched or
flat side of the LED (the notch or flat is on the rim that surrounds the LED base;
look carefully because it can be hard to find) to the Gnd bus and the other side to a
free hole in main area of the breadboard Place the resistor so that one end is in the
same column as the LED and the other end is in a free column. From that column,
connect a wire to digital pin 2 on the Arduino board. Your setup will look
something like this
void setup() {
pinMode(2,OUTPUT);
digitalWrite(2,HIGH);
delay(1000);
digitalWrite(2,LOW);
void loop() {
1.6. DEBUGGING:
56
Embedded debugging may be performed at different levels, depending on
the facilities available. From simplest to most sophisticate they can be roughly
grouped into the following areas:
57
FPGA, and co-processor). An increasing number of embedded systems today use
more than one single processor core. A common problem with multi-core
development is the proper synchronization of software execution. In such a case,
the embedded system design may wish to check the data traffic on the busses
between the processor cores, which requires very low-level debugging, at
signal/bus level, with a logic analyzer, for instance.
CHAPTER 7
7.1. APPLICATIONS:
7.2. ADVANTAGES:
Low cost
Android app will also develop for easily use. In Android app there will be
direct buttons for ON or OFF the system or to receive the OTP. For more security
purpose camera module can also be implemented on the system. If any person
58
attempt to enter in home with more than three time wrong password then at that
time camera module will be activate. And camera module will capture the image of
person who trying to attack on system. It can use antivirus so that hacking of the
system can be difficult.
59
CONCLUSION
In this paper, a novel architecture for low cost and flexible home
Automation system using Arduino microcontroller is proposed and implemented.
Overall Arduino is easy to understand & its coding is easy. By implementing this
type of system we can ensure that the energy conservation can be done. By help of
this system we can increase the efficiency of the appliances .we can have the
complete control over the home appliances from a long distance. This will Increase
the comfortability of human being and it will reduce the Human efforts.
60
REFERENCES
61
APPIENDICES
SCHEMATIC DIAGRAM:
CODE:
#include <ESP8266WiFi.h>
#include <Adafruit_MQTT.h>
#include <Adafruit_MQTT_Client.h>
#define Relay1 D6
#define nw_led D4
62
/************************* Adafruit.io Setup
*********************************/
//WIFI CLIENT
WiFiClient client;
void MQTT_connect();
void setup() {
Serial.begin(115200);
63
pinMode(Relay1, OUTPUT);
pinMode(nw_led, OUTPUT);
Serial.println(); Serial.println();
Serial.print("Connecting to ");
Serial.println(WLAN_SSID);
WiFi.begin(WLAN_SSID, WLAN_PASS);
delay(500);
Serial.print(".");
Serial.println();
Serial.println("WiFi connected");
digitalWrite(nw_led, HIGH);
delay(500);
digitalWrite(nw_led, LOW);
delay(500);
digitalWrite(nw_led, HIGH);
delay(500);
digitalWrite(nw_led, LOW);
64
delay(500);
mqtt.subscribe(&Light1);
void loop() {
MQTT_connect();
Adafruit_MQTT_Subscribe *subscription;
if (subscription == &Light1) {
Serial.print(F("Got: "));
Serial.println((char *)Light1.lastread);
digitalWrite(Relay1, Light1_State);
void MQTT_connect() {
int8_t ret;
65
if (mqtt.connected()) {
return;
uint8_t retries = 3;
Serial.println(mqtt.connectErrorString(ret));
mqtt.disconnect();
delay(5000);
retries--;
if (retries == 0) {
while (1);
Serial.println("MQTT Connected!");
66