Smart Building

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 56

Smart building using IR and IOT

CHAPTER 1: INTRODUCTION

1.1 PROJECT OVERVIEW


Using Internet of Things (IOT), we can control many electronic equipment in
homes and industries. In this project, you will develop an electronic device that can
detect the presence of any persons which passes through the IR sensor inside the
room and send the data to the Arduino board for interpretation. You can also program
the system in such a way that whenever there is a presence of persons in front of the
sensor, it will automatically switches ON the light and vice versa. The data about the
number of persons . will be sent to the cloud for storage and analysis purposes. To build
this Smart Building using IR & IOT Project you will need 4 major components, IR
Sensor, Arduino Uno, Relay Drivers, and ESP8266 Wi-Fi Module. These systems can
play an important role in regular energy monitoring and management and therefore to
save the possible energy and cost.

1.2 INFORMATION TRANSFER

A co-ordinated sequence of user and wireless communication system actions that


causes information present at a source user to become present at a destination user. An
information-transfer transaction usually consists of three consecutive phases called the
access phase, the information-transfer phase, and the disengagement phase.

1.3 COMPONENTS OVERVIEW

This system uses the following components.

1.3.1 Arduino uno

The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It


has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs, a 16 MHz ceramic resonator, 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

Department of ECE, VBIT 1


Smart building using IR and IOT

battery to get started. The Uno differs from all preceding boards in that it does not use
the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up
to version R2) programmed as a USB-to-serial converter. Revision 2 of the Uno board
has a resistor pulling the 8U2 HWB line to ground, making it easier to put into DFU
mode. Revision 3 of the board has the following new features:

1.3.2 IR Sensor

Infrared radiation is an electromagnetic wave with wavelength of 700nm to 1 mm. It


is emitted by objects with temperature above 0 kelvins. Furthermore intensity and
wavelength of infrared radiation depends on the temperature of the object.

The infrared sensors are the sensors that detect/measure infrared radiation or change
in the radiation from outer source or inbuilt source.Also sensors that uses the
property of infrared radiations to detect the changes in surrounding are termed as
infrared sensors.

1.3.3 Wifi Module

The ESP8266 is a low-cost Wi-Fi microchip with full TCP/IP stack and
microcontroller capability produced by Shanghai-based Chinese manufacturer .he chip
first came to the attention of western makers in August 2014 with the ESP-01 module,
made by a third-party manufacturer, Ai-Thinker. This small module allows
microcontrollers to connect to a Wi-Fi network and make simple TCP/IP connections
using Hayes-style commands. However, at the time there was almost no English-
language documentation on the chip and the commands it accepted.

1.3.4 Arduino Uno Interface

Finally, this project uses serial interface for interfacing the arduino with a Wi-Fi
module. This interface is used to setup the Wi-Fi module and arduino. A hyper terminal
application is used to issue AT commands to the Wi-Fi module.

1.4 SYSTEM OPERATION

Department of ECE, VBIT 2


Smart building using IR and IOT

The operation of the system is very simple. Sending message from any of the
Arduino based to the distant located notice board using Bluetooth module. For sending
the text message from android phone we need to interface the mobile phone with
Bluetooth module. For developing some of Bluetooth based applications we need to have
some commons peripherals including Bluetooth module, microcontroller, LCD (Liquid
crystal display), power supply and also some connecting wires.

Department of ECE, VBIT 3


Smart building using IR and IOT

CHAPTER 2: PROBLEM DEFINITION

As explained in the introduction chapter, the realization of complete potential of


the display boards and the wireless medium in information transfer is the major issue
that the following thesis of the following project deals with.

Fig 2.1: Overview of system

Department of ECE, VBIT 4


Smart building using IR and IOT

From Fig 2.1, there are at least four interfacing circuits, Wi-Fi module, Arduino-

Department of ECE, VBIT 5


Smart building using IR and IOT

uno with Microcontroller ATMEGA328, IR sensor and Relay. It is not a hidden


fact that interfacing a Wi-Fi module with a normal arduino is quite easy with the help of
the AT commands. But we must take into account the fact that the module requires a
wired connection at one end and wireless at the other. Dedicating a general purpose
computer at particular site for counting.

2.1 CIRCUIT DIAGRAM OF THE SYSTEM

Fig 2.2: Circuit diagram of the system.

This circuit uses Arduino board that accepts data as input from IR sensors and
automatically switches the light ON/OFF and vice versa. Arduino is the heart of this
programmable counting. The Power supply is applied through the USB port to drive
Arduino. In this application the Wi-Fi module acts as transmitter that gives the
information about people entering the room and vice versa and is compatible with most
Wi-Fi devices.

Department of ECE, VBIT 6


Smart building using IR and IOT

CHAPTER 3: SYSTEM REQUIREMENT SPECIFICATION

3.1 HARDWARE REQUIREMENTS

3.1.1 Arduino Uno


The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet).
It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs, a 16 MHz crystal oscillator, 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. The Uno 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. "Uno" means one in Italian and is named to mark the upcoming
release of Arduino 1.0. The Uno and version 1.0 will be the reference versions of
Arduino, moving forward. The Uno is the latest in a series of USB Arduino boards, and
the reference model for the Arduino platform.

Department of ECE, VBIT 7


Smart building using IR and IOT

Figure 3.1: Arduino uno

3.1.1.1 Features of Adruino Uno


Hardware features
 Microcontroller At mega 328
 Operating Voltage 5V
 Input Voltage (recommended) 7-12V
 Input Voltage (limits) 6-20V
 Digital I/O Pins 14 (of which 6 provide PWM output)
 Analog Input Pins 6
 DC Current per I/O Pin 40 mA
 DC Current for 3.3V Pin 50 mA
 Flash Memory 32 KB of which 0.5 KB used bootloader
 SRAM 2 KB
 EPROM 1 KB
 Clock Speed 16 MHz

Software features
 save default baud rate: 9600.
 IDE software.
3.1.1.2 Pin description
 Power Pins
The Arduino Uno can be powered via the USB connection or with an external power
supply. The power source is selected automatically. 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 centre-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

Department of ECE, VBIT 8


Smart building using IR and IOT

using more than 12V, the voltage regulator may overheat and damage the board. The
recommended range is 7 to 12 volts.
 VIN:
The input voltage to the Arduino board when it's using an external 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
 3.3v:
A 3.3 volt supply generated by the on-board regulator. Maximum current draw
is 50 mA.
• GND:
Ground pins.
 Input and output Pins
Each of the 14 digital pins on the 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:
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:
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.
• PWM:

Department of ECE, VBIT 9


Smart building using IR and IOT

3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analog Write()
function
. • SPI:
10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI
communication, which, although provided by the underlying hardware, is not currently
included in the Arduino language.
• 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
The Uno has 6 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 the analogReference()
function. Additionally, some pins have specialized functionality:
• I 2C:
4 (SDA) , and 5 (SCL). Support I2C (TWI) communication using the Wire
library. There are a couple of other pins on the board:
• AREF:
Reference voltage for the analog inputs. Used with analog Reference ().
• 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.
3.1.2 Wi-fi Module
The chip first came to the attention of western makers in August 2014 with
the ESP-01 module, made by a third-party manufacturer, Ai-Thinker. This small module
allows microcontrollers to connect to a Wi-Fi network and make simple TCP/IP
connections using Hayes-style commands. However, at the time there was almost no
English-language documentation on the chip and the commands it accepted. The very
low price and the fact that there were very few external components on the module which
suggested that it could eventually be very inexpensive in volume, attracted many hackers
to explore the mo

Department of ECE, VBIT 10


Smart building using IR and IOT

dule, chip,
and the software on it, as well as to translate the Chinese document

Pin Pin Alternate Normally used


Alternate purpose
Number Name Name for
Connected to the
1 Ground - ground of the -
circuit
Can act as a General
Connected to Rx
purpose
pin of
2 TX GPIO – 1 Input/output pin
programmer/uC
when not used as
to upload program
TX
General purpose
3 GPIO-2 - -
Input/output pin
Chip Enable –
4 CH_EN - -
Active high
Takes module into
GPIO - General purpose
5 Flash serial programming
0 Input/output pin
when held low

Department of ECE, VBIT 11


Smart building using IR and IOT

during start up
6 Reset - Resets the module -
Can act as a General
purpose
General purpose
7 RX GPIO - 3 Input/output pin
Input/output pin
when not used as
RX
Connect to +3.3V
8 Vcc -
only

Fig 3.2:Wi-fi Module

3.1.4.1 Enable (EN)

The EN line is called "Enable." This control line is used to tell the LCD that you
are sending it data. To send data to the LCD, your program should make sure this line is
low (0) and then set the other two control lines and/or put data on the data bus. When the
other lines are completely ready, bring EN high (1) and wait for the minimum amount of
time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing
it low (0) again.

3.1.4.2 Register Select (RS)

The RS line is the "Register Select" line. When RS is low (0), the data is to be
treated as a command or special instruction (such as clear screen, position cursor, etc.).
When RS is high (1), the data being sent is text data which should be displayed on the
screen. For example, to display the letter "T" on the screen you would set RS high.

3.1.4.3 Read/Write (R/W)


The RW line is the "Read/Write" control line. When RW is low (0), the information
on the data bus is being written to the LCD. When RW is high (1), the program is
effectively querying (or reading) the LCD. Only one instruction ("

Department of ECE, VBIT 12


Smart building using IR and IOT

3.1.4.1 Enable (EN)

The EN line is called "Enable." This control line is used to tell the LCD that you
are sending it data. To send data to the LCD, your program should make sure this line is
low (0) and then set the other two control lines and/or put data on the data bus. When the
other lines are completely ready, bring EN high (1) and wait for the minimum amount of
time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing
it low (0) again.

3.1.4.2 Register Select (RS)

The RS line is the "Register Select" line. When RS is low (0), the data is to be
treated as a command or special instruction (such as clear screen, position cursor, etc.).
When RS is high (1), the data being sent is text data which should be displayed on the
screen. For example, to display the letter "T" on the screen you would set RS high.

3.1.4.3 Read/Write (R/W)


The RW line is the "Read/Write" control line. When RW is low (0), the information
on the data bus is being written to the LCD. When RW is high (1), the program is
effectively querying (or reading) the LCD. Only one instruction ("

Department of ECE, VBIT 13


Smart building using IR and IOT

3.1.4 Important Signals

The following pins are important to LCD‟s while programming

Get LCD status") is a read command. All others are write commands--so RW will
almost always be low. Finally, the data bus consists of 4 or 8 lines (depending on the
mode of operation selected by the user). In the case of an 8-bit data bus, the lines are
referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.

The LCD panel's Enable and Register Select is connected to the Control Port. The
Control Port is an open collector / open drain output. While most Parallel Ports have
internal pull-up resistors, there is a few which don't. Therefore by incorporating the two
10K external pull up resistors, the circuit is more 18 portable for a wider range of
computers, some of which may have no internal pull up resistors.

We make no effort to place the Data bus into reverse direction. Therefore we hard
wire the R/W line of the LCD panel, into write mode. This will cause no bus conflicts on
the data lines. As a result we cannot read back the LCD Internal busy flag is noticed if
the LCD has accepted and finished processing the last instruction. This problem is
Overcome by inserting known delays into our program.

The 10k Potentiometer controls the contrast of the LCD panel. Nothing fancy
here. As with all the examples, I've left the power supply out. You can use a bench power
supply set to 5V or use a onboard +5 regulator. Remember a few de-coupling capacitors,
especially if you have trouble with the circuit working properly.

Table 3.2: LCD command set

Department of ECE, VBIT 14


Smart building using IR and IOT

3.2 MICROCONTROLLER ATMEGA 328

Figure 3.3: Arduino UNO board

The Atmel 8-bit AVR RISC-based microcontroller combines 32 KB ISP flash


memory with read-while-write capabilities, 1 KB EEPROM, 2 KB SRAM, 23 general
purpose I/O lines, 32 general purpose working registers, three flexible timer/counters

Department of ECE, VBIT 15


Smart building using IR and IOT

with compare modes, internal and external interrupts, serial programmable USART, a
byte-oriented 2-wire serial interface, SPI serial port, 6-channel 10-bit A/D converter (8-
channels in TQFP and QFN/MLF packages), programmable watchdog timer with
internal oscillator, and five software selectable power saving modes. The device operates
between 1.8-5.5 volts. The device achieves throughputs approaching 1 MIPS.

3.2.1 Applications

Today the ATmega328 is commonly used in many projects and autonomous


systems where a simple, low-powered, low-cost micro-controller is needed. Perhaps the
most common implementation of this chip is on the popular Arduino development
platform, namely the Arduino Uno and Arduino Nano models.

3.2.2 Features

 28-pin AVR Microcontroller


 Flash Program Memory: 32 kbytes
 EEPROM Data Memory: 1 kbytes
 SRAM Data Memory: 2 kbytes
 I/O Pins: 23
 Timers: Two 8-bit / One 16-bit
 A/D Converter: 10-bit Six Channel
 PWM: Six Channels
 RTC: Yes with Separate Oscillator
 MSSP: SPI and I²C Master and Slave Support
 USART: Yes
 External Oscillator: up to 20MHz

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.

Department of ECE, VBIT 16


Smart building using IR and IOT

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.

Department of ECE, VBIT 17


Smart building using IR and IOT

3.3 PIN DIAGRAM OF ATMEGA328

Figure 3.4: Pin diagram of Atmega328

Department of ECE, VBIT 18


Smart building using IR and IOT

Table 3.3: Description of each pins of ATmega328

As stated before, 20 of the pins function as I/O ports. This means they can
function as an input to the circuit or as output. Whether they are input or output is set in
the software. 14 of the pins are digital pins, of which 6 can function to give PWM output.
6 of the pins are for analog input/output. Two of the pins are for the crystal oscillator,
this is to provide a clock pulse for the Atmega chip. A clock pulse is needed for

Department of ECE, VBIT 19


Smart building using IR and IOT

synchronization so that communication can occur in synchrony between the Atmega chip
and a device that it is connected to.

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. 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. Since the ADC for the Atmega328 is a 10-bit ADC, meaning it
produces a 10-bit digital value, it converts an analog signal to its digital value, with the
AREF value being a reference for which digital values are high or low. Thus, a portrait of
an analog signal is shown by this digital value; thus, it is its digital correspondent value.
The last pin is the RESET pin. This allows a program to be rerun and start over. And this
sums up the pin out of an Atmega328 chip.

3.4 ARCHITECTURE

Figure 3.5: Architecture of AVR

Department of ECE, VBIT 20


Smart building using IR and IOT

3.5 FEATURES OF AVR.

• High-performance, Low-power AVR® 8-bit Microcontroller


• Advanced RISC Architecture
– 131 Powerful Instructions – Most Single-clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16 MHz
– On-chip 2-cycle Multiplier
• Nonvolatile Program and Data Memories
– 32K Bytes of In-System Self-Programmable Flash
• Endurance: 10,000 Write/Erase Cycles
– Optional Boot Code Section with Independent Lock Bits
• In-System Programming by On-chip Boot Program
• True Read-While-Write Operation
– 1024 Bytes EEPROM
• Endurance: 100,000 Write/Erase Cycles
– 2K Byte Internal SRAM
– Programming Lock for Software Security
• JTAG (IEEE std. 1149.1 Compliant) Interface
– Boundary-scan Capabilities According to the JTAG Standard
– Extensive On-chip Debug Support
– Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
• Peripheral Features
– Two 8-bit Timer/Counters with Separate Pre scalers and Compare Modes
– One 16-bit Timer/Counter with Separate Pre scaler, Compare Mode, and Capture
Mode
– Real Time Counter with Separate Oscillator
– Four PWM Channels
– 8-channel, 10-bit ADC
• 8 Single-ended Channels
• 7 Differential Channels in TQFP Package Only

Department of ECE, VBIT 21


Smart building using IR and IOT

• 2 Differential Channels with Programmable Gain at 1x, 10x, or 200x


– Byte-oriented Two-wire Serial Interface
– Programmable Serial USART
– Master/Slave SPI Serial Interface
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator
• Special Microcontroller Features
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated RC Oscillator
– External and Internal Interrupt Sources
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby
and Extended Standby
• I/O and Packages
– 32 Programmable I/O Lines
– 40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF
• Operating Voltages
– 2.7 - 5.5V for ATmega32L
– 4.5 - 5.5V for ATmega32
• Speed Grades
– 0 - 8 MHz for ATmega32L
– 0 - 16 MHz for ATmega32
• Power Consumption at 1 MHz, 3V, 25°C for ATmega32L
– Active: 1.1 mA
– Idle Mode: 0.35 mA
– Power-down Mode: < 1 μA

Department of ECE, VBIT 22


Smart building using IR and IOT

3.6 DIFFERENT FLAVOURS OF ARDUINO WITH THEIR


CONFIGURATION

Table 3.4: Different Flavors of ARDUINO with their Configuration

Department of ECE, VBIT 23


Smart building using IR and IOT

3.7 BASIC TERMINOLOGIES IN ARDUINO

3.7.1 Analog to Digital Converter (ADC)

 The process of Analog to digital conversion is shown in figure.


 The Arduino has 10 bits of Resolution when reading analog signals.
 210=1024 increments.
 Influence also by how fast you sample.

3.7.2 Pulse Width Modulation (PWM)

 The Arduino has 8bit of resolution, when outputting a signal using PWM.
 The range of output voltage is from 0 to 5 Volts.
 28=255 Increments
 Average of on/off(digital signals to make an average voltage),Duty cycle in 100%
of 5Volts.

3. 8 LANGUAGE REFERENCES:

The Microcontroller on the board is programmed using the Arduino programming


language (based on wiring) and the arduino development environment (based on
processing).

3.8.1 Arduino programming language (APL) (based on wiring)

The Arduino programming language is an implementation of wiring, a similar


physical computing platform, which is based on the Processing multimedia
programming environment.

3.8.2 Wiring

Wiring is an open-source programming framework for microcontrollers. Wiring


allows writing cross-platform software to control devices attached to a wide range of

Department of ECE, VBIT 24


Smart building using IR and IOT

microcontroller boards to create all kinds of creative coding, interactive objects, spaces or
physical experiences. The framework is thoughtfully created with designers and artists in
mind to encourage a community where beginners through experts from around the world
share ideas, knowledge and their collective experience. There are thousands of students,
artists, designers, researchers, and hobbyists who use Wiring for learning, prototyping,
and finished professional work production.

3.9 ARDUINO DEVELOPMENT ENVRONMENT

3.9.1 Processing

Processing is an open source programming language and environment for people


who want to create images, animations, and interactions. Initially developed to serve as a
software sketchbook and to teach fundamentals of computer programming within a
visual context, Processing also has evolved into a tool for generating finished
professional work. Today, there are tens of thousands of students, artists, designers,
researchers, and hobbyists who use Processing for learning, prototyping, and production.

3.10 SOFTWARE REQUIREMENTS

3.10.1 Embedded C

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.

3.10.2 Difference between C and Embedded C

Though C and embedded C appear different and are used in different contexts,
they have more similarities than the differences. Most of the constructs are same; the
difference lies in their applications.

Department of ECE, VBIT 25


Smart building using IR and IOT

C is used for desktop computers, while embedded C is for microcontroller based


applications. C takes more resources of a desktop PC like memory, OS, etc. while
programming on desktop systems what embedded C cannot. Embedded C has to use the
limited resources (RAM, ROM, I/O’s) on an embedded processor. Thus, program code
must fit into the available program memory. If code exceeds the limit, the system is likely
to crash.

Compilers for C (ANSI C) typically generate OS dependent executable files.


Embedded C requires compilers to create files to be downloaded to the
microcontrollers/microprocessors where it needs to run. Embedded compilers give access
to all resources which is not provided in compilers for desktop computer applications.

Embedded systems often have the real-time constraints, which is usually not
there with desktop computer applications.

Embedded systems often do not have a console, which is available in case of


desktop applications.

The C programming language is perhaps the most popular programming language


for programming embedded systems. C continues to be a very popular language for
micro-controller developers/programmers due to the code efficiency and reduced
overhead and development time. C offers low-level control and is considered more
readable than assembly language which is a little difficult to understand. Assembly
language requires more code writing, whereas C is easy to understand and requires less
coding. Plus, using C increases portability, since C code can be compiled for different
types of processors. We can program microcontrollers using Atmel Atmega328, AVR or
PIC.

Here by developing the programs as per the electronic hardware using Atmel
Atmega328 micro controller. For the operations like: blink led, increment decrement
counters, token displays etc.

Department of ECE, VBIT 26


Smart building using IR and IOT

Most C programmers are spoiled because they program in environments where


not only there is a standard library implementation, but there are frequently a number of
other libraries available for use. The cold fact is, that in embedded systems, there rarely
are many of the libraries that programmers have grown used to, but occasionally an
embedded system might not have a complete standard library, if there is a standard
library at all. Few embedded systems have capability for dynamic linking, so if standard
library functions are to be available at all, they often need to be directly linked into the
executable. Oftentimes, because of space concerns, it is not possible to link in an entire
library file, and programmers are often forced to "brew their own" standard c library
implementations if they want to use them at all. While some libraries are bulky and not
well suited for use on microcontrollers, many development systems still include the
standard libraries which are the most common for C programmers.

C remains a very popular language for micro-controller developers due to the


code efficiency and reduced overhead and development time. C offers low-level control
and is considered more readable than assembly. Many free C compilers are available for
a wide variety of development platforms. The compilers are part of an IDEs with ICD
support, breakpoints, single-stepping and an assembly window. The performance of C
compilers has improved considerably in recent years, and they are claimed to be more or
less as good as assembly, depending on who you ask. Most tools now offer options for
customizing the compiler optimization. Additionally, using C increases portability, since
C code can be compiled for different types of processors.

3.10.3 Software

The software used by the arduino is Arduino IDE. The Arduino IDE is a cross-
platform application written in Java, and is derived from the IDE for the Processing
programming language and the Wiring project. It is designed to introduce programming
to artists and other newcomers unfamiliar with software development. It includes a code
editor with features such as syntax highlighting, brace matching, and automatic
indentation, and is also capable of compiling and uploading programs to the board with a
single click. There is typically no need to edit make files or run programs on a command-

Department of ECE, VBIT 27


Smart building using IR and IOT

line interface. Although building on command-line is possible if required with some


third-party tools such as Ino.

The Arduino IDE comes with a C/C++ library called "Wiring" (from the project
of the same name), which makes many common input/output operations much easier.
Arduino programs are written in C/C++, although users only need define two functions to
make a runnable 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

A typical first program for a microcontroller simply blinks a LED on and off. In
the Arduino environment, the user might write a program like this:
 #define LED_PIN 13
 void setup (){
 pinMode(LED_PIN, OUTPUT);// enable pin 13 for digital output
 }
 void loop (){
 digitalWrite(LED_PIN, HIGH);// turn on the LED
 delay(1000);// wait one second (1000 milliseconds)

Department of ECE, VBIT 28


Smart building using IR and IOT

Figure 3.6: A Screenshot of Arduino IDE

For the above code to work correctly, the positive side of the LED must be
connected to pin 13 and the negative side of the LED must be connected to ground. The
above code would not be seen by a standard C++ compiler as a valid program, so when
the user clicks the "Upload to I/O board" button in the IDE, a copy of the code is written
to a temporary file with an extra include header at the top and a very simple main()
function at the bottom, to make it a valid C++ program.

The Arduino IDE uses the GNU tool chain and AVR Libc to compile programs,
and uses AVR dude to upload programs to the board.

Department of ECE, VBIT 29


Smart building using IR and IOT

For educational purposes there is third party graphical development environment


called Mini blog available under a different open source license.

PROGRAM COMPILING

Figure 3.7: Program compiling using arduino IDE.

Department of ECE, VBIT 30


Smart building using IR and IOT

SELECTING BOARD

Figure 3.8: Selecting the board from Tools menu

SELECTING PORT

Figure 3.9: Selecting the port

Department of ECE, VBIT 31


Smart building using IR and IOT

UPLOADING PROGRAM

Figure 3.10: Uploading program to the arduino.

3.10.4 Language Reference

Arduino programs can be divided in three main parts: structure, values (variables
and constants), and functions.

Available data types in ARDUINO IDE are

 void

 boolean

 char ( 0 – 255)

 byte - 8 bit data ( 0 – 255)

 int - 16-bit data (32,767 - -32,768)

Department of ECE, VBIT 32


Smart building using IR and IOT

 long – 32 bit data (2,147,483,647 to -2,147,483,648)

 float

 double

 string - char array

 String - object

 array

3.11 AT COMMANDS.

AT commands are used to control MODEMs. AT is the abbreviation for


Attention. These commands come from Hayes commands that were used by the Hayes
smart modems. The Hayes commands started with AT to indicate the attention from the
MODEM. The dial up and wireless MODEMs (devices that involve machine to machine
communication) need AT commands to interact with a computer. These include the
Hayes command set as a subset, along with other extended AT commands.

AT commands with a mobile phone can be used to access following information


and services:

1. Information and configuration pertaining to mobile device or Bluetooth module.


2. SMS services.
3. MMS services.
4. Fax services.
5. Data and Voice link over mobile network.

The Hayes subset commands are called the basic commands and the commands
specific to a Bluetooth network are called extended AT commands.

Department of ECE, VBIT 33


Smart building using IR and IOT

3.12 TYPES OF AT COMMANDS:

There are four types of AT commands:

Fig 3.11: AT commands classification

3.12.1 Explanation of commonly used AT commands

1) AT - This command is used to check communication between the module and the
computer.
For example, AT OK

The command returns a result code OK if the computer (serial port) and module
are connected properly. If any of module or SIM is not working, it would return a result
code
ERROR.

2) +CMGF - This command are used to set the SMS mode. Either text or PDU mode can
be selected by assigning 1 or 0 in the command.
SYNTAX: AT+CMGF=<mode>
0: for PDU mode
1: for text mode

Department of ECE, VBIT 34


Smart building using IR and IOT

The text mode of SMS is easier to operate but it allows limited features of SMS.
The PDU (protocol data unit) allows more access to SMS services but the operator
requires bit level knowledge of TPDUs. The headers and body of SMS are accessed in
hex format in PDU mode so it allows availing more features.
For example,
AT+CMGF=1
OK

3) +CMGW - This command is used to store message in the SIM.

SYNTAX: AT+CMGW=” Phone number”>Message to be stored Ctrl+z

As one types AT+CMGW and phone number, „>‟ sign appears on next line
where one can type the message. Multiple line messages can be typed in this case. This is
why the message is terminated by providing a „Ctrl+z‟ combination. As Ctrl+z is
pressed, the following information response is displayed on the screen.+CMGW: Number
on which message has been stored

4) +CMGS - This command is used to send a SMS message to a phone number.

SYNTAX: AT+CMGS= serial number of message to be send.

As the command AT+CMGS and serial number of message are entered, SMS is
sent to the particular SIM.
For example,
AT+CMGS=1
OK

5) ATD - This command is used to dial or call a number.

SYNTAX: ATD<Phone number> (Enter)

Department of ECE, VBIT 35


Smart building using IR and IOT

For example,
ATD123456789

6) ATA - This command is used to answer a call. An incoming call is indicated by a


message „RING‟ which is repeated for every ring of the call. When the call ends „NO
CARRIER‟ is displayed on the screen.

SYNTAX: ATA (Enter)


As ATA followed by enter key is pressed, incoming call is answered. For example,
RING
RING
ATA

7) ATH - This command is used to disconnect remote user link with the GSM module.

SYNTAX: ATH (Enter)

3.13 LIST OF AT COMMANDS

The AT commands for both, bluetooth module and the mobile phone, are listed
below. Some of these commands may not be supported by all the bluetooth modules
available. Also there might be some commands which won’t be supported by some
mobile handsets.

TABLE 3.5: AT Commands

Command Description
AT Checking communication between
the module and computer.

Department of ECE, VBIT 36


Smart building using IR and IOT

CALL CONTROL
Command Description
ATA Answer command
ATD Dial command
ATH Hang up call
ATL Monitor speaker mode
ATM Monitor speaker mode
ATO Go on-line
ATP Set pulse dial as default
ATT Set tone dial as default
AT+CSTA Select type of address
AT+CRC Cellular result codes

DATA CARD CONTROL


Command Description
ATI Identification
ATS Select an S-register
ATZ Recall stored profile
AT&F Restore factory settings
AT&V View active configuration
AT&W Store parameters in given profile
AT&Y Select set as power up option
AT +CLCK Facility lock command
AT +COLP Connected line identification

Department of ECE, VBIT 37


Smart building using IR and IOT

presentation
AT +GCAP Request complete capabilities list
AT+GMI Request manufacturer
identification
AT+GMM Request model identification
AT+GMR Request revision identification
AT+GSN Request product serial number
identification (IMEI)

PHONE CONTROL
Command Description
AT+CBC Battery Charge
AT+CGMI Request manufacturer
identification
AT+CGMM Request model identification
AT+CGMR Request revision identification
AT+CGSN Request product serial number
identification
AT+CMEE Report mobile equipment error
AT+CPAS Phone activity status
AT+CPBF Find phone book entries
AT+CPBR Read phone book entries
AT+CPBS Select phone book memory storage
AT+CPBW Write phone book entry
AT+CSCS Select TE character set
AT+CSQ Signal quality

Department of ECE, VBIT 38


Smart building using IR and IOT

COMPUTER DATA INTERFACE


Command Description
ATE Command Echo
ATQ Result code suppression
ATV Define response format
ATX Response range selection
AT&C Define DCD usage
AT&D Define DTR usage
AT&K Select flow control
AT&Q Define communications mode
option
AT&S Define DSR option
AT+ICF DTE-DCE character framing
AT+IFC DTE-DCE Local flow control
AT+IPR Fixed DTE rate

SERVICE
Command Description
AT+CLIP Calling line identification
presentation
AT+CR Service reporting control
ATV+DR Data compression reporting

Department of ECE, VBIT 39


Smart building using IR and IOT

NETWORK COMMUNICATION PARAMETER


Command Description
ATB Communications standard option
AT+CBST Select bearer service type
AT+CEER Extended error report
AT+CRLP Radio link protocol
AT+DS Data compression

MISCEELANEOUS
Command Description
AT/ Re-execute command line
AT? Command help
AT*C Start SMS interpreter
AT*T Enter
AT*V Activate V.25bis mode
AT*NOKIA TEST Test command
AT+CESP Enter SMS block mode protocol

SMS TEXT MODE:


Command Description
AT+CSMS Select message service
AT+CPMS Preferred message storage
AT+CMGF Message format
AT+CSCA Service center address
AT+CSMP Set text mode parameters

Department of ECE, VBIT 40


Smart building using IR and IOT

AT+CSDH Show text mode parameters


AT+CSCB Select cell broadcast message types
AT+CSAS Save settings
AT+CRES Restore settings
AT+CNMI New message indications to TE
AT+CMGL List messages
AT+CMGR Read message
AT+CMGS Send message
AT+CMSS Send message from storage
AT+CMGW Write message to memory
AT+CMGD Delete message

SMS PDU MODE


Command Description
AT+CMGL List messages
AT+CMGR Read message
AT+CMGS Send message
AT+CMGW Write message to memory

Department of ECE, VBIT 41


Smart building using IR and IOT

CHAPTER 4: SYSTEM MODELLING AND DESIGN

4.1 Functional description

Fig 4.1: Functional decomposition diagram

The constituent parts involved in the process are

 Mobile phone
 Bluetooth module
 Arduino with Atmel Atmega328 microcontroller
 LCD display

First block portrays to be Bluetooth which receives, verifies and forwards the
message to the Microcontroller. Micro is the second block. Micro processes the message
and sends to the LCD. LCD behaving as the third constituent part displays the message
until it is invoked by micro to display a new message.

Department of ECE, VBIT 42


Smart building using IR and IOT

4.2 DATA FLOW DIAGRAM

Fig 4.4: Flow chart

Department of ECE, VBIT 43


Smart building using IR and IOT

The flow starts by initializing the ports of components. LCD is enabled and the
baud rate is set. The program module points out the AT commands that has to be
executed by the GSM. When micro reads these AT commands, it is sent to the GSM
module where the commands are processed. At this instance the messages are sent to the
micro so it can be displayed. The updating of messages is checked and if the sender is
valid the messages are stored. Any operation pertaining to the present result is performed.
Once the operations are performed the acknowledgement is sent. In the worst case
scenario if there are no new messages the loop of checking for new messages continues
until the new one arrives.

4.2.1 Architecture of the system

Fig 4.3: Architecture of the system

Architecture of the system consists of Microcontroller which involves in the operation


and validation. Regulated supply is to power up the whole circuit components. GSM modem

Department of ECE, VBIT 44


Smart building using IR and IOT

stores any message received by the user, any operation performed by the GSM is due to the AT
commands initiated by the microcontroller. Microcontroller forwards the message to the LCD.
LCD receives the message and can display only 16*2 characters at a time. Mobile is the end user
that starts the interaction with Bluetooth module by sending a message.

Department of ECE, VBIT 45


Smart building using IR and IOT

CHAPTER 5: IMPLEMENTATION

5.1 MICROCONTROLLER - LCD INTERFACING

Fig 5.1: Microcontroller – LCD interfacing

Fig 5.1 is the quite simple schematic. The LCD panel’s Enable and Register Select is
connected to the Control Port. The Control Port is an open collector / open drain output. While
most Parallel Ports have internal pull‐up resistors, there is a few which don’t. Therefore by
incorporating the two 10K external pull up resistors, the circuit is more portable for a wider range
of computers, some of which may have no internal pull up resistors.

There no effort to place the Data bus into reverse direction. Therefore we hard wire the
R/W line of the LCD panel, into write mode. This will cause no bus conflicts on the data lines.
As a result we cannot read back the LCD‟s internal Busy Flag which tells us if the LCD has
accepted and finished processing the last instruction. This problem is overcome by inserting
known delays into our program. The 10k Potentiometer controls the contrast of the LCD panel.
Nothing fancy here. The user may select whether the LCD is to operate with a 4‐bit data bus or
an 8‐ bit data bus. If a 4‐bit data bus is used, the LCD will require a total of 7 data lines.

Department of ECE, VBIT 46


Smart building using IR and IOT

If an 8‐bit data bus is used, the LCD will require a total of 11 data lines. The three controls
lines are EN, RS, and RW. Note that the EN line must be raised / lowered before/after each
instruction sent to the LCD regardless of whether that instruction is read or write text or
instruction. In short, you must always manipulate EN when communicating with the LCD. EN is
the LCD‟s way of knowing that you are talking to it. If you don’t raise/lower EN, the LCD
doesn’t know you’re talking to it on the other lines.

5.2 IMPLEMENTATION AT DIFFERENT PLACES

5.2.1 Overview

Information sharing holds an important role in the daily work of supermarkets, restaurants
and cafes etc,. The current means of information transfer are manually painted notice boards. This
makes the process very time consuming and inefficient. Looking into current trend of information
transfer, it is seen that important notice take time to be displayed in the notice boards. This latency
is not expected in most of the cases and must be avoided.

5.2.2 Proposal

It is proposed to place display boards at major access points. But, The Bluetooth based
display toolkit can be used as an add-on to these display boards and make it truly wireless. The
display board programs itself with the help of the incoming message with proper validation. The
centralized system can be placed as the Computer Center for access by any other valid users with
authentications. Message from these users is treated to be valid and is displayed. Other messages
from any other mobile phone is discarded. Thus information from valid sources can be sent
easily. Such a system proves to be helpful for immediate information transfer and can be easily
implemented.

Department of ECE, VBIT 47


Smart building using IR and IOT

CHAPTER 6: TESTING

6.1 INITIALIZATION

The baud rate of the module was set to be 9600 bps using the command
AT+IPR=9600.The ECHO from the module was turned off using the command ATE/ATE0 at
the hyper terminal. For serial transmission and reception to be possible both the DTE and DCE
should have same operational baud rates.

6.2 SERIAL TRANSFER USING Tx AND Rx FLAGS

After setting the baud rates of the two devices both the devices are now ready to transmit
and receive data in form of characters. Transmission is done when Tx flag is set and similarly
data is known to be received when the Rx flag is set. The microcontroller then sends an AT
command to the module in form of string of characters serially just when the Tx flag is set.
After reception of a character in the SBUF register of the microcontroller (response of module
with the read message in its default format or ERROR message or OK message), the Rx flag is
set and the received character is moved into the physical memory of the microcontroller.

6.3 VALIDITY CHECK & DISPLAY


To display the message on the LCD using the Android based smart phone, download Blue
Term application from Google Play Store. Run it and HC-05 Bluetooth module will be detected
by your smart phone. Pair your smart phone with HC-05. You can now type the desired message
on your smart phone, followed by pressing Enter for transmission to HC-05 connected to
Arduino. The message will be displayed on the LCD screen.

Department of ECE, VBIT 48


Smart building using IR and IOT

6.4 RESULTS

Snapshots

1. Welcome Note

Figure 6.1a: Snapshot of the System

Department of ECE, VBIT 49


Smart building using IR and IOT

2. Displays the Received Message.

Figure 6.1b: Snapshot of the System

Department of ECE, VBIT 50


Smart building using IR and IOT

Figure 6.1c: Snapshots of the System

Department of ECE, VBIT 51


Smart building using IR and IOT

CHAPTER 7: ADVANTAGES AND APPLICATIONS

7.1 ADVANTAGES

 As it's a Bluetooth wireless transmission system it has very less errors and needs
less maintenance

 Prevents unauthorized access of notice board (password for Bluetooth module).


 Multiple Users are authorized to update notices on the electronic notice board.

 No printing and photocopying costs. Thus saves time, Energy and finally
environment.


7.2 DISADVANTAGE


 It is applicable only for shorter distances around 100 meters range.


7.3 APPLICATIONS
 Advertisement Conference hall.

 Bus/Railway station.

 Any Public utility places.

 Educational institutions.

Department of ECE, VBIT 52


Smart building using IR and IOT

CONCLUSION

The prototype of the Bluetooth based display toolkit was efficiently designed.
This prototype has facilities to be integrated with a display board thus making it truly
mobile. The toolkit accepts the message, stores it, validates it and then displays it in the
LCD module. We intend to extend this work to provide a keypad programmed to allow
manipulation of the characters displayed on the screen. This future work will also explore
to the use of a bigger LCD with suitable hardware to manipulate and display graphics in
addition to the characters.

Department of ECE, VBIT 53


Smart building using IR and IOT

FUTURE SCOPE
The use of Atmel Atmega328 microcontroller in place of a general purpose
computer allows us to theorize on many further improvements on this project prototype.
Temperature display during periods wherein no message buffers are empty is one such
theoretical improvement that is very possible. The ideal state of the microcontroller is
when the indices or storage space in the Bluetooth memory are empty and no new
message is there to display. With proper use of interrupt routines the incoming message
acts as an interrupt, the temperature display is halted and the control flow jumps over to
the specific interrupt service routine which first pairs the user’s mobile phone Bluetooth
with Bluetooth module and then displays the information field. Another very interesting
and significant improvement would be to accommodate multiple receiver modules at the
different positions in a geographical area. After a display board receives the valid
message through the module and displays it, it withdraws its identification from the
network & synchronously another nearby module signs itself into the network and starts
to receive the message. The message is broadcast by the mobile switching center for a
continuous time period during which as many possible display board modules “catch” the
message and display it as per the constraint of validation.

Multilingual display can be another added variation of the project. The display
boards are one of the single most important media for information transfer to the
maximum number of end users. This feature can be added by programming the
microcontroller to use different encoding decoding schemes in different areas as per
local language. This will ensure the increase in the number of informed users. Graphical
display can also be considered as a long term but achievable and target able output.

Department of ECE, VBIT 54


Smart building using IR and IOT

REFERENCES

1. P. D. Minns, C Programming For the PC the MAC and the Arduino Microcontroller
System. Author House, 2013

2. M. Banzi, Getting started with arduino. " O'Reilly Media, Inc.", 2009

3. Arduino, "Arduino uno." Last visited on 06/09/2014

4. A. M. Gibb, New media art, design, and the Arduino microcontroller: A malleable tool.
PhD thesis, Pratt Institute, 2010

5. M. Margolis, Arduino cookbook. " O'Reilly Media, Inc.", 2011

6. D. Mellis, M. Banzi, D. Cuartielles, and T. Igoe, "Arduino: An open electronic


prototyping platform, " in Proc. CHI, vol. 2007, 2007

7. Shahrzad Tadjpour "A 900MHz Dual Conversion, Low-IF CMOS GSM Receiver"
Department of Electrical Engineering University of California 2001

8. Theodore S. Rappaport "Wireless Communications: Principles & Practice" Prentice


Hall PTR, 1996

9. http://electronicsforu.com/electronics-projects/hardware-diy/arduino-lcd-using-
bluetooth-module

10. H. Khalid, “Microcontroller Based LCD Display system”,


http://www.researchgate.net/.

11. https://static.secure.website/wscfus/5655211/4550650/v8n1-2p8-2015-ajocict-
prototyping-of-an-arduino-micro-controlled-digital-display-system.pdf

Department of ECE, VBIT 55


Smart building using IR and IOT

APPENDIX - A

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
String inData;
void setup(){
Serial.begin(9600);
lcd.begin(16,2);
lcd.print("Welcome!");
delay(3000);
lcd.clear();
}
void loop(){
int i=0;
char commandbuffer[100];
if(Serial.available()){
delay(100);
while(Serial.available()&&i<99){
commandbuffer[i++]=Serial.read();
}
commandbuffer[i++]='\0';
}
if(i>0)
Serial.println((char*)commandbuffer);
lcd.print((char*)commandbuffer);
delay(100);
lcd.clear();
}

Department of ECE, VBIT 56

You might also like