You are on page 1of 23

1.

Introduction:
The project aims at designing an advanced home automation system using normal
web server and Wi-Fi technology. The devices can be switched ON/OFF and sensors
can be read using a Personal Computer (PC) through Wi-Fi.
Automation is the most frequently spelled term in the field of electronics. The
hunger for automation brought many revolutions in the existing technologies. These
had greater importance than any other technologies due to its user-friendly nature.
These can be used as a replacement of the existing switches in home which produces
sparks and also results in fire accidents in few situations. Considering the advantages
of Wi-Fi an advanced automation system was developed to control the appliances in
the house.
Wi-Fi (Short for Wireless Fidelity) is a wireless technology that uses radio frequency
to transmit data through the air. Wi-Fi has initial speeds of 1mbps to 2mbps. Wi-Fi
transmits data in the frequency band of 2.4 GHz. It implements the concept of
frequency division multiplexing technology. Range of Wi-Fi technology is 40-300
feet.

Fig:-1.1:-Application visual studio

1
2. Project Overview
It is also cheap and be used for making cool projects connected to the Internet .Learn how to
make a simple IOT Project with it .The ESP8266 WiFi Module is a self contained SOC with
integrated TCP/IP protocol stack that can give any microcontroller access to your WiFi
network. The ESP8266 is capable of either hosting an application or offloading all Wi-Fi
networking functions from another application processor. Each ESP8266 module comes pre-
programmed with an AT command set firmware, meaning, you can simply hook this up to
your Arduino device and get about as much WiFi-ability as a WiFi Shield offers (and thats
just out of the box)! The ESP8266 module is an extremely cost effective board with a huge,
and ever growing, community.

The following picture gives an overview of how this system is going to work.

Fig:- 2.1 Project overview

2
3. System description
For controlling, a number of electrical equipment using a PC from a centralized location
involved development of hardware and software for controlling it. The block diagram of PC
controlled home appliances system as shown in fig.3.1.

Relay Bulb
Esp ckt

PC/LAPTO 8266
Relay Motor
P/phone wifi
ckt
module
Relay Socket
ckt

Power
supply

Fig.3.1. Block diagram of the system

The system consists of three sections are as follows


3.1. Power supply
3.2. Relay Circuit
3.3. Microcontroller

3.1Power Supply:-
There are many types of power supply. Most are designed to convert high voltage AC mains
electricity to a suitable DC voltage supply for electronic circuits and other devices. 5 Volt DC power
supply require for operation of microcontroller.

The Power supply consist of different type of component:-


Transformer

3
Diode
Voltage Regulator 7805 IC
Capacitor

Fig.3.2:- Power supply

3.1.1 Transformer:-

A transformer is an electrical device that transfers electrical energy between two or more
circuits through electromagnetic induction. Electromagnetic induction produces an
electromotive force within a conductor which is exposed to time varying magnetic fields.
Transformers are used to increase or decrease the alternating voltages in electric power
applications.

A varying current in the transformer's primary winding creates a varying magnetic flux in the
transformer core and a varying field impinging on the transformer's secondary winding. This
varying magnetic field at the secondary winding induces a varying electromotive force
(EMF) or voltage in the secondary winding due to electromagnetic induction.

4
Fig.3.3:- Transformer

3.1.2 Diode:-

In electronics, a diode is a two terminal electronic component that conducts primarily in one
direction (asymmetric conductance) it has low (ideally zero) resistance to the flow of current
in one direction, and high (ideally infinite) resistance in the other.

A semiconductor diode, the most common type today, is a crystalline piece of semiconductor
material with a pn junction connected to two electrical terminals. A vacuum tube diode has
two electrodes, a plate(anode) and a heated cathode. Semiconductor diodes were the first
semiconductor electronic devices.

The discovery of crystals' rectifying abilities was made by German physicist Ferdinand Braun
in 1874. The first semiconductor diodes, called cat's whisker diodes, developed around 1906,
were made of mineral crystals such as galena. Today, most diodes are made of silicon, but
other semiconductors such as selenium or germanium are sometimes used.

Fig.3.4:-Diode

3.1.3Voltage Regulator 7805 IC:-

The 78xx(sometimesL78xx, LM78xx,MC78xx) is a family of self contained fixed linear


voltage Regulator integrated circuits. The 78xx family is commonly used in electronic
circuits requiring a regulated power supply due to their ease of use and low cost. For Ics
within the family, the xx is replaced with two digits, indicating the output voltage (for
example, the 7805 has a 5volt output, while the 7812 produces 12 volts).

5
Fig.3.5:-Voltage regulator ICs

The 78xx line are positive voltage regulators: they produce a voltage that is positive relative
to a common ground. There is a related line of79xx devices which are complementary
negative voltage regulators. 78xx and 79xx ICs can be used in combination to provide
positive and negative supply voltages in the same circuit. 78xx ICs have three terminals and
are commonly found in the TO220 form factor, although they are available in
surfacemount,TO92, and TO3 packages.

These devices support an input voltage anywhere from around 2.5 volts over the intended
output voltage up to a maximum of 35 to 40 volts depending on the model, and typically
provide 1 or 1.5amperes of current (though smaller or larger packages may have a lower or
higher current rating).

Individual devices in the series


There are common configurations for 78xx ICs, including 7805 (5 V), 7806 (6 V), 7808 (8 V), 7809 (9 V),
7810 (10 V), 7812 (12 V), 7815 (15 V), 7818 (18 V), and 7824 (24 V) versions. The 7805 is the most
common, as its regulated 5volt supply provides a convenient power source for most TTL components. Part
number Output voltage (V) Minimal input voltage (V).

Part Number Output Voltage Minimum Input Voltage


7805 +5 7.3
7806 +6 8.3
7808 +8 10.5
7810 +10 12.5
7812 +12 14.6
7815 +15 17.7
7818 +18 21.0
7824 +24 27.1
Table no 2 Individual ICs

6
3.1.4 Capacitor:-

A capacitor (originally known as a condenser) is a passive two terminal electrical component


used to temporarily store electrical energy in an electric field. The forms of practical
capacitors vary widely, but most contain at least two electrical conductors (plates) separated
by a dielectric (i.e. an insulator that can store energy by becoming polarized).

The conductors can be thin films, foils or sintered beads of metal or conductive electrolyte,
etc. The non conducting dielectric acts to increase the capacitor's charge capacity. Materials
commonly used as dielectrics include glass, ceramic, plastic film, paper, mica, and oxide
layers. Capacitors are widely used as parts of electrical circuits in many common electrical
devices.

Fig.3.6:- Capacitor

Unlike a resistor, an ideal capacitor does not dissipate energy. Instead, a capacitor stores
energy in the form of an electrostatic field between its plates. When there is a potential
difference across the conductors (e.g., when a capacitor is attached across a battery), an
electric field develops across the dielectric, causing positive charge +Q to collect on one plate
and negative charge Q to collect on the other plate.

If a battery has been attached to a capacitor for a sufficient amount of time, no current can
flow through the capacitor. However, if a time varying voltage is applied across the leads of
the capacitor, a displacement current can flow.

An ideal capacitor is characterized by a single constant value, its capacitance. Capacitance is


defined as the ratio of the electric charge Q on each conductor to the potential difference V
between them.

The SI unit of capacitance is the farad (F), which is equal to one coulomb per volt (1 C/V).
Typical capacitance values range from about 1 pF (1012 F) to about 1 mF (103 F). The
larger the surface area of the "plates" (conductors) and the narrower the gap between them,
the greater the capacitance is. In practice, the dielectric between the plates passes a small
amount of leakage current and also has an electric field strength limit, known as the
breakdown voltage.

The conductors and leads introduce an undesired inductance and resistance. Capacitors are
widely used in electronic circuits for blocking direct current while allowing alternating
current to pass. In analog filter networks, they smooth the output of power supplies. In

7
resonant circuits they tune radios to particular frequencies. In electric power transmission
systems, they stabilize voltage and power flow.

3.2 Relay Circuit

3.2.1 What is a relay?


We know that most of the high end industrial application devices have relays for their
effective working. Relays are simple switches which are operated both electrically and
mechanically. Relays consist of a n electromagnet and also a set of contacts. The switching
mechanism is carried out with the help of the electromagnet. There are also other operating
principles for its working. But they differ according to their applications. Most of the devices
have the application of relays.

3.2.2 Why is a relay used?


The main operation of a relay comes in places where only a low-power signal can be used to
control a circuit. It is also used in places where only one signal can be used to control a lot of
circuits. The application of relays started during the invention of telephones. They played an
important role in switching calls in telephone exchanges. They were also used in long
distance telegraphy. They were used to switch the signal coming from one source to another
destination. After the invention of computers they were also used to perform Boolean and
other logical operations. The high end applications of relays require high power to be driven
by electric motors and so on. Such relays are called contactors.

3.2.3 How relay works?


The working of a relay can be better understood by explaining the following diagram given
below.

Fig.3.7:- Relay circuit

8
Fig.3.8:- Relay circuit pcb layout

4. ARDUINO UNO Board (Microcontrollar)


Arduino / Genuino Uno is a microcontroller board based on the ATmega328P (datasheet). It
has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a
16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. It
contains everything needed to support the microcontroller simply connect it to a computer
with a USB cable or power it with a AC-to-DC adapter or battery to get started.

"Uno" means one in Italian and was chosen to mark the release of Arduino Software (IDE)
1.0. The Uno board and version 1.0 of Arduino Software (IDE) were the reference versions of
Arduino, now evolved to newer releases.

Fig.4.1:-Arduino

9
Fig.4.2:-Ardunio back

Fig.4.3:- Arduino cable

10
4.1 Pins Description
Input and Output

Each of the 14 digital pins on the Arduino Uno can be used as an input or output, using pinMode(),
digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a
maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms.
In addition, some pins have specialized functions:

Serial: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins
are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

External Interrupts: pins 2 and 3. These pins can be configured to trigger an interrupt on a low
value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the
SPI library.

LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED
is on, when the pin is LOW, its off.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e.
1024 different values). By default they measure from ground to 5 volts, though is it possible to change
the upper end of their range using the AREF pin and the analogReference() function. Additionally,
some pins have specialized functionality:

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.There
are a couple of other pins on the board:

11
AREF. Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields
which block the one on the board.

4.2 AVR 328P MICROCONTROLLER:

The Atmega328 is a very popular microcontroller chip produced by Atmel. It is an 8-bit


microcontroller that has 32K of flash memory, 1K of EEPROM, and 2K of internal SRAM.

The Atmega328 is one of the microcontroller chips that are used with the popular Arduino
Duemilanove boards. The Arduino Duemilanove board comes with either 1 of 2 microcontroller
chips, the Atmega168 or the Atmega328. Of these 2, the Atmega328 is the upgraded, more advanced
chip. Unlike the Atmega168 which has 16K of flash program memory and 512 bytes of internal
SRAM, the Atmega328 has 32K of flash program memory and 2K of Internal SRAM.The Atmega328
has 28 pins.

It has 14 digital I/O pins, of which 6 can be used as PWM outputs and 6 analog input pins. These I/O
pins account for 20 of the pins.

Fig.4.4:- Pin out of AVR 328P

Pin Description Function

12
1 PC6 Reset

2 PD0 Digital Pin (RX)

3 PD1 Digital Pin (TX)

4 PD2 Digital Pin

5 PD3 Digital Pin (PWM)

6 PD4 Digital Pin

7 Vcc Positive Voltage (Power)

8 GND Ground

9 XTAL 1 Crystal Oscillator

10 XTAL 2 Crystal Oscillator

11 PD5 Digital Pin (PWM)

12 PD6 Digital Pin (PWM)

13 PD7 Digital Pin

14 PB0 Digital Pin

15 PB1 Digital Pin (PWM)

16 PB2 Digital Pin (PWM)

17 PB3 Digital Pin (PWM)

18 PB4 Digital Pin

19 PB5 Digital Pin

20 AVCC Positive voltage for ADC (power)

21 AREF Reference Voltage

22 GND Ground

23 PC0 Analog Input

13
24 PC1 Analog Input

25 PC2 Analog Input

26 PC3 Analog Input

27 PC4 Analog Input

28 PC5 Analog Input

Table no.-1 pin description of AVR 328P

The Atmega328 chip has an analog-to-digital converter (ADC) inside of it. This must be or else the
Atmega328 wouldn't be capable of interpreting analog signals. Because there is an ADC, the chip can
interpret analog input, which is why the chip has 6 pins for analog input .

Fig.4.5:- Pin out of Arduino

The ADC has 3 pins set aside for it to function- AVCC, AREF, and GND. AVCC is the power supply,
positive voltage, that for the ADC. The ADC needs its own power supply in order to work. GND is
the power supply ground. AREF is the reference voltage that the ADC uses to convert an analog
signal to its corresponding digital value.

Analog voltages higher than the reference voltage will be assigned to a digital value of 1, while
analog voltages below the reference voltage will be assigned the digital value of 0.

14
5. Esp 8266 wifi module:

Fig
.5.1 wifi module esp 8266

15
5.1 Description:
The ESP8266 WiFi Module is a self contained SOC with integrated TCP/IP protocol stack
that can give any microcontroller access to your WiFi network. The ESP8266 is capable of
either hosting an application or offloading all Wi-Fi networking functions from another
application processor. Each ESP8266 module comes pre-programmed with an AT command
set firmware, meaning, you can simply hook this up to your Arduino device and get about as
much WiFi-ability as a WiFi Shield offers (and thats just out of the box)! The ESP8266
module is an extremely cost effective board with a huge, and ever growing, community.

This module has a powerful enough on-board processing and storage capability that allows it
to be integrated with the sensors and other application specific devices through its GPIOs
with minimal development up-front and minimal loading during runtime. Its high degree of
on-chip integration allows for minimal external circuitry, including the front-end module, is
designed to occupy minimal PCB area. The ESP8266 supports APSD for VoIP applications
and Bluetooth co-existance interfaces, it contains a self-calibrated RF allowing it to work
under all operating conditions, and requires no external RF parts. There is an almost limitless
fountain of information available for the ESP8266, all of which has been provided by
amazing community support. In the Documents section below you will find many resources
to aid you in using the ESP8266, even instructions on how to transforming this module into
an IoT (Internet of Things) solution!

5.2 Features:
802.11 b/g/n
Wi-Fi Direct (P2P), soft-AP
Integrated TCP/IP protocol stack
Integrated TR switch, balun, LNA, power amplifier and matching network
Integrated PLLs, regulators, DCXO and power management units
+19.5dBm output power in 802.11b mode
Power down leakage current of <10uA
1MB Flash Memory
Integrated low power 32-bit CPU could be used as application processor
SDIO 1.1 / 2.0, SPI, UART
STBC, 11 MIMO, 21 MIMO
A-MPDU & A-MSDU aggregation & 0.4ms guard interval
Wake up and transmit packets in < 2ms
Standby power consumption of < 1.0mW (DTIM3)

16
5.3 Specification of ESP 8266:
Wi-Fi Direct (P2P), soft-AP
Integrated TCP/IP protocol stack
Integrated TR switch, balun, LNA, power amplifier and matching network
Integrated PLLs, regulators, DCXO and power management units
19.5dBm output power in 802.11b mode
Power down leakage current of <10uA
1MB Flash Memory
Integrated low power 32-bit CPU could be used as application.

17
5.4 Pin diagram of esp 8266 :

18
Fig. 5.2 pin diagram of esp 8266 wifi module

5.5 Connecting NodeMCU board to Computer :

Firstly, you connect NodeMCU board to PC via microUSB cable. After connected, you may
get lighting on blue LED.
If you are working on Windows platform, open Device Manager, you should see NodeMCU
board detected on Ports (COM & LPT).

Fig.5.3 Connecting NodeMCU board to Computer

5.6 Connecting to the ESP8266 :


The ESP8266 is a WiFi device and hence we will eventually connect to it using WiFi
protocols but some bootstrapping is required first. The device doesn't know what network to
connect to, which password to use and other necessary parameters. This of course assumes
we are connecting as a station, if we wish the device to be an access point or we wish to load
our own applications into it, the story gets deeper. This implies that there is a some way to
interact with the device other than WiFi and there is the answer is UART (Serial). The
ESP8266 has a dedicated UART interface with pins labeled TX and RX. The TX pin is the
ESP8266 transmission (outbound from ESP8266) and the RX pin is used to receive data
(inbound into the ESP8266). These pins can be connected to a UART partner. By far the
easiest and most convenient partner for us is a USB UART converter. These are discussed
in detail later in the book. For now let us assume that we have set those up. Through the

19
UART, we can attach a terminal emulator to send keystrokes and have data received from the
ESP8266 displayed as characters on the screen. This is used extensively when working with
the AT commands. A second purpose of the UART is to receive binary data used to "flash" the
flash memory of the device to record new applications for execution. There are a variety of
technical tools at our disposal to achieve that task.

When we use a UART, we need to consider the concept of a baud rate. This is the speed of
communication of data between the ESP8266 and its partner. During boot, the ESP8266
attempts to automatically determine the baud rate of the partner and match it. It assumes a
default of 74880 and if you have a serial terminal attached, you will see a message.

if it is configured to receive at 74880.The ESP8266 has a second UART associated with it


that is output only. One of the primary purposes of this second UART is to output diagnostics
and debugging information. This can be extremely useful during development and as such I
recommend attaching two USB UART converters to the device. The second UART is
multiplexed with pin GPIO2.

Fig.5.4 Connecting to the ESP8266

6. WiFi Theory :
When working with a WiFi oriented device, it is important that we have at least some
understanding of the concepts related to WiFi. At a high level, WiFi is the ability to
participate in TCP/IP connections over a wireless communication link. WiFi is specifically
the set of protocols described in the IEEE 802.11 Wireless LAN architecture.Within this
story, a device called a Wireless Access Point (access point or AP) acts as the hub of all
communications. Typically it is connected to (or acts as) as TCP/IP router to the rest of the

20
TCP/IP network. For example, in your home, you are likely to have a WiFi access point
connected to your modem (cable or DSL). WiFi connections are then formed to the access
point (through devices called stations) and TCP/IP traffic flows through the access point to
the Internet.

Fig. 6.1 wifi modem

An ESP8266 device can play the role of an Access Point, a Station or both at the same
time.Very commonly, the access point also has a network connection to the Internet and acts
as a bridge between the wireless network and the broader TCP/IP network that is the
Internet.A collection of stations that wish to communicate with each other is termed a Basic
Service Set (BSS). The common configuration is what is known as an Infrastructure BSS. In
this mode, all communications inbound and outbound from an individual station are routed
through the access point.A station must associate itself with an access point in order to
participate in the story. A station may only be associated with a single access point at any one
time.Each participant in the network has a unique identifier called the MAC address. This is a
48bit value.
When we have multiple access points within wireless range, the station needs to know with
which one to connect. Each access point has a network identifier called the BSSID (or more

21
commonly just SSID). SSID is service set id entifier. It is a 32 character value that represents
the target of packets of information sent over the network.

6.1 AT Command Programming :


The quickest and easiest way to get started with an ESP8266 is to access it via the AT
command interface. When we think about an ESP8266 device we find that it has a built in
UART (Serial) connection. This means that it can both send and receive data using the
UART protocol. We also know that the device can communicate with WiFi. What if we had
an application that ran on the ESP8266 that took "instructions" received over the serial link,
executed them and then returned a response? This would then allow us to use the ESP8266
without ever having to know the programming languages that are native to the device. This
is exactly what a program that has so far been found to be pre-installed on the ESP8266
does for us. The program is called the "AT command processor" named after the format of
the commands sent through the serial link. These commands are all prefixed with "AT" and
follow (roughly) the style known as the "Hayes command set".

22
Fig.6.2 AT Command Programming

If we think of an application wishing to use the services of the ESP8266 as a client and the
ESP8266 as a server capable of servicing those commands as a server, then the client
sends strings of characters through the UART connection to the server and server responds
with the outcome.

23

You might also like