Building Management System
Simulation of lighting control and fire detection systems using Arduino for a small sized library

By Andrei-Octavian Ciozvarda-Diaconescu
Supervisor: Chi Nguyen

Project Journal (logbook)

Project definition:
This project will design and implement a device to monitor building parameters and that issue system updates and messages.
The device will use the Arduino open source hardware platform. The design will include inputs from multiple sensors, e.g. temperature and motion. The device will store the data from the sensors and use them as input to system monitoring and management algorithms. A limited set of parameters will be adjustable on the device and more parameters will be adjustable using the computer or online user interface. The algorithms will produce alerts and messages using the SMS text format, e.g. when sensor values exceed threshold parameters.
A prototype system will be developed with sample input sensors and SMS alerts. The final report will include analysis of the prototype design and performance profile.

From the definition it can be seen that the projects aims are to research the Building Management Systems (BMS) domain in order to analyze
the algorithms used and with this knowledge the next step is to research/observe/survey a location in order to produce my own algorithms
for the sensors that I will implement on the Arduino board. The final part is to find a solution that will provide an indication of the system
performance. A project plan according to the marking scheme is attached below:


This journal is in chronological order. In order to see the last update you must scroll towards the bottom of the page
Also research was made during the entire period.


I started working with Arduino and understand how it works.

Uploaded today few pictures showing the process of understanting how an Arduino board is working. The programing language seems not to be very hard and controling digital outputs is easy. Also worked with delays and multiple outputs and digital inputs. This goal of these experiments were to make me understand of how the whole process of programing, sending to Arduino the program and runing the program on the board should take place. I am also adding a picture with one of these simple programs that I created.


More pictures in the Project's gallery


In order to understand the fire system and the illumination system better a research into the Building Management System must be made.
I researched this domain and I will present in the next lines the conclusions.

From the literature review I made a drawing showing the main parts of a BMS system.


From the picture above it can be observed the main parts. I will research on every topic presented above and
after the research I will decide on which subject I will develop my own algorithms in order to implement them on the prototype.

Good controls are essential for the safe and efficient operation of a modern building. The control system does more than
keep the inside of the building comfortable for the occupants. The trend is to integrate building automation with
the security system in order to provide a unique system that will monitor and mange the building in every possible way,
starting with the control of power, illumination and Heating, Ventilation and Air-Conditioning (HVAC) systems in order to
provide greater comfort for the occupants with less energy consumption ending with access control, fire systems, burglar alarms
and CCTV to provide more security for the building. In conclusion a BMS will provide comfort and security with lower energy consumption.

The first topic that I will research will be the Fire Systems.

A little introduction.

In order to determine the algorithms used in the fire systems I will write a little introduction to these systems.
A fire system role is to permanently supervise the protected space, detect as soon as possible a fire and take action
accordingly meaning trigger the alarm systems and/or protection systems that will allow a fast intervention and
prevention of damage.

Fire systems can be fully automatic, manual or mixed. Manual installations provide the users with the means
to trigger the alarm manually. An automatic system contains automatic detectors that trigger themselves the alarm
without the intervention of a human. A mixed system is generally used because sometimes humans can provide an earlier
warning in case o fire.

The components of a fire system are as following:
- Fire detector - a device with a sensor that monitors permanently or an certain time intervals a physical parameter
or/and chemical associated with a fire and is capable of supplying an electrical signal to the central unit.
There are more than one types of fire detectors according to how they work. Usually detectors are picked according to
the destination of the room. E.g.: a temperature detector where there are objects in the room that can burn fast, without
a flame and show a rapid increase in temperature.
According to how they work fire detectors can be:
- Central(control) unit. Represents the equipment used to control and monitor all the components of a fire system. This central unit must
be capable to:
- devices that are triggered in case of alarm (optical and acoustical sirens)
- and others


In the picture above a typical fire detection system is shown.

After this little introduction I will present how a typical fire system works, in other words what is the algorithm that makes a fire system work.
In the literature review I found a decision tree showing the typical algorithm that fire system use:

*ROI means Rate of Increase

Researched on the internet and found that the regulation for the fire system that apply in the UK are in the standard EN 54-1:2001 that is adopted in the European Union
and other parts of the world.

08/08/2012 - 09/08/2012

Found 3 papers on fire systems algorithms.
"A robust fire detection algorithm or temperature and optical smoke density using fuzzy logic" by Muller, H.C.
"Advanced fire detection using multi-signature alarm algorithms" by Gottuk Daniel et al.
"A review of AVHRR-base active fire detection algorithms: principles, limitations and recommendations", by Li.Z. et al

Found that in this domain there are not so many algorithms because of the fact that pretty much every method of detection
for each specific type of locations are presented in the EN-54 standard hence the study on the subject of fire systems will continue by
researching this standard.

Also research on the topic illumination systems that are included in BMS was made. Illumination systems or Lighting Control offers
great saving in electrical energy by switching off lights were they are not needed and/or dimming them if there is sufficient daylight available.
Usually lighting control comprises of motion detectors and/or presence sensors that allow the control unit to know if the room is occupied so
that it can decide if the lights should be on or off. Locally manual switches can be present. For example in a meeting room in the case of a
presentation the users should be able to turn the lights off, overriding the system, in order to achieve a better visibility.
As in the case of fire systems and their detectors. Different rooms and destinations require different setups for the detectors and
different ways to function (for example delays are introduced in the algorithm).
According to the destination and the occupancy of the room a general algorithm along with the recommendations in each case is presented from
a book used in the literature review:


Those 4 types of solution in a little detail are:
- Localized manual controls - local switches and dimmers that allow the user to have full control on the lights
- Time-switches - used when mostly with fixed building fixed occupancy times and usually are used to turn on/off the lights at fixed hours (E.g.: on at 8:00AM and off at 5:00PM)
- Occupancy switching - is one of the most efficient modes of control because the lights are turned off as soon as the system detects no occupancy in the room
or after a small delay.
- Photoelectric - are used in continuously occupied spaces that have sufficient daylight available. The lights are turned off when daylight is sufficient and turned on if
the daylight falls under a certain level.


Found the standard that regulates this domain. In the UK the standard in use is released by the International Organization for Standardization (ISO) and the number
is ISO 8995-2 - Indoor. By studying the standard I found that it only presents for example the levels of illumination in certain types of rooms according to their
destination but not the means and recommendations (like in the case of EN-54 for fire systems) to reach this levels.

Studying the literature on BMS I found that for lighting control motion detection and/or occupancy detection is used to determine
the amount of light needed in a particular zone/room. Also some systems take into account the daylight available in order to
provide further savings. For example if movement is detected in a room but there is sufficient daylight available the lights remain turned off.


In order to select the best solution for the illumination system a research in how people are detected inside buildings
The algorithms researched are from the movement detection and from the occupancy detection domains to see
which is the best solution that can be applied in the case of this project.

"Personnel detection using ground sensors" by Raju Damarla and David Ufford

In this paper the author propose a solution to detect movement a multi-modal multi-sensor
fusion algorithm for the detection of personnel. The unattended ground sensors employed consist of acoustic,
seismic, passive infrared (PIR) and video camera. The individual sensor data is
processed and the probabilities of detection of a person are estimated. Then, the
individual probability estimates are fused to estimate the overall probability of detection
of a person.
The results of their experiment is presented in the following picture taken from the paper:


From the analysis of the picture is clear that seismic detection has a delay from the other sensors response. The
PIR and the acoustic sensors offer a similar rate of detection with a fast response and the last detection method,
the video detection has a small delay from the results obtained with the PIR and the acoustical sensors.
The graph also shows the combined results obtained by the algorithm they proposed when the system
relays on all the sensors. This results tend to prove that for a simple solution the use of a passive infra-red sensor
might provide the detection needed.

"RFID-based occupancy detection solution for optimizing HVAC energy consumption" by Li Shuai et al"

Even that their solution is for optimizing HVAC energy consumption this algorithm can be also applied in
movement detection and/or occupancy detection
Occupants of the building are equipped with active RFID tags allowing the system to detect their movement in the
building and take the necessary actions. Their tests using a prototype showed a probability of detection of around
71% hence giving a good rate of detection.

"An estimation of passive infra-red sensors's probability of detection" by Osman, E.A. et al

In this paper the authors test the probability of detection of a PIR sensor in different conditions. Different
temperatures and different luminosity levels. In their tests they show that in normal conditions and if
the PIR sensor is positioned correctly this kind of sensor can achieve a probability of detection of 91%.
This is a good rate of detection. The remaining of 9% can be also detected if the sensor is given enough time.

By comparing the results obtained in the papers mentioned above and others that are not presented here
but that they will be in the final report I reach the conclusion that in my case the best solution for the illumination
system is to propose an algorithm that will use a passive infra-red sensor and going further into research and
taking in consideration the recommendations in the CIBSE Guide H - Building Control Systems, a guide released
by the Charted Institution of Building Services Engineers in the UK the algorithm should also contain
the means so that the system will take in account the daylight available in order to allow a dimming
of the lamps in the building according to the daylight available. For example if the luminosity level inside
the building is more than enough the lights should stay turned off even if movement is detected.

The CIBSE Guide H also recommends that the lights should be turned off if no movement is detected
after a period of 10 minutes to allow further savings of energy. The paper also states that this delay in practice
is of 30 minutes. Considering this I decided to go to the library to make some observations that will allow
me to determine the optimal time needed before turning off the lights. Because of the fact that the university
is not during term time and at the University Library there are very few people to make a correct observation
in order that I will be able to produce my own algorithm in the case of lighting systems I decided today to make
a file in excel and go to the Southsea Library and make observations on the time the customers spend in the library
and the rooms they are using (private or common).
Starting tomorrow I will go for 3 hours each day and make observations.

The header of the sheet I will use looks like this:


This data collection will allow me to take account in my algorithm the average time a person stays in a certain room and thus allowing me to decide
for example after how much time after the presence was detected the lights should go off to save energy.


I uploaded the first observation sheets used at the Southsea Library.

more pictures Project Gallery
It can be seen that the average time a person spends in the library is somewhere around 18 minutes. For these observation sheets I will use
a delay of 20 minutes before switching off the lights in the lighting control algorithm.

Also, because there are not many things to observe for the fire system control, except for reading the
regulations and recommendations I was able to produce a scratch for this algorithm.


This may not be the final shape of the algorithm but it is a start.


The following pictures shows the first version of the algorithm for lights control in an open space.
I produced this algorithm after reading the recommendations in the CIBSE Guide H - Building Control Systems.
In their work an efficient algorithm for lighting control should take in consideration the daylight available
so that further savings are accomplished, on top of the need to detect movement and turn on the lights only when
movement is detected.



I produced a much better version of the algorithm for the lights control. making it more efficient.


It will take into consideration as the previous one the amount of daylight available but assures a better sensitivity, with
more room to control the actual intensity at which the lights are turned on, not just for 3 steps like the previous one.


I made the first schematic for the final prototype. Although this schematic takes into account all the components
that will be present on the prototype changes can occur until completion.


In my opinion the final prototype will have the following parts:
- LCD - to display different messages and allow users to have a visual representation of what the device is doing.
- a red LED - will be turned on in case of alarm.
- temperature sensor - a temperature sensor that will monitor the ambient temperature and in case this temperature
goes over and/or above a threshold it will trigger the alarm.
- motion detector - will monitor the surroundings and if the alarm is on and it detects movement this part will trigger the alarm.
- photo-resistor - a sensor that is sensitive to light and will enable the device to take in account the daylight available that will
be used in the algorithm for the lighting control.
- button - to reset the alarm.
- cellular shield - will enable the device to operate, with the help of a SIM, to communicate in the GSM area. Will enable
the device to send text messages in case the alarm is triggered.


Luminosity sensor
I found a sensor that can monitor the luminosity for my device.
SK Pang http://www.skpang.co.uk/catalog/tsl2561-digital-luminosity-lux-light-sensor-p-1131.html

I chose this sensor according to the specifications in the ISO 8995-2:2002 - indoor. Considering the fact that I am simulating lighting control
in a "educational building" (according to the standard) the illumination level in the room should be at least 750 lux.
By the fact that this sensor has a dynamic range from 0.1 to 40,000 Lux will allow my device to monitor the luminosity efficiently.
Also because the input voltage is between 2.7-3.6V means that it can be connected to the Arduino's 5V port.

Precisely Measures Illuminance in Diverse Lighting Conditions
Temperature range: -30 to 80 *C
Dynamic range (Lux): 0.1 to 40,000 Lux
Voltage range: 2.7-3.6V
Interface: I2C

These characteristics are enough to provide a good measurement for the luminosity.

Motion detector
A motion detector that uses infrared light in order to detect movement and can be easily connected to the device looks like this:
SK Pang http://www.skpang.co.uk/catalog/epir-p-1058.html

Passive infra-red motion detector is not affected by regulations meaning that certain minimum performances are not specified
but the sensor should offer a good and wide detection pattern in order to have a good detection, low current draw and configurable
sensitivity, delay and ambient light threshold.
Having the following key characteristics:
- Complete, fully functional motion detection SBC including low profile Fresnel lens
- Advanced software based motion detection algorithms provide superior sensitivity and stability
- 2.7-3.6VDC operating voltage
- Typical current draw: 8.9mA
- Wide 5 x 5m, 60 degree detection pattern

As for the Luminosity sensor the input voltage is small and also the current draw is small that can be connected easily to Arduino's 5V port.


This will be a part of the prototype enabling Arduino to be able to detect movement.

Temperature sensor
The following sensor will allow the device to measure the temperature and trigger the fire alarm in case the values exceed the thresholds.
SK Pang http://www.skpang.co.uk/catalog/tmp36-temperature-sensor-p-1129.html


In the EN-54 the parameters of a temperature sensor are regulated and minimal performance is required:
From the "EN 54 part 5 Fire detection and fire alarm systems. Heat detectors. Point detectors" I extracted the requirements for such a sensor
- must have the sensitivity of at least 1/2 C linearity detection (the case of point detectors - trigger the alarm at a certain temperature)
- Operating temperature range - 5C - 38C
- Sensing range - 54C - 70C

The standard says that in the majority of situations the alarm must be triggered at 57C.

Product description:
Voltage Input: 2.7 V to 5.5 VDC
10 mV/C scale factor
2C accuracy over temperature
0.5C linearity
Operating Range: −40C to +125C

Considering the input voltage that allows the connection to Arduino's 5V supply, good sensitivity and very good operating range I consider
that this sensor is right for the job.


Also I am attaching pictures from with the Arduino device, the LCD and the GSM shield. There are not to many explanations for these at this moment.
For example the LCD will display various messages, the GSM shield will allow connection of the device to a GSM network and Arduino will
control all the parts mentioned above.

GSM shield


Updated the online journal with the research and work did in the last month and also started working on writing the report.
I am waiting for the parts to arrive and in the meantime I will write the report. I will update the online journal with the
work in constructing the prototype.


In the previous days I wrote a big part of the report. Also today, after studying the Mitsunori Miki et al paper -
"Proposal for an intelligent lighting system, and verification of control method effectiveness" I was able to redesign
my lighting control algorithm.

The authors propose a solution that also takes in consideration daylight available and the adjustment
of the artificial lighting accordingly in steps. The algorithm proposes that the lights are turned
on when movement is detected at an initial level, get the illumination level and modify the levels
of the artificial lighting that corresponds to that amount of daylight available. The next steps are
to constantly reevaluate the daylight available and repeat the process if the levels of daylight changed.
A more detailed working of the algorithm is presented below in a picture taken from the paper:


By studying their algorithm I was able to redesign and optimize the algorithm that will be used in the lighting control system.


The new algorithm takes in account an additional 15 seconds delay before the illumination levels are changed in order to
accommodate for cases like when a small cloud passes and the daylight is reduced. In this case the system should account
for a delay so that if the change in daylight is for a short time the lights will keep the illumination level and avoid often
changes in intensity that might damage the lamp.

Because the for the fire system the algorithm is simple because the regulations limit the possible ways that a system like this
can work I also sketched the algorithm that is describing how the simulation for the fire system will occur.


The algorithm will monitor the temperature and if the temperature goes above 57 degrees C the system will trigger the alarm and
activate the visual, acoustical and SMS alarm to warn of the possible threat.


In the past days I tried to test different possibilities on how to integrate the algorithms on the prototype.
I am testing the fire system and the illumination system separately and after the parts will arrive I
will try to put them all together .


Also the writing of the report is going well and hopefully at the end of these week or on Monday the next week to have like 95% of it
in order to allow in the last days time to proofread it and other preparations for the submission.

06/09/2012 - 07/09/2012

After the parts have been received I was able to start the working on the prototype.
As mentioned above the components of the prototype are the following:
- Arduino
- 3 LEDs (one to simulate the visual fire alarm and two to simulate the artificial light)
- a piezo buzzer to simulate the acoustical fire alarm
- 2 X manual fire alarm buttons
- 2 X manual switch for lights
- a luminosity sensor to simulate the daylight sensor
- a passive infra-red sensor
- a temperature sensor to simulate the heat detector
- the GSM shield to allow the prototype to send SMS alerts.

From the datasheet of the Arduino the board has 14 digital ports and 6 analog inputs.
The number of inputs/outputs is needed because each component will make use of this
ports so a clear knowledge of the ports is necessary before connecting the devices. Also
the board offers 3 ground connectors, 1 output for 5V and 1 port for 3.3V.

By studying the datasheets of each component that will be a part of the prototype
they use the following ports:

--> LCD - One 5V pin for power, 1 Ground pin and 1 digital pin for communication with the board
The LCD is produced by the SparkFun company and comes with a library that allows
serial communication with the device using one digital pin. Further information can be found
on the device's product page SparkFun
--> GSM shield - requires 2 digital pins to communicate with Arduino. Because it's a shield it draws current from the board directly.
Because it's a shield the GSM module stays on top of the Arduino. In the program implemented in the Arduino programming
environment the pins that are used are declared. The GSM shield uses the NewSoftSerial library that allows easier communication
with the device. Further information can be found on the device's product page SparkFun
--> LEDs - because there are 3 LEDs they will need 1 digital and 1 ground pins each so that makes 3 digital pins and 3 ground pins.
--> buzzer - the buzzer needs 1 digital pin and 1 ground pin.
--> 5 X buttons - each button requires one 5V pin, 1 ground pin and 1 digital or analog pin to communicate with the board.
That makes five 5V pins, 5 ground pins and 5 analog or digital pins.
--> luminosity sensor - the luminosity sensor uses 2 analog pins for communication, 1 ground pin and one 3.3V for powering.
The luminosity sensor is connected using the example found here Adafruit
--> PIR - the passive infra-red sensor uses two 3.3V pins, 4 ground pins and 2 digital pins to communicate with the board
The PIR sensor has 8 pins but using the example found here Dev-O-Rama
I found that I only need to use 2 digital pins. One for the Sleep pin to "wake-up" the sensor and one for the motion detection pin that
will send the value "High" or "Low" if movement is detected or not.
--> the temperature sensor - needs 1 analog pin for communication, 1 ground pin and 1 pin for 5V to power the sensor.
This sensor was connected and programmed using the example from here Adafruit
It provides an analog communication that sends the temperature in a voltage form and using a mathematical formula the voltage is
transformed in temperature (Celsius or Fahrenheit).
Note that Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data.

Considering the wires for the ground, for the 5V and for the 3.3V can be connected together all the parts can be connected to
the power pin (5V and 3.3V - depending on the needs) and to the ground. The remaining problem is the
distribution of communication pins. Calculating the above figures the parts will need 14 digital pins and 3 analog pins.
Because the number of digital pins exceeds the one available on the board and considering there are still 3 free
analog buttons I will connect 3 buttons to two analog pins so finally the device will use 11 digital pins and 6 analog pins
along with the ground and voltage connections.

In order to connect the parts I went to the lab on the 6/08/2012 and 07/08/2012 to solder the wires and the connection.
The wires were soldered according to recommendations in the datasheet of the parts and/or by making use of different examples
that I found related to the parts I was using. The following pictures also shows the pins and the part connected to that pin:


After the soldering and the connection the device looks like this:

front view

back view

The parts are arranged on an A4 sheet glued to a polystyrene board. Allows easier manipulation and provides a safe connection
to the wires not allowing them to get away. Also because of this setup, without using a breadboard, there is no need to disconnect
the wires and reconnect them again every time the prototype is moved from place to place. Every wire has a small tag showing
the pin that is going to and the device from which it comes.


The next problem was the implementation of the designed algorithms on the prototype.
Because it's simpler I will present first the implementation of the fire system.

The fire algorithm presented above says that if the temperature exceeds the designated temperature it
should activate the visual fire alarm, the acoustical fire alarm, send an SMS alert and wait for the manual
reset. Because the fire algorithm should consider the recommendations in the EN-54, like I showed above
I added two buttons to allow the manual trigger of the alarm.

The prototype monitors the temperature and the state of the 2 buttons and if the alarm is triggered automatically
or manually it displays a message on the LCD and sends the SMS alarm. Also turns on the visual and acoustical alarm.
The code implemented on the prototype that related to this algorithm is the following:


The implemented algorithm reads the temperature and the state of the involved buttons (manual fire alarm and the reset button) and with the
help of a "IF" condition the device enters the alarm state. The "||" symbol in the IF condition represents "OR". So if the manual fire button 1 OR
the manual fire button 2 OR the temperature >57 the prototype enters the alarm state. In the alarm state, as shown on the pictures, the
device activates the acoustical and visual alarm and also the "artificial ligthing" to allow occupants to see their way out.
In the code all these instructions are in a "DO" loop to allow the device to do the intructions "WHILE" the reset button is "LOW". In other
words the device stays in the fire alarm state as long as the reset button is not pressed.
The SMS alert function is a separate function that is called in the fire algorithm loop with the help of the command "SMS();". This
function looks like this.


The prototype prepares the GSM shield to enter the SMS mode and sends the designated phone number and the message that should be sent
to the shield, that ends the communication with the shield after a delay of 3 seconds to allow the device to receive a confirmation from
the network provider. Tests from 08/08/2012 worked and the text looks like this:


The algorithm works as designed and provides an alert in case the temperature exceeds the threshold or if its triggered manually.

The illumination algorithm is a little more complicated because introduces some delays in readings to take in account the 20 minutes
delay before the prototype should turn off the lights and the 15 seconds delay before changing the artificial lights level to
allow the system to exclude short time changes in the luminosity level.
The implemented algorithm looks like this:


As you can see the explanations for the code are presented in the pictures but to make a long story short the device waits
for the PIR to activate its motion detection port in case movement is detected or the push of the button to turn the lights
on manually. Next a part of the fire algorithm is introduced to resolve the following problem.
The Arduino's LOOP part repeats the instructions as they are written. If a delay of 20 seconds is introduced the device
will do that specific intruction for 20 seconds and if another event is triggered it will not work. This made the
prototype to not respond to the triggering of the fire alarm which was a bad thing. I wanted the device to enter the
fire alarm state no matter what the device was doing, all the time.
After the introduction of that small part from the fire the algorithm waits the triggering of the lights and with the help of
the function "while ((finished - start) <=20000 && (resetState = LOW))" enters a loop to calculate the luminosity level
and adjust the brightness level of the artificial lights for 20 seconds. This 20 seconds represent the 20 minutes in the algorithm
and for demonstration purposes was reduced to this value. In this while loop a delay was introduced "delay(1000);" , in this
case for 1 second to simulate the 15 seconds in the algorithm, again, for demonstration purposes. These values can be changed
all by using the Arduino programming environment easily.
The prototype calculates the luminosity in LUX and aims to turn on the ligths so that the total amount of combined light
is 750 lux (from the ISO 9885 standard for this type of room). Also this value is presented on the LCD display of the prototype.
For this case I had to calculate the equation that will give the percentage of light that should come from the artificial lighting.
Considering that the in the simulation the "lights" should provide a luminosity of 600 LUX and the command in the
Arduino programing environment is "analogWrite(pin, value)" where value can go from 0 (which represents no voltage transmitted -
so the lights are turned off) to 255 (which represents the maximum power for the LEDs - so the lights are fully turned on. The
equation was determined using an Excel table and looks like this:


So the equation for the brightness of the artificial lighting that is also implemented in the program is:

brightness = -0.425 * lux + 318.75;
This way the brightness level in the room is kept at a constant level even if the variable, lux, changes in time.

I made a video and uploaded it to Youtube to show the whole system working. The video can be found
here --> Youtube Video


Updated the logbook with contruction of the prototype and the implementation of the algorithm.
Continuing with the work on the final paper.
Attachment Timestamp Size