Android Controlled Light PDF
Android Controlled Light PDF
Android Controlled Light PDF
Dator Ottobrei G.
De Castro, Vianca Minette M.
Tawat, Gregorio S.
April 2016
ii
ABSTRACT
Manual switching of lights proves to be a drag in every class and often leads to
distraction not only in the part of students but also in the part of the instructor and often
leads to unnecessary usage of lights. This study tends to control the switching of the
lights using an android application and also, automatically turn off the lights if the count
reaches zero or there is no one in the room. The Bluetooth module is used to connect with
smartphone to control the lights wirelessly along with the IR sensor that count the person
entering and exiting the room. Prescriptive Model is the methodology used in the study.
The implementation proves to add convenience in controlling the switching of the lights
ACKNOWLEDGEMENT
The completion of this student research project would not be possible without the
assistance of other people. All their help and support regardless of its complexity is a
great contribution to the accomplishment of the paper. In line with this, we would like to
offer this endeavor to our Almighty God for the wisdom He bestowed upon us, the
strength, peace of mind and good health in order to finish this research. We also thank
our adviser, Engr. Stanley Aquino for his support and guidance throughout the research.
We also appreciate Engr. Francis Malabanan for giving his valuable comments and
A special thanks to the staffs of Tinkbox for assisting us in purchasing the hardware
part of the research. And lastly, we are grateful to our family, Guardino-Dator,
Magsumbol-De Castro, and -Tawat, for their undying moral support, for their
unconditional love and for their unending encouragement throughout the completion of
the paper.
iv
DEDICATION
First and foremost to the Almighty God who gives us strength and determination to
To our classmate who supports each other in times of happiness and hardships;
TABLE OF CONTENTS
Page
TITLE PAGE i
ABSTRACT ii
ACKNOWLEDGMENT iii
DEDICATION iv
TABLE OF CONTENTS v
LIST OF TABLES x
I. INTRODUCTION 1
Definitions of Terms 4
Research Design 15
Generation of Alternatives 19
vi
Evaluation of Alternatives 23
Project Design 29
Block Diagram 38
Person Detector 38
Wireless Controller 38
Light Controller 39
Flow Chart 40
Hardware Verification 42
Summary 64
Conclusions 65
Recommendation 66
vii
BIBLIOGRAPHY 67
APPENDICES 68
viii
LIST OF FIGURES
Page
LIST OF TABLES
Page
4.1. AT Commands 36
LIST OF APPENDICES
Page
A Prototype Pictures 69
B Source Codes 71
C Specification Documents 80
D Gantt Chart 86
E Curriculum Vitae 89
1
CHAPTER I
INTRODUCTION
Automation is today’s fact, where things are being controlled automatically, often
used to turn devices OFF/ON automatically. Automation lowers the human judgment to
the lowest degree possible but does not completely eliminate it making things easier and
more innovative.
Nowadays, smart phones are becoming more powerful with reinforced processors,
larger storage capacities, rich entertainment function and more communication methods
and one of the most popular platform for a smartphone is the “Android” operating system
which enables us to create software that runs on it and makes use of its features, such as
multi-touch screen, camera, accelerometer, GPS and Bluetooth. One of the most useful
features of a smart phone is its Bluetooth technology which is used for wireless data
transfer between Bluetooth enabled devices to exchange digital information over short
distances.
In this study, we tend to use an android device to control the lighting system in
automatically control the lights. Microcontroller, IR sensors and Bluetooth slave module
have been utilized. Microcontroller is used to control the lighting system in the
classroom. IR sensors were used to monitor the number of students in the classroom and
lastly, the Bluetooth module is used to communicate with the android device wirelessly.
2
The aim of this project is to design an app – controlled lighting system along with the
following objectives:
as an interface.
To know the advantages of using wireless devices to control the lights in the room
The purpose of the project is to provide a light control system for school’s
laboratory room that is implemented using the ARDUINO microcontroller using android
application as the interface. The system also includes a person counter to detect the
presence of people or a person in the classroom. The accessibility of the system is only
With the vast scope of the project come certain limitations. The system is limited
only to certain types of devices basically those with an android operating system. It is not
inclusive of other mobile devices such as an apple device or a windows device. Only one
3
mobile device can only be connected to the Bluetooth module. Using Bluetooth, the
system is limited only for certain distance. The person counter cannot support
simultaneous entering and exiting of a person. The person detection relies primarily on
The research project serves only the purpose of controlling the lighting system
To students and researchers. This study can serve as a reference for students
and researchers in interfacing an arduino to mobile device via Bluetooth. It also provides
information about systems that are useful for further and future studies.
lighting system in the classroom. Also it helps them monitor the security of the
classroom.
To the school community. This project helps in saving electricity and at the same
Definitions of Terms
For clearer understanding of the terms used in this research study, below are the
to replace the cables. With its low energy consumption and low cost, Bluetooth is
CHAPTER 2
This chapter presents the related literature and studies after the thorough and in-depth
search done by the researchers. All the technologies discussed in this chapter are further
used to support the implementation of the research. This chapter will also present the
The Microcontroller
single-chip computer. The word “Micro” suggests that the device is small, and the word
“controller” suggests that the device can be used to control objects, processes, or events.
microcontroller and its support circuits are often built into, or embedded in, the devices
ATxmega series (AVR architecture), AVR32 (32-bit AVR architecture), Intel’s 8086,
tiny computer that you can program to process inputs and outputs between the device and
external components you connect to it. The Arduino board is made up of an Atmel AVR
To program the arduino, the Arduino IDE, which is a piece of free software that
enables you to program in the language that the Arduino understands, is used. The IDE
enables you to write a computer program, which is a set of step-by-step instructions that
you then upload to the Arduino. The Arduino will then carry out those instructions and
interact with whatever you have connected to it. These programs are known as
“sketches”.
Duemilanove, Mega 2560, Mega ADK, Fio, Arduino,Ethernet, Mini, Nano, Lilypad, and
Bluetooth Arduinos. The choice of arduino board is based on the application. Figure 2.2
shows the gizduino board. The Gizduino is a microcontroller board based on the
Receiver/Transmitter”, is a serial communication which uses two lines for sending (TX)
Receiver/Transmitter) Master/Slave.
transmitted without the sender having to send a clock signal to the receiver. The sender
and the receiver, thus, must agree on timing parameters such as the baud rate before the
transmission and special bits are added to each word to synchronize the sending and
receiving units. The sender sends a Start bit, 5 to 8 data bits (LSB first), an optional
The start bit is to inform the data is about to send thereby forcing the clock in the
receiver to be in sync with the clock in the transmitter. The receiver and the transmitter
must have an identical baud rate. The individual bits are then being send beginning with
the Least Significant Bit (LSB). Stop bit will be sent to indicate the end of transmission.
If the Stop Bit does not appear when it is supposed to, the UART considers the entire
word to be garbled and will report a Framing Error to the host processor when the data
word is read. Transmitting and receiving UARTs must be set at the same baud rate,
character length, parity, and stop bits for proper operation. The typical format for serial
ports used with PC connected to modems is 1 Start bit, 8 data bits, no Parity and 1 Stop
bit. Figure 2.3 shows a basic UART packet format, 1 Start bit, 8 data bits, 1 Parity bit and
1 Stop bit.
Most microcontrollers including arduino uses the simplest UART format which is the
TTL (Transistor-transistor Logic) level UART to communicate with different ICs. Figure
more points that are not physically connected. Distances can vary depending on the
environment and technology used for the data transmission. This work focuses mainly on
According to Huang (2009), Bluetooth is a way for devices to communicate with each
other wirelessly over short distances. Every Bluetooth chip ever manufactured is
imprinted with a unique 48-bit address, which is referred to as the “Bluetooth address” or
“device address” so for one Bluetooth device to communicate with another, it must have
some way of determining the other device’s Bluetooth address. This address is used at all
layers of the Bluetooth communication process, from the low-level radio protocols to the
higher-level application protocols. Bluetooth devices will almost always have a user-
friendly name which is usually shown to the user in lieu of the Bluetooth address to
identify a device but it is the Bluetooth address that is used in actual communication. It
will usually take an average of 5 seconds before a device is connected to another device
frequencies more than a thousand times a second and there are only 79 possible
frequencies that it can transmit on. It divides the 2.4 GHz band into 79 channels and
employs channel hopping techniques so that Bluetooth devices are always changing
10
which frequencies they’re transmitting and receiving on. Many Bluetooth protocols are
used for communication of devices such as RFCOMM and L2CAP. Once a numerical
address and transport protocol are known, is to choose the port number. Table 1.1 shows
the transmission power levels. Table 1.2. shows the different classifications and their
range. Almost all Bluetooth-enabled cell phones, headsets, laptops, and other consumer-
maximum asymmetric (only one Bluetooth device is transmitting) data rate of 723.2
11
kilobits per second (kb/s) and a maximum symmetric data rate (both Bluetooth device is
transmitting) of 433.9 kb/s. Bluetooth devices is strongly limited by how far apart they
are.
Bluetooth Modules
and utility functions useful for the most common Bluetooth programming tasks.
Bluetooth modules can be classified in either a master/slave – only or a master and slave.
Two or more Bluetooth devices that are communicating with each other and using the
same channel hopping configuration (so that they’re always using the same frequencies)
form a Bluetooth “piconet”. In each piconet, there are a maximum of 8 devices connected
to it. .One device on every piconet is designated the master and the rest is the slave. The
master coordinates communication throughout the piconet. It can send data to any of its
slaves and request data from them as well. Slaves are only allowed to transmit to and
receive from their master. They can’t talk to other slaves in the piconet.
Android
Google, for mobile devices such as tablets, smart phones and PDAs. Android is an open
platform which means that this platform can be customized to fit a certain requirements
or real life applications. Android is that popular that there are approximately 300 million
activated android devices in the world. Looking at its architecture, the operating system is
Application framework, and Application layer. Each one has its designated functions.
The Application Framework layer lies on top of these layers and is the layer used by
Srirama et al., (2012) made a study that analyses and compares Smart homes
implementation. He tackles different smart home implementations and the medium used
in each implementation.
Wave, Android@Home, ZigBee and the domotichome. For choosing the best
Scalability, and cost must be considered. The cheaper the system the harder it is to install.
The more there are devices the more interference in the environment.
namely the Bluetooth and the Wi – fi. The system uses arduino and an android app for
communication medium of the system. Arduino was used because it is open hardware
and compared to other prototyping platforms it is the cheapest plus it has a strong and
Android was considered because of its popularity. In addition, Arduino is highly Android
compatible.
13
For the architecture of the project using Bluetooth, the study uses Arduino
and arduino modules such as the LED module for controlling the LED and the thermistor
module for sensing the temperature of the room. For the interface used for
communication of the android and arduino, the app called “Amarino” was chosen. It is an
for sending and receiving data via Bluetooth between an Arduino-based device and an
Android phone. The block diagram for the this communication is shown in figure 2.5. A
sketch that runs on the Arduino board uses the MeetAndroid library, which uses a serial
port of the Arduino to send and receive data to manage incoming and outgoing messages.
Identifiers such as integers, letters and alphabets are used for communication.
remote, mobile host controller and several client modules (home appliances) which
communicate with the host controller through Bluetooth devices. The result of this
the user to monitor and control different appliances connected over a Bluetooth network
devices. In their project, one device is associated with one Bluetooth module thus
increasing the controlling appliances also increases the needed Bluetooth module or one
device per one Bluetooth module is suggested. They also suggested the use of the
internet to integrate the design and to allow better control for the appliances.
15
CHAPTER III
RESEARCH METHODOLOGY
This chapter outlines the research methodology used in conduct of this study. This
Research Design
A Prescriptive research methodology was used for this study. This model
prescribes what must be done during the design process. This model includes five phases
of Schemes, Detailed Design and Design communication. Figure 3.1 shows each phase
As shown, the design stages are represented by rectangles with round corners and
other information. The study aims on designing and implementing an app – controlled
room lighting system that prevents unnecessary usage of room lights of unauthorized
students or teachers. The study also aims to give comfort in controlling the lights in the
classroom. The device has to detect the presence of students or teachers inside the
classroom and automatically turn the lights “off” when there is no student in the
prevent students from using classroom lights when they are not unauthorized to do so.
concepts. The conceptual design focuses on room light control system objectives,
with the smartphone. For person detection system, several sensors are considered as
Preliminary design. After the conceptual design is initiated, the chosen concept is
17
embodied with preliminary versions of their most important attributes. The chosen design
is modeled, analyzed, test and evaluated. The specific wireless communication and sensor
will be selected as the design implementation. Authorized personnel will access the
personnel to limit the usage of lights. A command will be sent to the device if automatic
control of lights will be initiated via smartphone. The sensor will then count the number
of person going in or out of the room. Once the count reaches zero, the lights will be
automatically turned off. The lights can be accessed again if exclusive personnel are to
Detailed Design. After the chosen design is modeled, analyzed, test and evaluated
the design is refined by working to optimize it. In detail design, the hardware
Detailed design for person detection includes two sensors which will be placed on the
door with one sensor followed by the other. If one sensor sensed first before the other, it
installed in a smartphone. The detailed design for the android application includes
command the light control to either turn on or off the lights. The serial information will
be the signal to transition from one state to another. The detailed design for light
Documentation. In this phase, the design process is presented in written report including
18
the resulting final design, and its fabrication specifications or prototyping specifications.
answer relevant questions and evaluate outcomes. In this section, the data collection
Document studies and observation are data collection methods that are used by
variety of interactions, and to openly explore the research topic. In particular, a structured
observation will be used as the researcher has some prior knowledge about problem. The
operations that are to be observed and the various features that are to be noted or recorded
are decided well in advance. It also produces a large quantity of data with relative case
and also, the observation can begin or stop at any time. Observation will be used to
perceived data. The lighting activity of the classroom will be observed and carefully
analyze if the changes to be made will be beneficial and practical. Document studies
personal papers, secondary data and multimedia. Documents related to the studies are
Table 3.1 shows the morphological chart developed for the generation of
alternatives. There are at least three possible means of implementing each of the desired
The features of this study include detecting the presence of students or teachers
inside the classroom and controlling the lights wirelessly using microcontroller. These
Global System for Mobile Communications (GSM) and Bluetooth. For human detection,
The OMRON D6T thermal sensor, PIR sensor and an IR – photodiode sensor module are
considered. Lastly, for controlling the lights, servo light switch flicker and relay is
considered.
communication to interface with the android smartphone and the microcontroller can be
implemented in several ways. The researchers considered three of the most used wireless
communication that can interface with the Arduino microcontroller. The implementations
smartphone includes a router and an Ethernet shield. The Ethernet shield which is
connected to a router provides IP for the Arduino which is used to connect to the internet.
The Wi – Fi Arduino library then allows the arduino to serve as either a server accepting
command requests between the microcontroller and the smartphone exchanges. The
smartphone application then sends a JavaScript Object Notation (JSON) request to the
HTTP which sends serial command to the microcontroller to control the external devices
connected to the microcontroller (i.e., relay switches). Several built – in applications for
connecting Arduino through smartphones are available like Blynk and DomoticHome.
Global System for Mobile Communications (GSM). For the implementation GSM to
interface with the microcontroller, a GSM Shield is required. The GSM shield along with
GSM library allows Arduino to place and receive voice calls, send and receive SMS, and
connect to the internet over a GPRS network. The GSM shield has a modem that transfers
data from a serial port to the GSM network. The modem executes operations via a series
of AT commands. The smartphone app can send data to GSM network which then the
library abstracts low level communications between the modem and SIM card and
translate information into a serial command to control devices like lights connected to the
Arduino.
smartphone includes a Bluetooth module. A Bluetooth module serves as the slave in the
piconet connection. The Bluetooth module (slave) accepts serial commands from the
21
Bluetooth module, sends serial information and the Bluetooth module translate this
the smartphone to allow Bluetooth communication between the smartphone and the
Person Detection. Person detection inside the classroom can be implemented using
different sensors. There are many sensors that can be used to detect the presence of a
person inside the classroom. Some of which are motion sensor, heat sensor, CO2 sensor,
face recognition and humanoid shape recognition. In this study, the researchers
follows:
OMRON D6T thermal sensor. This sensor uses thermal sensor to detect room
occupation by sensing the body heat. This sensor can be placed in the middle of the room
to detect human presence. This sensor has a wide range of detection and can easily detect
if there is a person or none even if they aren’t moving. This sensor has a digital output
that can be connected the microcontroller. Also, by connecting this thermal sensor into
an image or video capturing device, this sensor can tell where the person is in a specified
area.
Passive Infrared (PIR) Sensor. PIR sensors primarily sense motion, almost always used
to detect whether a human has moved in or out of the sensors range. This sensor is
22
sensitive to the infrared energy emitted by every living thing. When a person walks into
the detector’s field of vision, the detector “sees” a sharp increase in infrared energy
signaling that a person has passed. Two PIR sensors are needed for this implementation.
One PIR sensor is placed before the other. When one of the sensors detects motion before
Infrared Rays from a surface. A continuous beam of IR rays is emitted by the IR LED.
diode), these rays are reflected back and captured. Whenever an absorbing surface
(Black/No Obstacle) comes in front of the Receiver, these rays are absorbed by the
surface and thus unable to be captured. Like the PIR sensor, two IR-Photodiode sensor
will be used in for this implementation. One sensor is placed before the other. When one
of the sensors detects motion before the other it means that a person entered or exited.
Light Controller. The microcontroller outputs either high or low signal. The low signal
corresponds to 0 volts DC and the HIGH signal corresponds to 5 volts DC. The high
signal is not capable of turning an AC light bulb thus, a light controller is needed. Two
current that can turn on or off a much larger electric current. Relay is usually used along
with microcontroller because microcontroller outputs either HIGH (5V) or LOW (0)
signal. This small voltage can be used for switching relays that is connected to a load
23
requiring a high current. In this implementation, relay will be used to switch the lights in
the classroom.
Servo light switch flicker. Servo light switch flicker uses servo motor to flip the light
switch “on” or “off”. It uses the capability of a servo motor to rotate in 180 degrees to
Evaluation of Alternatives
In this section, alternatives that are considered are compared and evaluated to
implement the best design. The advantages and disadvantages of each alternative is
considered and compared. The priority checkmark method for the evaluation of
the numerical evaluation matrix. Objectives with high priority are given three checks;
those with medium priority are given two checks, while objectives with low priority are
communication, the cost, the range and the place of installation is considered.
The main advantage of using the internet as the implementation for wireless
everywhere as long as there is an internet connection. The module also has a considerable
price. On the other hand, this implementation requires a router which almost every
classroom lacks. Also, implanting this with a router connected to the AC supplied
24
contradicts one of the objective which is reduction of power consumption. Also, because
it is connected to the internet other unauthorized device anywhere can also send and
The main advantage of using the GSM is it provides a wide scope in controlling
things remotely from any place by just sending an SMS. GSM also provides ease to
easily communicate in a more robust way. Also, the GSM module allows the
microcontroller to be connected to the internet via GPRS. One of the major drawbacks
from using GSM is its cost. One of the most important factors for implementation of a
device is its cost. The GSM module is relatively expensive compare to other.
is the ease of connection and the cost. The Bluetooth module can be connected to a
smartphone in less than a minute by just pairing the smartphone and the Bluetooth
communication is cheaper compared to other two. The main disadvantage of using this is
the range of connectivity between the Bluetooth module and the smartphone. Also, one
the GSM module is the best among the alternatives in terms of functions, Bluetooth
module is chosen as for prototyping purposes. It is much cheaper compared to other two
25
alternatives and appropriate for prototyping. Also, its one to one connectivity and
password ready capability is suitable for the operation of the design. It is also easier to
establish connection between the Bluetooth module and the smartphone. Table 3.2 shows
the priority benchmark of the three alternatives. As shown, the GSM module and the
Table 3.2 Priority benchmark of the chosen alternatives for wireless interface
Person Detection. For person detection, accuracy, cost and availability of devices are
The OMRON D6T thermal sensor can detect human presence inside a room in a
wide scope. The main advantage of using this thermal sensor is its capability to detect
person with ease in a wide scope. Once placed in an area, this thermal sensor can detect a
person based on its body temperature. The main disadvantage for using this sensor is its
availability. This sensor is produced abroad and not yet available in this country.
The PIR sensor has a great advantage in terms of cost and availability. This sensor
are small, inexpensive, low-power, easy to use and don't wear out. For that reason they
26
are commonly found in appliances and gadgets used in homes or businesses. The
disadvantage in using this sensor is that it only detects motion. Once the person is still,
the PIR sensor will not trigger, hence, there will be an inconsistency in detection. When
used in counting, the PIR sensor is not accurate due to its wide scope and time delay.
The last sensor considered is the IR – Photo Diode sensor. This sensor is capable
of detecting object in front of it. When used in this study, the IR – Photo Diode sensor be
used to detect a person passing in front of it and can be used to count the person entering
or exiting the room. Also, this sensor is cheaper compared to PIR and Omron thermal
sensor. Like the PIR sensor, the IR – Photo Diode sensor can be inaccurate when
Among the alternatives, the OMRON D6T thermal sensor is the best alternative
considered but IR – Photo diode sensor is preferred to use for person detection in this
study. Although the OMRON D6T thermal sensor is the most accurate among the
the cost, the PIR sensor and the IR – photo Diode sensor are both cheap and can be used
for prototyping purposes but IR – Photo diode sensor is more accurate than the PIR
sensor.
27
The priority benchmark suggest that OMRON D6T is also the best among alternatives as
shown in table 3.3. The OMRON D6T and IR sensor complies with the three alternatives
as shown in the total number of checks. In terms of accuracy and range, the OMRON
Light Controller. After evaluating the alternatives for person detector and wireless
voltage. Aside from being a low cost device, it does not affect other devices connected in
the circuit. One disadvantage of using relay is the danger in operating such currents.
Although relay is isolated, there is always a risk involve in operating large currents.
Servo light switch flicker eliminates the risk of operating large currents or
voltages. The servo motor will flip the switch in either on or off direction. One
28
disadvantage of this device is that it is only exclusive for specific type of switch. Also,
the servo motor is complicated and hard to control. It is also more expensive than relay
For light controller, the servo light switch flicker is chosen. Aside from the being
safer than relays, it can be implemented in real classrooms. Because the rooms have
identical standard switches, one standard switch is only considered. For prototyping
purposes, the relay is used for it is much cheaper than the servo light switch flicker but
CHAPTER IV
TECHNICAL STUDY
This chapter covers the technical specifications of the design as well as its
implementation.
Project Design
The whole system is divided into two major parts namely: the central control
system and the wireless controller system. The central control system is composed of the
light controller system and the person detection system whereas the wireless controller
system is composed of the bluetooth module and the android application. The main
algorithm of the design is procesed by the the central control system that receives all the
incoming inputs coming from external devices. A block diagram showing the input and
As shown, the central control system accepts input from Bluetooth module and person
detector and gives command to the light controller to control the lights in the room. The
smartphone gives serial command to the central control system to turn the lights on or off
wirelessly. The person detector detects the number of person coming in or out of the
room. If the count becomes zero, the central control system will automatically turn the
lights off.
The main devices used in the system are microcontroller specifically gizduino, IR –
Photo Diode sensor, Bluetooth module and android smartphone. The microcontroller
accepts input from the Bluetooth module and the IR – photodiode sensor and gives
Central Control system. The central control system is composed of two major
parts namely the light controller system and the person detection system. These parts are
Gizduino. The gizduino microcontroller will accept inputs and output commands to
control the lighting system. Figure 4.3 shows the a Gizduino X board. It is the latest
board. As shown in figure 4.4 ,the board offers 54 I/Os, 3 hardware SPI, 2- hardware
IR – Photo Diode Sensor. IR – Photo Diode Sensor will be used to determine the
number of person in the room to automatically turn the lights on or off. The sensor works
on the principal in which IR LED emits IR radiation and Photodiode sense that IR
on it, hence the voltage drop across it also changes and by using a voltage comparator,
IR LED and Photodiode can be place in two ways: Direct and Indirect. The
direct and indirect incidence is shown in figure 4.5 and 4.6 respectively. As shown, IR
LED and photodiode are kept in front of one another, so that IR radiation can directly
falls on photodiode. If an object falls between them, the falling of IR light on photodiode
stops. Whereas, in in Indirect Incidence, both the IR LED and Photo diode are placed in
parallel (side by side), facing both in same direction. When a object is kept in front of IR
pair, the IR light gets reflected by the object and gets absorbed by photodiode.
Figure 4.7 shows the circuit for IR photo diode sensor. As shown, the Photo
diode is connected in reverse bias, inverting end of LM358 is connected to the variable
resistor, to adjust the sensitivity of the sensor and the non-inverting pin of the op – amp is
connected to the junction of photodiode and a resistor. When a person passes in front of
the IR pair, then IR emitted by IR LED is reflected by the object and absorbed by the
photodiode. When the reflected IR Falls on Photodiode, the voltage across photodiode
drops, and the voltage across series resistor R2 increases. When the voltage at Resistor
R2 gets higher than the voltage at inverting end, then the output becomes HIGH signaling
Wireless controller system. The wireless controller system is composed of the android
app and the Bluetooth module. The Bluetooth module is used to connect wirelessly with
Bluetooth Module HC – 05. HC-05 module is an easy to use Bluetooth SPP (Serial Port
Protocol) module, designed for transparent wireless serial connection setup. Bluetooth
serial module is used for converting serial port to Bluetooth. These modules have two
modes: master and slaver device. The HC – 05 can be configured as slave or a master
module. Bluetooth module HC – 05 is shown in figure 4.8. The slave modules can not
initiate a connection to another Bluetooth device, but can accept connections, when in
master mode the module can initiate a connection to other devices. In this design, the
researchers only use the Bluetooth module as slave. The specifications of the Bluetooth
Modulation: GFSK
The HC-05 Bluetooth Module has 6 pins namely the Vcc, GND, TX, RX, Key,
and LED. It comes pre-programmed as a slave. The range for Bluetooth communication
is usually 30m or less. The module has a factory set pin of “1234” which is used while
pairing the module to a phone. To change the default password to make the connection
more secure, the module needs to be configured by going into the AT Command mode.
This is done by connecting the KEY pin to a digital pin and sending AT commands. The
commands for configuring the baud rate, the Bluetooth module name and the password is
shown in table 4.1. The connection of the Bluetooth module to the microcontroller is
shown in figure 4.7. A voltage divider is placed in the TX pin of the microcontroller
going in the RX pin of the Bluetooth module to limit the voltage to 3.3 Volts since the
Command Info
1 – 1200
2 – 2400
3 – 4800
4 – 9600
5 – 19200
6 – 38400
7 – 57600
8 – 115200
9 – 230400
A – 460800
B – 921600
C – 1382400
MIT app inventor. To create the application for the smartphone, the MIT app inventor is
used as it requires little knowledge in JAVA programming. The layout platform and the
block diagram platform of the MIT inventor is shown in figure 4.8 and 4.9. In layout
platform, all the buttons and the designs for the app are placed whereas, in the block
diagram platform, the functions needed for the app to operate is created.
Block Diagram
The block diagram for person detector is shown in figure 4.10. As shown, two
sensors are placed as implemented to count the person going in and going out of the
room.
The block diagram for wireless controller is shown in figure 4.10. As shown,
the transmitter pin of the Bluetooth module is connected to the receiver pin of the
microcontroller.
39
The flowchart showing how the entire system will operate to control the lighting
system in the classroom is shown in figure 4.13. As shown, the user needs to connect to
the system using a smartphone with Bluetooth capability using the application installed in
the smartphone. The smartphone can then control the lights by sending serial commands
in the microcontroller. The commands are hidden in the block diagram of the buttons
available in the app. The user can command the light controller to automatically turn off
State Machine
The state diagram of the system is shown in figure 4.14. As shown, the system
comprises of four states namely, the “not connected” state, the “connected”, “automatic”,
“lights on”, “lights off” state. The first state is the “not connected” state where no
the system goes in the connected state. When in this state, the lights can be turned either
by giving the automatic mode command. This allows the device to monitor the presence
of a student in the room. When the count of student reaches zero, the device will go on
“lights off” state. When in “lights on” or “lights off” state, the lights can still be control.
41
In any state, the smartphone can be disconnected returning back to the “disconnected”
state.
Hardware implementation
The hardware implementation for the device is shown in figure 4.15. The front
and back door light installation is shown. As shown, the light controller is located besides
the back door along with a sensor module and the Bluetooth module to count the number
of person exiting the room. The light sensor is to be placed at the light switch to control
the lights. One IR sensor is then placed at the front part of the door to count the number
Hardware Verification
This section includes the verification plan for hardware implementation of the
system. This includes the test plan for the design. The verification focuses on the
accuracy of the person detection. Two IR – photodiode sensor will be placed with one
sensor following the other. The IR sensor will be tested in certain distances and the count
will be monitored via serial monitor available in the arduino IDE. The Bluetooth
connection range will also be tested to evaluate the distance of control. Lastly, the
android application will be tested by sending serial information and observing the
CHAPTER V
This chapter presents and analysis results of different test cases implemented to
smartphone to the microcontroller. The connection range of the module is tested first to
be determined its limitations in terms of connection and control range. Table 5.1 shows
the result in testing the connection range of the module. The test consists of 7 trials and
each trial has different distances. The Bluetooth module is powered by a microcontroller
device. Once the device is paired with the Bluetooth module, the android application can
control the lighting system in the classroom through the android application. Table 5.1
shows the range of connection of the Bluetooth device. HC – 05 datasheet indicates that
the distance that the device can be connected to another Bluetooth device is 30 feet or
approximately 10 meters but table 5.1 shows that when in 30 feet range, the connection
5 25’ Strong
6 30’ Weak
7 35’ No connection
Bluetooth module connection limit. The number of devices that can connect to the
Bluetooth module is also tested. This test is conducted to determine if more than one
device can be connected to the Bluetooth module. Table 5.2 shows the result of the test
conducted for testing the limitation of the number of devices the HC – 05 can be
connected with. As shown, the number of devices that can be connected in the Bluetooth
module simultaneously is only limited to one. It means that the system can be
Number of
Can be
Trial Devices at the
connected?
same time
1 1
2 2 X
3 3 X
4 4 X
5 5 X
Bluetooth connection time. For Bluetooth connection time, different android devices
including smartphones and tablets are tested and the time for connection is determined.
The result is shown in figure Table 5.3. As shown, the test consists of five trials.
in each test and the time of connection is recorded. Based on the result, the time of
connection is almost identical to every device. Each device can successfully connect to
45
the Bluetooth module. It means that, almost every device with Bluetooth capability can
connect to the system. The Lenovo (A5000) is chosen to be used for testing the features
of the system as it acquires the fastest connection time and its updated android Operating
system.
Time of
Trial Device
connection
1 Myphone (A848) 3s
Lenovo (Tab2
2 3s
A7-30H)
3 Samsung () 3.5s
Lenovo
4 2.5s
(A5000)
5 Alcatel 3.5s
is also tested to determine how long the device can stay connected to a smartphone. The
test is conducted by keeping an uninterrupted power supply in the Bluetooth module and
connecting it to an android device given the device will not close the Bluetooth
connection. The result is shown in table 5.4. After 30 minutes, the connection status is
checked. There are six periods in this test which corresponds to three hours. This time is
set according to the maximum length one class. As shown, there is no interruption in the
Connection
Time
status
0
46
After 30 minutes
After 1 hour
After 1 hour and
half
After 2 hours
After 2 hours and
a half
After 3 hours
The key part of making this design work is the transfer of serial information from
the smartphone device to the microcontroller. This means that, testing the program of the
microcontroller using the built – in serial monitor in the “Arduino” application is a must
before testing the device using the created android application. The Arduino serial
monitor is used for communication between the Arduino board and a computer or other
devices. The built – in serial monitor is used for verifying codes created by observing
outputs that were force to display in the serial monitor to check if the code goes to a
certain state.
In our design, the main component is the exchange of serial information from the
smartphone to the microcontroller. In these tests, the serial monitor will act as the android
application by sending serial commands to the microcontroller. The researchers then will
In our design, three lights are chosen to be controlled. In this test, the lights are
represented by LEDs. The sample serial monitor output is shown in figure 5.1. The table
showing the response of the system in different serial commands is shown in table 5.5.
47
As shown in figure 5.1, the serial monitor output the response of the device in certain
inputs. An input of ‘a’ will turn the first light ON and input of ‘b’ will turn it OFF. Inputs
‘c’ and ‘d’ will turn the light 2 on and off respectively. Inputs ‘e’ and ‘f’ will turn the
light 3 on and off respectively. The command ‘y’ enables the “automatic mode” of the
device whereas the command ‘n’ disables it. As shown in the figure 5.2, as observed,
the program accepts two or more characters and still recognized the commands even
without a delimiter. This characteristic is helpful in making the android application as the
Table 5.5 shows the system response in consecutive inputs. The tested system has a count
of zero, or no person has entered the room. As shown, each light can be switched on and
off separately and independent from each other. Also, as shown in the result, while in
“Manual” mode, the lights can be switched on or off regardless of the count. Enabling the
49
“automatic” mode switches off the lights when the count is zero as assumed. The lights
cannot be turned off or on when the count approaches to zero unless the ‘n’ command is
sent again or when someone entered the room that will increase the count. The lights
however can be turned on or off when in “automatic” mode when the count does not
reach zero.
The person counter system is also tested using the serial monitor first. The IR sensor is
replaced first by two push buttons as the concept for detection is similar. The IR sensor
will be tested separately. This test is conducted to determine if the program is functioning
Table 5.5 summarizes the result of the test involving the person detection system. The
sensor sends a HIGH signal when triggered an object or a person passed in front of it, and
LOW signal when there is no obstacle in front of it. This characteristic leads the
researchers to use the interrupt concept for counting the person. The interrupt is triggered
at RISING edge meaning if the signal change from HIGH to LOW, the sensor is
triggered. Table 5.6 summarized how the system works. If the sensor 1 is triggered first
than the second, it means that, a person has entered and the count is increased by 1.
Otherwise, if the sensor 2 is triggered first than the second, it means that a person has
exited the room and the count is decreased by 1. If one sensor is triggered but not the
other, it means that the person does not enter nor exit and the previous count is retained.
Lastly, if one sensor is triggered many times but not the other the previous count is also
The range and the accuracy of the IR sensor will be tested in this section. Two
configurations of the IR sensor is considered namely the Direct and Indirect. In Direct
incidence, In Direct incidence, IR LED and photodiode are kept in front of one another,
so that IR radiation can directly falls on photodiode. If an object is placed between them,
51
then it stops the falling of IR light on photodiode. In indirect incidence, both the IR LED
and Photo diode are placed in parallel (side by side), facing both in same direction. In that
fashion, when a object is kept in front of IR pair, the IR light gets reflected by the object
and gets absorbed by photodiode. Figure 5.4 shows the Direct Incidence while Figure 5.5
Table 5.6 shows the distance the distance between the photodiode and IR LED
must be in order to detect obstacle passing by. As shown, when the photodiode and IR
LED is 22 inches apart or less, it can detect object passing between it. More than that
distance, the IR LED and the photodiode no longer communicate. Table 5.7 shows the
testing of the distance the direct incidence can cover. As shown, it covers only a very
52
short distance. When the distance between the object and the photodiode exceeds 3
Figure 5.7 and 5.8 shows the implementation considering the two configuration of
the IR Photodiode sensor. As shown, implementing the system in real application, the
distance between the IR LED and photodiode sensor when implemented as an indirect
incidence must be 2.3 feet. This measurement is based on width of the door opening in
FAITH rooms. When implemented as indirect incidence, the minimum distance that the
IR sensor must cover is 5.8 inches base on shoulder width of a person. The shoulder of
the person is considered because it is the widest part of the body. The result shown in
table 5.6 does not meet the target 2.3 feet but its range is enough and can be used to
detect the presence of a person. However, when indirect incidence is used, the system
cannot be used as a person detector. With this results, the direct incidence is chosen as the
implementation. Figure 5.8 shows the maximum distance the IR sensor can be
configured to detect a person passing. As shown, the two LEDS is still ON indicating that
18
20
21
24 (2 feet)
Table 5.9 shows the result of testing the IR sensor for person counter. Object is
used to represent a person. Each object is given 10 seconds, 5 seconds and 2 seconds
interval before the next object will pass. The trial consists of 4 trials with different
55
distances as shown. The two IR sensor is separated by 5’’. Table 5.10 shows the result for
same test but the two IR sensors is separated by 10’’. Table 5.11 shows the result for
same test but the two IR sensors is separated by 20’’. The object with a width of 2.4’’ is
2 10’’ 10 10 8 6
3 15’’ 10 10 8 7
4 21’’ 10 10 8 6
Observing the results of these tests, there are two factors to consider namely the
interval time between each object and the distance of two sensors. As shown in table 5.8,
in 10 seconds interval, the count is accurate, but decreasing the time interval to 5 seconds
or 2 seconds, the count became inaccurate. Decreasing the time interval to 5 seconds, the
count is slightly accurate to that of the actual count. In two second interval, the count is
delayed by almost 1 count per object meaning the count is almost only half of the actual
count. This is because the program is set to response to person not continuing to enter or
exit the room. The program is set such that for example, the sensor 1 is triggered but
sensor two is not triggered, the program will wait for 5 seconds for the sensor two to
trigger and if so, the count will increase, otherwise the count will refresh and ignore that
sensor 1 is already triggered. This suggests that sensor is not applicable to high speed
application. Table 5.9 shows more accuracy than that in table 5.8 due to the fact that the
distance is increased but in two second interval, the count is still inaccurate and almost
did not change. Table 5.10 shows much more accuracy in 10 second and 5 second
interval but the two second interval did not improve much. Observing the result, the
Distance between IR LED and photodiode Sensor is not really a factor as the count is
precise so the distance of 21’ between the IR LED and photodiode sensor is chosen as the
implementation for it occupies larger space. Considering the distance between the two
sensors, 20’’ is the best distance in terms of accuracy but considering the width of the
57
side of the door, the 10’’ distance is chosen. Observing the response of the system, the
system is not applicable in situations where the time difference between two people
entering or exiting is short. Also, the photodiode sensor and the IR LED should be align
Figure 5.9 shows the android application created using the MIT app inventor. It
consists of five buttons. The Bluetooth button is use to connect to the HC – 05 module
while the three buttons is use to control the switching of lights. The Automatic mode
button is used to allow automatic mode or disable automatic mode. In this test, the serial
monitor in the laptop displays the commands sent by the smartphone. The sample testing
Table 5.12 shows the the result of testing the android application using the serial
monitor by displaying the result in serial monitor. As shown, when the light 1 button is
clicked when the button display “ON”, the command sent is ‘a’ meaning the light 1 will
turn on. When the light 2 button is clicked when the button display “ON” light 2, the
command sent is ‘b’ and light two will turn on and same goes to light 3 button but this
time command ‘c’ is sent. Otherwise, if the button display is initially “OFF” the process
will be reversed. Lastly, when the automatic mode button displays “ALLOW” initially,
command ‘y’ will be sent otherwise, command ‘n’ is sent. Also, when opening the app,
the display button is set to “ON” for three buttons and “ALLOW” for automatic mode
button.
59
after
Light 1 ON a OFF
Light 2 ON c OFF
Light 3 ON e OFF
Light 1 OFF b ON
Light 2 OFF d ON
Light 3 OFF f ON
The prototype consists of model of classroom, one AC LED bulb, two 5 Volts DC
LED, the relay module, the Bluetooth module, two PIR sensors and the microcontroller.
The relay module is used as the controller of the LED bulb. A relay is an electrically
operated switch that allows you to turn on or off a circuit using voltage and/or current
much higher than the Arduino could handle. There is no connection between the low
voltage circuit operated by Arduino and the high power circuit. The relay protects each
circuit from each other. The two IR sensors are placed before the door to model the
counting system. The lights are placed at the roof the room model. Table 5.13 shows the
60
disabled. As shown, gray code is used to cover all possible scenarios. The result shows
that the three lights can be controlled independently. Table 5.14 shows the results of
testing the counter in 10 trials. Each trial, 8 objects entered the room. The actual count of
the object that has entered is compared to the count shown in the app. As observed, the
actual count does not match the count shown in the app. A test is also conducted when
the objects exits the model. Table 5.15 shows the result of that test which also consists of
10 trials and each trial is a continuation of the previous test. As shown, 8 objects have
exited and the count is zero which matches that of the count shown in the app. This is
because; the program does not accept negative numbers. Meaning, if the count reaches
zero, the count is no longer decremented. Although in final count, the actual count and
the count shown in the app is equal, table 5.16 and 5.17 shows the effect of incorrect
exiting count. Another test is conducted and from time to time, the actual count is
monitored. Two tests were conducted for verification. The system is switched to
“Automatic” mode. As shown, the count is already zero in the app and the lights turned
off even if the actual count does not reach zero. The result shows the inaccuracy of the
IR sensor as the sensor for person counter but the data shown are precise.
61
CHAPTER VI
This section contains the summary, conclusions and recommendation based on the test
Summary
Manual switching of lights proves to be a drag in every class and often leads to
distraction not only in the part of students but also in the part of the instructor. Also,
manual switching of lights often leads to unnecessary usage of lights due to some
students using the classroom along with the lights in their vacant period. Due to these
situations, controlled switching of lights is necessary and this leads the proponents to
along with person counter to monitor the presence of students in the room to
The function of the study is to control the switching of the lights using an android
application and also, automatically turn off the lights if the count reaches zero or there is
no one in the room. These functions are accomplished by the use of Bluetooth module,
the MIT app inventor and the IR Sensor. The Bluetooth module is used to connect with
smartphone to control the lights wirelessly. The IR sensor is used to count the person
entering and exiting in the room to automatically turn off the lights. A developed android
application is used to interface with the Bluetooth module to give serial commands to the
Conclusions
After analysing the results gathered using several tests, the researchers were able
to conclude that:
The advantage of using wireless devices such as smartphone to control the light
switching is the ease of installation and convenience in the part of the user.
IR sensors can be used to detect the presence of students or teachers in the room
by using it as a counter.
The usage of lights can be made exclusive to certain personnel by the use of
android application such that only allowed personnel is able to use the android
application and can be connected to the light controller that can minimize
Recommendation
For future researchers of the study, the proponents recommend to consider the
following:
WI – Fi can be used.
counter/detector is recommended.
BIBLIOGRAPHY
Retrieved from:
http://people.csail.mit.edu/rudolph/Teaching/Articles/BTBook.pdf
Retrieved from:
https://www.bookdepository.com/Microcontroller-Idea-Book-Jan-
Axelson/9780965081900
Retrieved from:
https://pdfs.semanticscholar.org/a001/5665acb00ddf1491aec436e47cfb75835b82.pdf
Retrieved from:
https://comserv.cs.ut.ee/home/files/thesis.pdf
Retrieved from:
https://schoology.com
68
APPENDICES
69
APPENDIX A
Prototype Pictures
70
71
APPENDIX B
Source Codes
pinMode(3, INPUT);
attachInterrupt(1, entering, RISING);
pinMode(21, INPUT);
attachInterrupt(2, exiting, RISING);
Timer1.initialize(500000);//0.5ms
Timer1.attachInterrupt(count_second);
}
void count_second ()
{
Serial.println(count);
}
void loop() {
if (Serial.available() > 0)
{
state = Serial.read();
}
if (state == 'a') {
if (allow_automatic == 0 || (allow_automatic == 1 && count > 0))
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
}
73
if (person == 2)
{
count ++;
Serial.println(count);
person = 0;
}
else if (person == 1)
{
count --;
74
void entering()
{
if ((millis() - previous_millis) > 300)
{
previous_millis = millis();
if (ex == 1 && ((millis()- previous_exit) < 5000))
{
person = 1;
ex = 0;
}
else
{
enter = 1;
previous_enter = millis();
}
}
}
void exiting ()
{
if ((millis() - previous_millis) > 300)
{
75
previous_millis = millis();
if (enter == 1 && ((millis()- previous_enter) < 5000))
{
person = 2;
enter = 0;
}
else
{
ex = 1;
previous_exit = millis();
}
}
}
//for testing
pinMode(3, INPUT);
attachInterrupt(1, entering, RISING);
76
pinMode(21, INPUT);
attachInterrupt(2, exiting, RISING);
Timer1.initialize(500000);//0.5ms
Timer1.attachInterrupt(count_second);
}
void count_second ()
{
// Serial.println(count);
}
void loop() {
if (Serial.available() > 0)
{
state = Serial.read();
}
if (state == 'a') {
if (allow_automatic == 0 || (allow_automatic == 1 && count > 0))
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led2, LOW);
Serial.println("Input: 'd':Light 2 is OFF");
state = 'j';
}
if (person == 2)
{
count ++;
Serial.write("A person has entered Count: "); Serial.println(count);
person = 0;
}
else if (person == 1)
{
count --;
if (count < 0 ) count = 0;
Serial.write("A person has exited Count: ");Serial.println(count);
person = 0;
}
78
void entering()
{
if ((millis() - previous_millis) > 300)
{
// Serial.println("sensor 1, triggered");
previous_millis = millis();
if (ex == 1 && ((millis()- previous_exit) < 5000))
{
person = 1;
ex = 0;
}
else
{
enter = 1;
previous_enter = millis();
}
}
}
void exiting ()
{
if ((millis() - previous_millis) > 300)
{
//Serial.println("sensor 2, triggered");
previous_millis = millis();
if (enter == 1 && ((millis()- previous_enter) < 5000))
79
{
person = 2;
enter = 0;
}
else
{
ex = 1;
previous_exit = millis();
}
}
}
80
App Code
81
82
83
84
85
86
APPENDIX C
Schematic Diagrams
87
88
89
APPENDIX D
Device specifications
90
91
92
93
94
95
use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial
connection setup. Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR
(Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and
baseband. It uses CSR Bluecore 04-External single chip Bluetooth system with CMOS
technology and with AFH(Adaptive Frequency Hopping Feature). It has the footprint as