Smart Building
Smart Building
Smart Building
CHAPTER 1: INTRODUCTION
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
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.
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.
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.
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.
From Fig 2.1, there are at least four interfacing circuits, Wi-Fi module, Arduino-
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.
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
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:
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
dule, chip,
and the software on it, as well as to translate the Chinese document
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
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.
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.
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.
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.
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.
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
3.2.2 Features
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.
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
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
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:
3.8.2 Wiring
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.1 Processing
3.10.1 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.
Embedded systems often have the real-time constraints, which is usually not
there with desktop computer applications.
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.
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-
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)
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.
PROGRAM COMPILING
SELECTING BOARD
SELECTING PORT
UPLOADING PROGRAM
Arduino programs can be divided in three main parts: structure, values (variables
and constants), and functions.
void
boolean
char ( 0 – 255)
float
double
String - object
array
3.11 AT COMMANDS.
The Hayes subset commands are called the basic commands and the commands
specific to a Bluetooth network are called extended 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
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
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
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
For example,
ATD123456789
7) ATH - This command is used to disconnect remote user link with the GSM module.
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.
Command Description
AT Checking communication between
the module and computer.
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
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
SERVICE
Command Description
AT+CLIP Calling line identification
presentation
AT+CR Service reporting control
ATV+DR Data compression reporting
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
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.
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.
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.
CHAPTER 5: IMPLEMENTATION
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.
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.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.
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.
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.4 RESULTS
Snapshots
1. Welcome Note
7.1 ADVANTAGES
As it's a Bluetooth wireless transmission system it has very less errors and needs
less maintenance
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.
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.
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.
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
4. A. M. Gibb, New media art, design, and the Arduino microcontroller: A malleable tool.
PhD thesis, Pratt Institute, 2010
7. Shahrzad Tadjpour "A 900MHz Dual Conversion, Low-IF CMOS GSM Receiver"
Department of Electrical Engineering University of California 2001
9. http://electronicsforu.com/electronics-projects/hardware-diy/arduino-lcd-using-
bluetooth-module
11. https://static.secure.website/wscfus/5655211/4550650/v8n1-2p8-2015-ajocict-
prototyping-of-an-arduino-micro-controlled-digital-display-system.pdf
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();
}