D 418
D 418
D 418
INTRODUCTION
1. INTRODUCTION:
Today we are living in 21st century where automation is playing an important role in
human life. Home automation allows us to control household appliances like light,
door, fan, AC etc. It also provides home security and emergency system to be
activated. Home automation not only refers to reducing human efforts but also
energy efficiency and timesaving. The main objective of home automation and
security system is to control home appliances by using different techniques like
android application, web pages, GSM when a person is away from home. The
system alerts the person in case a burglar enters the house by sending SMS on
person’s mobile phone which will enable them to protect their home from burglars.
The system also helps old people by controlling home appliances with the help of
their mobile phones as they do not need to go to different locations for turning the
appliance ON orOFF.
Main purpose of home automation is “SAVE ELECTRICITY”. With this
technology everyone can control the home equipment or office equipment
automatically. The system is secured, user- friendly, reliable, flexible and affordable
1
implies that whenever a person tries to enter into the house then a SMS will be sent
to house owner’s mobile phone indicating the presence of some person inside the
house and the house owner can take some preventive measure in order to protect
this house from the burglar. More over the person can control the home appliances
using an android application present in the mobile phone which will reduce the
human hard work. The list of various home appliances along with TURN ON and
TURNOFF buttons will be provided in an android application. By clicking on that
particular button the person will be able to TURN ON and TURN OFF the home
appliances using an androidapplication.
1.1 Block diagram:
2
1.2 Circuit diagram:
3
1.3 Flow chart:
4
CHAPTER 2
HISTORY OF EMBEDDED SYSTEMS
2.1. Embedded systems:
In the earliest years of computers in the 1930-40’s, computers were sometimes
dedicated to a single task, but were far too large and expensive for most kinds of tasks
performed by embedded computers of today. Over time however, the concept of
programmable controllers evolved from traditional electromechanical sequencers, via
solid state devices, to the use of computer technology. One of the first recognizably
modern embedded systems was the Apollo Guidance Computer, developed by
Charles Stark Draper at the MIT Instrumentation Laboratory. At the project’s
inception, the Apollo guidance computer was considered the riskiest item in the
Apollo project the newly developed monolithic integrated circuits to reduce the size
and weight. An early mass-produced embedded system was the Autonetics D-17
guidance computer for the Minutemaid missile, released in 1961. It was built from
transistor logic and had a hard disk for main memory. When the Minutemaid II went
into production in 1966, the D-17 was replaced with a new computer that was the first
high-volume use of integrated circuits. This program alone reduced prices on quad
Nand gate ICs from $1000/each to $3/each, permitting their use in commercial
products.
Since these early applications in the 1960s, embedded systems have come
down in price and there has been a dramatic rise in processing power and
functionality. The first microprocessor for example, the Intel 4004, was designed for
calculators and other small systems but still required many external memory and
support chips. In 1978 National Engineering Manufacturers Association released a
“standard” for program able microcontrollers, including almost any computer-based
controllers, such as single board computers, numerical, and event-based controllers.
By the mid-1980s, most of the common previously external system components had
been integrated into the same chip as the processor and this modem form of the
microcontroller allowed an even more widespread use, which by the end of the decade
were the norm rather than the exception for almost all electronic devices.
The integration of microcontrollers has further increased the applications for
5
which embedded systems are used into areas where traditionally a computer would
not have been considered. A general purpose and comparatively low-cost
microcontroller may often be programmed to fulfill the same role as a large number of
separate components. Although in this context an embedded system is usually more
complex than a traditional solution, most of the complexity is contained within the
microcontroller itself. Very few additional components may be needed and most of
the design effort is in the software. The intangible nature of the software makes it
much easier to prototype and test new visions compared with the design and
construction of a new circuit not using an embedded processor.
In this world of knowledge everything around us is run by Computing
Systems. The technical Brilliance and Developments in different fields has led to a
drastic change in our lives especially in the communications field. Due to various
changes in technologies many systems have come up with breathtaking developments.
One amongst them is the EMBEDDED SYSTEMS. It is the evolution or further
development of computing system. Its applications provide tremendous opportunities
for creative use of computer technology. Almost every new system introduced in the
market is an example of Embedded System.
An embedded system is basically a close interaction of hardware and software.
The design part involves different instruction sets in terms of functionality,
compactness of code, power consumption, performance, and reliability so on. The
Embedded software interacts with the hardware circuitry to generate the desired
functionality. An embedded system typically comprises the hardware, embedded
RTOS, device drivers, communication stacks and embedded application software.
Apart from the common computer applications there are many applications, which do
not need high performances.
2.2 Main components of embedded system:
1. Embeds hardware to give computer like functionalities
2. Embeds main application software generally into flash or ROM and the application
software performs concurrently the number of tasks.
3. Embeds a real time operating system (RTOS), which supervises the application
software asks running on the hardware and organizes the accesses to system resources
according to priorities and timing constraints of tasks in the system.
6
Fig. 2.1: Typical Embedded System Hardware Unit.
2.3. Processor in embedded system
Program Flow and data path Control Unit (CU) —includes a fetch unit for fetching
Execution Unit (EU) —includes circuits for arithmetic and logical unit
(ALU), and for instructions for a program control task, say, data transfer instructions,
halt, Interrupt or jump to another set of instructions call to another routine or sleep or
reset
`
Fig 2.2: Processor in Embedded Systems
1a. General purpose microprocessor
For example, Intel 80x86, Sparc, or Motorola 68HCxxx
1b. Embedded general purpose processor
Fast context switching features, use of on-chip Compilers, for example, Intel® X
Scale™
7
Applications: Personal Internet Client Architecture-based PDAs, cell phones and
other wireless devices.
8
Examples
• Multiprocessor system for Real time performance in a video-conference system,
• Embedded firewall cum router, High-end cell phone.
2.4. Classification of embedded systems:
1. Small scale embedded system:
• Single 8 bit or 16bit Microcontroller.
• Little hardware and software complexity.
• They May even be battery operated.
• Usually “C” is used for developing these system.
• The need to limit power dissipation when system is running continuously.
Programming tools: Editor, Assembler and Cross Assembler15.
2. Medium scale embedded system
• Single or few 16 or 32 bit microcontrollers or Digital Signal Processors (DSP) or
Reduced Instructions Set Computers (RISC).
• Both hardware and software complexity.
Programming tools: RTOS, Source code Engineering Tool, Simulator, Debugger and
Integrated Development Environment (IDE).16
3. Sophisticated embedded system
• Enormous hardware and software complexity.
• Which may need scalable processor or configurable processor and programming
logic arrays.
• Constrained by the processing speed available in their hardware units.
Programming Tools: For these systems may not be readily available at a reasonable
cost or may not be available at all. A compiler or re-targetable compiler might have to
be developed for this.
9
CHAPTER 3
MICRO CONTROLLER
3.1 ArduinoMega2560:
10
External (non-USB) power can come either from an AC-to-DC adapter (wall-
wart) or battery. The adapter can be connected by plugging a 2.1mm center-
positive plug into the board's power jack. Leads from a battery can be inserted in
the Gnd and Vin pin headers of the POWER connector.
The board can operate on an external supply of 6 to 20 volts. If supplied with less
than 7V, however, the 5V pin may supply less than five volts and the board may
be unstable. If using more than 12V, the voltage regulator may overheat and
damage the board. The recommended range is 7 to 12 volts.
The Mega2560 differs from all preceding boards in that it does not use the FTDI
USB-to-serial driver chip. Instead, it features the Atmega8U2 programmed as a
USB-to-serial converter.
The power pins are as follows:
VIN. The input voltage to the Arduino board when it's using an external power
source (as opposed to 5 volts from the USB connection or other regulated
power source). You can supply voltage through this pin, or, if supplying
voltage via the power jack, access it through this pin.
5V. The regulated power supply used to power the microcontroller and other
components on the board. This can come either from VIN via an on-board
regulator, or be supplied by USB or another regulated 5V supply.
3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current
draw is 50 mA.
GND. Ground pins.
3.3 Memory:
The ATmega2560 has 256 KB of flash memory for storing code (of which 8
KB is used for the bootloader), 8 KB of SRAM and 4 KB of EEPROM (which can be
read and written with the EEPROM library).
3.4 Input and Output:
Each of the 54 digital pins on the Mega 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
11
resistor (disconnected by default) of 20-50 kOhms. In addition,
some pins have specialized functions:
Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX)
and 16 (TX); Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and
transmit (TX) TTL serial data. Pins 0 and 1 are also connected to the
corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.
Used with analog Reference ().
PWM: 0 to 13. Provide 8-bit PWM output with the analogWrite() function.
SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI
communication using the SPI library. The SPI pins are also broken out on the
ICSP header, which is physically compatible with the Uno, Duemilanove and
Diecimila.
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, it's off.
I2C: 20 (SDA) and 21 (SCL). Support I2C (TWI) communication using the
Wire library (documentation on the Wiring website). Note that these pins are
not in the same location as the I2C pins on the Duemilanove or Diecimila.
The Mega2560 has 16 analog inputs, 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 analog
Reference() function.
There are a couple of other pins on the board
AREF: Reference voltage for the analog inputs
3.5 Communication:
The Arduino Mega2560 has a number of facilities for communicating with a
computer, another Arduino, or other microcontrollers. The ATmega2560 provides
four hardware UARTs for TTL (5V) serial communication. An ATmega8U2 on the
board channels one of these over USB and provides a virtual com port to software on
the computer (Windows machines will need a .inf file, but OSX and Linux machines
will recognize the
A Software Serial library allows for serial communication on any of the
12
Mega2560's digital pins. The ATmega2560 also supports I2C (TWI) and SPI
communication. The Arduino software includes a Wire library to simplify use of the
I2C bus; see the documentation on the Wiring website for details. For SPI
communication, use the SPI library.
3.6 Programming:
The Arduino Mega can be programmed with the Arduino software (download).
For details, see the reference and tutorials.
The ATmega2560 on the Arduino Mega comes preburned with a bootloader 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 bootloader and program the microcontroller through the
ICSP (In-Circuit Serial Programming) header; see these instructions for board as a
COM port automatically. The Arduino software includes a serial monitor which
allows simple textual data to be sent to and from the board. The RX and TX LEDs
on the board will flash when data is being transmitted via the ATmega8U2 chip
and USB connection to the computer (but not for serial communication on pins 0
and 1).details.
The ATmega8U2 firmware source code is available in the Arduino repository.
The ATmega8U2 is loaded with a DFU bootloader, which can be activated by
connecting the solder jumper on the back of the board (near the map of Italy) and
then resetting the 8U2. 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 bootloader).
See this user-contributed tutorial for more information.
13
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 setup has other implications. When the Mega2560 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 bootloader is
running on the Mega2560. 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 Mega2560 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.
3.8USB Overcurrent Protection:
The Arduino Mega2560 has a resettable polyfuse that protects your computer's
USB ports from shorts and overcurrent. 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.
3.9 Physical Characteristics and Shield Compatibility:
The maximum length and width of the Mega2560 PCB are 4 and 2.1 inches
respectively, with the USB connector and power jack extending beyond the former
dimension. Three 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.
The Mega2560 is designed to be compatible with most shields designed for
the Uno, Diecimila or Duemilanove. Digital pins 0 to 13 (and the adjacent AREF and
GND pins), analog inputs 0 to 5, the power header, and ICSP header are all in
14
equivalent locations. Further the main UART (serial port) is located on the same pins
(0 and 1), as are external interrupts 0 and 1 (pins 2 and 3 respectively). SPI is
available through the ICSP header on both the Mega2560 and Duemilanove /
Diecimila.
15
CHAPTER 4
HARDWARE COMPONENTS
16
4.1.2 Definition:
GSM (Global System for Mobile communications) is an open, digital cellular
technology used for transmitting mobile voice and data services. GSM differs from
first generation wireless systems in that it uses digital technology and time division
multiple access transmission methods. GSM is a circuit-switched system that divides
each 200kHz channel into eight 25kHz time-slots. GSM operates in the 900MHz and
1.8GHz bands in Europe and the 1.9GHz and 850MHz bands in the US. The 850MHz
band is also used for
GSM and 3GSM in Australia, Canada and many South American countries. GSM
supports data transfer speeds 9.6 kbit/s, allowing the transmission of basic data
services such as SMS (Short Message Service). GSM satellite roaming has also
extended service access to areas where terrestrial coverage is not available. The
transmission power in the handset is limited to a maximum of 2 watts in GSM850/900
and 1 watt in GSM1800/1900.
GSM has used a variety of voice codec’s to squeeze 3.1 kHz audio into
between 5.6 and 13 Kbit/s. Originally, two codes named after the types of data
channel they were allocated, were used, called Half Rate (5.6 Kbit/s) and Full Rate
(13 Kbit/s). These used a system based upon linear predictive coding (LPC). In
addition to being efficient with bitrates, these codes also made it easier to identify
more important parts of the audio, allowing the air interface layer to prioritize and
better protect these parts of the signal.
GSM was further enhanced in 1997 with the Enhanced Full Rate (EFR) codec,
17
a 12.2 Kbit/s codec that uses a full rate channel. Finally, with the development of
UMTS, EFR was made refectory into a variable-rate codec called AMR-Narrowband,
which is high quality and robust against interference when used on full rate channels,
and less robust but still relatively high quality when used in good radio conditions on
half-rate channels.
There are four different cell sizes in a GSM network—macro, micro, pico and
umbrella cells. The coverage area of each cell varies according to the implementation
environment. Macro cells can be regarded as cells where the base station antenna is
installed on a mast or a building above average roof top level. Micro cells are cells
whose antenna height is under average roof top level; they are typically used in urban
areas. Pico cells are small cells whose coverage diameter is a few dozen meters; they
are mainly used indoors. Umbrella cells are used to cover shadowed regions of
smaller cells and fill in gaps in coverage between those cells.
Cell horizontal radius varies depending on antenna height, antenna gain and
propagation conditions from a couple of hundred meters to several tens of kilometers.
The longest distance the GSM specification supports in practical use is 35 kilo
meters (22 mi). There are also several implementations of the concept of an extended
cell, where the cell radius could be double or even more, depending on the antenna
system, the type of terrain and the timing advance.
Indoor coverage is also supported by GSM and may be achieved by using an
indoor picocell base station, or an indoor repeater with distributed indoor antennas fed
through power splitters, to deliver the radio signals from an antenna outdoors to the
separate indoor distributed antenna system. These are typically deployed when a lot of
call capacity is needed indoors, for example in shopping centers or airports. However,
this is not a prerequisite, since indoor coverage is also provided by in-building
penetration of the radio signals from nearby cells.
The modulation used in GSM is Gaussian minimum-shift keying (GMSK), a
kind of continuous-phase frequency shift keying. In GMSK, the signal to be
modulated onto the carrier is first smoothed with a Gaussian low-pass filter prior to
being fed to a frequency modulator, which greatly reduces the interference to
neighboring channels (adjacent channel interference).
18
4.1.3 Architecture:
A GSM network is composed of several functional entities, whose functions
and interfaces are defined. Figure 1 shows the layout of a generic GSM network.
19
• Contains the International Mobile Subscriber Identity (IMSI).
• Allows users to send and receive calls and receive other subscriber services.
• Encoded network identification details- key kick and A3, A5 and A8
algorithms.
• Protected by a password or pin.
• Can be moved from phone to phone-contains key information to activate the
phone.
• By inserting the SIM card into another GSM cellular phone, the user will be
able to receive calls at that phone, make calls from that phone.
20
• Central component of the Network Subsystem.
• Manages communication between GSM and other networks.
• Acts like a normal switching node of the PSTN or ISDN.
• Provides functionality such as registration, authentication, and handovers.
• Call routing to a roaming subscriber.
21
• Encryption of speech and data transmission over the radio path.
• Low speed data services (up to 9.6 Kb/s).
• Support of short message service (SMS).
22
• Fleet management.
• Automatic meter reading.
• Toll collection.
10 Modulation 0.3GMSK
13 Interleaving 40ms
4.2 NodeMCUmodule:
NodeMCU is an open source IoT platform. It includes firmware which runs on the
ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the
ESP-12 module The term "NodeMCU" by default refers to the firmware rather than
the dev kits. The firmware uses the Lua scripting language. It is based on the eLua
project, and built on the Espressif Non-OS SDK for ESP8266. It uses many open
source projects, such as lua-cjson, and spiffs.
23
Fig 4.3 :NodeMcu Module
4.2.1 HISTORY:
NodeMCU was created shortly after the ESP8266 came out. On December 30,
2013, Espress 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 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.
4.2.2 ESP8266 Arduino Core :
As Arduino.cc began developing new MCU boards based on non-AVR
processors like the ARM/SAM MCU and used in the Arduino Due, they needed to
modify the Arduino IDE so that it would be relatively easy to change the IDE to
support alternate tool chains to allow Arduino C/C++ to be compiled down to these
24
new processors. They did this with the introduction of the Board Manager and the
SAM Core. A "core" is the collection of software components required by the Board
Manager and the Arduino IDE to compile an Arduino C/C++ source file down to the
target MCU's machine language. Some creative ESP8266 enthusiasts have developed
an Arduino core for the ESP8266 WiFiSoC that is available at the GitHub ESP8266
Core webpage. This is what is popularly called the "ESP8266 Core for the Arduino
IDE" and it has become one of the leading software development platforms for the
various ESP8266 based modules and development boards, including NodeMCUs.
4.2.3NodeUSB :
NodeUSB is an open IoT platform about the size of a standard USB stick. It
was designed to leverage NodeMCU (Lua) for easy programming and has the extra
feature of USB capability. It is ideal for Plug-n-Play solutions, allowing easy
prototyping for developers.
4.3 MOTION SENSOR:
PIR sensors allow you to sense motion, almost always used to detect whether a
human has moved in or out of the sensors range. They are small, inexpensive, low-
power, easy to use and don't wear out. For that reason they are commonly found in
appliances and gadgets used in homes or businesses. They are often referred to as
PIR, "Passive Infrared", "Pyroelectric", or "IR motion" sensors
25
(change) not average IR levels. The two halves are wired up so that they cancel each
other out. If one half sees more or less IR radiation than the other, the output will
swing high or low.
26
humidity. Higher relative humidity decreases the resistance between the electrodes,
while lower relative humidity increases the resistance between the electrodes.
27
Fig 4.7:Temperature and Humidity Sensor layout
Table 4.2: Pin Description
Pin Description
S GPIO
V Supply Voltage 5V
G Ground
28
• 8 bit parity bit
• If a transmission is successful the “8bit humidity integer data + 8bit humidity
decimal data +8 bit temperature integer data + 8bit temperature fractional data”
8bit checksum is equal to the results of the last eight.
• After the user host (MCU) sends a signal DHT11 is converted from low-power
mode to high-speed mode, until the host begins to signal the end. Then DHT11
sends a response signal to send 40bit data, and trigger a letter collection. If
DHT11 doesn't receive a signal from the host it will not begin a letter collection.
After the letter collection is done DHT11 will turn to low power mode.
4.5 IR SENOR:
Infrared Obstacle Sensor Module has builtin IR transmitter and IR receiver
that sends out IR energy and looks for reflected IR energy to detect presence of any
obstacle in front of the sensor module. The module has on board potentiometer that
lets user adjust detection range. The sensor has very good and stable response even in
ambient light or in complete darkness.
29
photo diodes as they detect only infrared radiation. When the IR transmitter emits
radiation, it reaches the object and some of the radiation reflects back to the IR
receiver. Based on the intensity of the reception by the IR receiver, the output of the
sensor is defined
30
or “off”. If the pixel is “on”, the liquid crystal cell is electrically activated, and the
molecules in the liquid will align in a single direction. This will allow the light to pass
through unchanged. If the pixel is “off”, the electric field is removed from the liquid,
and the molecules with in scatter. This dramatically reduces the light that will pass
through the display at that pixel.
Fig 4.10: A general purpose alphanumeric lcd, with two lines of display
In a color display, after the light passes through the liquid crystal matrix, it
passes through a color filter (usually glass). This filter blocks all wavelengths of light
except those within the range of that pixel. In a typical RGB display, the color filter is
integrated into the upper glass colored microscopically to render each individual pixel
red, green or blue. The areas in between the colored pixel filter areas are printed black
to increase contrast. After a beam of light passes through the color filter, it passes
through yet another polarizer to sharpen the image and eliminate glare.
31
• ON/OFF, Blink Character, Cursor Shift, Display Shift.
32
4.7 Relay Module:
This relay module allows you to combine the processing power of the Arduino to
devices that use higher current and voltage. It does so by providing four relays that
are rated for 7A at either 28VDC or 10A at 125VAC. Each relay has a Normally
Open (NO) and a Normally Closed (NC) contact.
With these relays you can control:
Appliances
Motors
Lights
Other Relay
4.7.1: Relay Module Inputs:
The module is supplied with power via the pin labeled VCC and ground via
the pin labeled GND.The relays are energized with low inputs to the IN1, IN2, IN3
and IN4 inputs.
33
Fig 4.12: Relay Board Common Connetions
4.7.3 Advantages:
• Sophisticated security.
• Monitors all hazards and threats.
• Alert message to mobile phone for remote information.
• Mobile number can be changed at any time.
34
Fig 4.13: Transistor BC547
Table 4.3: Pin Configuration
Pin
Pin Name Description
Number
When this transistor is fully biased then it can allow a maximum of 100mA to
flow across the collector and emitter. This stage is called Saturation Region and the
typical voltage allowed across the Collector-Emitter (V¬CE) or Base-Emitter (VBE)
could be 200 and 900 mV respectively. When base current is removed the transistor
becomes fully off, this stage is called as the Cut-off Region and the Base Emitter
voltage could be around 660 mV.
35
CHAPTER 5
SOFTWARE DESCRIPTION
5.1. PROGRAMMING LANGUAGE:
The programming language used is EMBEDDED C.
EMBEDDED C PROGRAMMING:
Embedded C is a set of language extensions for the C programming language by the C
Standards Committee to address commonality issues that exist between C extensions
for different embedded systems. Historically, embedded C programming requires
nonstandard extensions to the C language in order to support exotic features such
as fixed-point arithmetic, multiple distinct memory banks, and basic I/O operations.
In 2008, the C Standards Committee extended the C language to address these issues
by providing a common standard for all implementations to adhere to. It includes a
number of features not available in normal C, such as, fixed-point arithmetic, named
address spaces, and basic I/O hardware addressing.
Embedded C uses most of the syntax and semantics of standard C, e.g., main()
function, variable definition, datatype declaration, conditional statements (if, switch
case), loops (while, for), functions, arrays and strings, structures and union, bit
operations, macros, etc
5.2. Software:
36
(meaning physical devices). In contrast to hardware, software "cannot be touched".
Software is also sometimes used in a more narrow sense, meaning application
software only. Sometimes the term includes data that has not traditionally been
associated with computers, such as films, tapes and records.
5.3.TYPES OF SOFTWARE:
System software provides the basic functions for computer usage and helps
run the computer hardware and system like Device drivers, Operating systems.
System software is responsible for managing a variety of independent hardware
components, so that they can work together harmoniously. Its purpose is to unburden
the application software, programmer from the often complex details of the particular
computer being used, including such accessories as communications devices, printers,
device readers, displays and keyboards, and also to partition the computer's resources
such as memory and processor time in a safe and stable manner.
37
5.4SOFTWARE USED:
5.4.1. ARDUINO:
38
1. Get an Arduino board
2. Download the Arduino environment
3. Install the USB drivers
4. Connect the board
5. Upload a program
There are a few ways to get an Arduino board:
buy a ready made board. See how you can buy a board or just the PCB.
o European distributor
o US distributor
build your own board. If you want you can build your own PCB just by
downloading the CAD files from the Hardwarepage. Extract the .brd file and send it
to a PCB manufacturer. Be aware that manufacturing a single pcb will be very
expensive. It's better to get together with other people and make 20 or 30 at a time.
Since you get the full CAD files you can make your own customised version of
Arduino. if you make modifications or fix bugs please send us your changes!
o purchase parts. purchase the parts from any electronics store. The Serial version in
particular has been designed to use the most basic parts that can be found anywhere in
the world. The USB version on the other hand requires some advanced soldering
skills because of the FTDI chip that is ansmd part. Here is a list of parts for the serial
board.
o assemble the board. We put together a step by step guide on how to build an arduino
board.
o program the bootloader. In order for the development environment to be able to
program the chip, this has to be programmed with a piece of code called bootloader.
See the bootloader page on how to program it on your chip.
39
Linux note: For help getting the Arduino IDE running
On Windows, you will need to unzip FTDI USB drivers zip .Then, when you plug in
the Arduino board, point the Windows Add Hardware wizard to the FTDI USB
drivers directory.
40
Installing Drivers
On the USB boards, the power source is selected by the jumper between the USB and
power plugs. To power the board from the USB port (good for controlling low power
devices like LEDs), place the jumper on the two pins closest to the USB plug. To
power the board from an external power supply (needed for motors and other high
current devices), place the jumper on the two pins closest to the power plug. Either
way, connect the board to a USB port on your computer. On Windows, the Add New
Hardware wizard will open; tell it you want to specify the location to search for
drivers and point to the folder containing the USB drivers you unzipped in the
previous step.
5 | Upload a program
Open the LED blink example sketch: File > Sketchbook > Examples >led_blink.
41
Here's what the code for the LED blink example looks like.
Select the serial device of the Arduino board from the Tools | Serial Port menu. On
Windows, this should be COM1 or COM2 for a serial Arduino board, or
COM3,COM4,or COM5 for a USB board. On the Mac, this should be something like
/dev/cu.usbserial-1B1 for a USB board, or something like
/dev/cu.USA19QW1b1P1.1 if using a Keyspan adapter with a serial board (other
USB-to-serial adapters use different names).
42
Push the reset button on the board then click the Upload button in the IDE.
Wait a few seconds. If successful, the message "Done uploading." will appear in the
status bar
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
43
pinMode(10,OUTPUT);
pinMode(9 ,OUTPUT);
pinMode(48,INPUT);
pinMode(50,INPUT_PULLUP);
pinMode(52,INPUT_PULLUP);
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
dht.begin();
Serial1.begin(9600);
Serial.begin(9600);
lcd.setCursor(0, 0);
lcd.print("Home Automation");
lcd.setCursor(0, 1);
lcd.print("Using Wifi");
delay(6000);
lcd.clear();
// Print a message to the LCD.
void loop() {
delay(500);
intx,y,z;
x=digitalRead(52);
y=digitalRead(50);
z=digitalRead(48);
if(x==LOW)
{
lcd.clear();
44
lcd.setCursor(0, 0);
lcd.print("Door Open........");
msg();
lcd.print("Door Open........");
Serial1.print("Person Trying To Enter Room Please Open The Door .....");
delay(1000);
Serial1.write(0x1A);
delay(1000);
}
if(y==LOW)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Door Close........");
msg();
Serial1.print("No One Inside the Room Please Close The Door .....");
delay(1000);
Serial1.write(0x1A);
delay(1000);
}
if(z==HIGH)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Fan On........");
msg();
Serial1.print("Guest Enterd Room Switch on The FAN .....");
delay(1000);
Serial1.write(0x1A);
delay(1000);
}
45
hum();
}
voidmsg()
{
Serial1.println("AT");
delay(1000);
Serial1.println("AT+CMGF=1");
delay(1000);
Serial1.println("AT+CSCS=\"GSM\"");
delay(1000);
Serial1.println("AT+CMGS=\"8185061595\"");
delay(1000);
}
void hum()
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: Humidity:");
lcd.setCursor(0, 1);
float h = dht.readHumidity();
h=h*1.3;
float f = dht.readTemperature(true);
f=f/2.6;
if (isnan(h) || isnan(f)) {
lcd.print("ERROR");
return;
}
46
lcd.print(f);
lcd.setCursor(7,1);
lcd.print(h);
}
voidserialEvent()
{
if(Serial.available())
{
char d=Serial.read();
if(d=='a')
{
digitalWrite(12,HIGH);
}
else if(d=='b')
{
digitalWrite(12,LOW);
}
else if(d=='c')
{
digitalWrite(11,HIGH);
}
else if(d=='d')
{
digitalWrite(11,LOW);
47
}
else if(d=='e')
{
digitalWrite(10,HIGH);
}
else if(d=='f')
{
digitalWrite(10,LOW);
}
else
{
}
}
}
48
server.send(200, "text/plain", "Acesss /fon page to turn on FAN, /Foff page to turn off
Fan,/Aon page to turn on AC,/Aoff page to turn off AC,/Dopen page to Door Open
and /Dclose page to Door Close");
}
voidfon()
{
mySerial.print('a');
server.send(200, "text/plain", "FAN IS Now ON Condtion");
handleRoot();
}
voidfoff()
{
mySerial.print('b');
server.send(200, "text/plain", "FAN IS Now OFF Condtion");
delay(2000);
handleRoot();
}
void Aon()
{
mySerial.print('c');
server.send(200, "text/plain", "AC IS Now ON Condtion");
delay(2000);
handleRoot();
}
voidAoff()
{
mySerial.print('d');
server.send(200, "text/plain", "AC IS Now OFF Condtion");
49
delay(2000);
handleRoot();
}
voidDopen()
{
mySerial.print('e');
server.send(200, "text/plain", "Door Opened Now");
delay(2000);
handleRoot();
}
voidDclose()
{
mySerial.print('f');
server.send(200, "text/plain", "Door Closed Now");
delay(2000);
handleRoot();
}
void setup(void)
{
pinMode(14,OUTPUT);
digitalWrite(14,1);
Serial.begin(115200);
mySerial.begin(9600);
Serial.println();
Serial.print("Configuring access point...");
WiFi.softAP(ssid, password);
IPAddressmyIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
server.on("/", handleRoot);
50
server.on("/fon", fon);
server.on("/foff", foff);
server.on("/aon", Aon);
server.on("/aoff", Aoff);
server.on("/don", Dopen);
server.on("/doff", Dclose);
server.begin();
Serial.println("HTTP server started");
}
void loop(void)
{
server.handleClient();
}
51
CHAPTER 6
RESULTS:
DJ HD,DJ HD
52
Fig 6.2:Mobile controlled messages
53
CONCLUSION
Home automation techniques have been implemented in order to provide ease to the
people to control their home appliances. Different home automation techniques using
Arduino, GSM and Android are given with their design, implementation and
flowcharts which gives the successful layout of their strengths and weaknesses.
Main purpose of home automation system is to provide ease to people to
control different home appliances with the help of mobile phones and to save
electricity, time and money. The goal of the project is to design a system which
should be easy to implement and short ranged. The project is implemented through
onboard Wi-Fi. Implementing the actuators for door systems for more security aspects
can increase the future scope of this project.
54
REFERENCES
Websites:
• http://www.iot-playground.com
• http://www.instructables.com
• http://en.wikipedia.org
• http://www.journals.elsevier.com/easyiot
55