mobile and web applications for sensing hazardous room temperature using wireless sensore networks
TRANSCRIPT
1
Mobile and Web Application for Sensing
Hazardous Room Temperatures using
Wireless Sensor Network
Georg-August-Universität, Göttingen Institut für Informatik
Telematics Group
Practical Course on Wireless Sensor Networks (Lab) Dr. Omar Alfandi,
Prof. Dr. Dieter Hogrefe, Arne Bochem, M.Sc-Inf.
Submitted By: Vijay Soppadandi: 21363273
Pushpendra Chaturvedi: 11336967
Gurjinder Singh:11333672
Masters in Applied Computer Science
Summer Semester 2014
Date of Submission: 30 May 2014
2
Table of Contents
EXECUTIVE SUMMARY ................................................................................................................... 3
1. INTRODUCTION ........................................................................................................................ 4
2. OBJECTIVE .................................................................................................................................. 5
3. MOTIVATION ............................................................................................................................. 5
4. PROJECT DESCRIPTION ......................................................................................................... 6
5. TECHNICAL SPECIFICATION ................................................................................................ 8
6. DESIGN APPROACH ............................................................................................................... 10
7. PROJECT IMPLEMENTATION ............................................................................................. 11
8. SUMMARY ................................................................................................................................. 16
REFERENCES .................................................................................................................................... 17
APPENDIX A ..................................................................................................................................... 18
APPENDIX B ..................................................................................................................................... 20
3
EXECUTIVE SUMMARY
Wireless Sensor networks are widely used for accomplishing various tasks and performing
several functions. They can be employed to measure real world environment and
atmospheric values such as temperature humidity, visibility of light, sound, pressure, speed
etc. As the name suggests wireless sensor networks is interconnection of sensors in definite
topological manner or ad-hoc to sense various environmental or physical variables from the
real world. The objective of this project is to design a wireless sensor network which has the
ability to sense and notify the hazardous increase in temperature at the location under
surveillance in minimum time over the internet through web and mobile applications. The
network can find its application in locations such as dense forests, laboratories etc. where
change in temperature can become a harmful aspect due to ever changing environmental
factors. Functionality of Wireless sensor network for sensing the hazardous temperature
was programmed in TinyOS with nesC programming language. MoteView is a java based
application to display the recorded temperature values over the time. IRIS motes were used
establish the network connection through sensors and the specification of IRIS mote is 56
mm at x-axis, 36 mm on y-axis and 18 mm on z-axis. The algorithm implemented in this
sensor network is energy proficient so that the network can work with minimum power
requirements. Crossbow’s IRIS sensor was used to collect environmental data and to
transmit those readings in computer database. The android based mobile application and
PHP web application is developed to fetch those values from the computer database and
alarm the user when the temperature values cross certain threshold for hazardous
temperature.
Four IRIS sensors were used in this project to detect and store temperature values
from the environment. The web application was developed in PHP with Apache to fetch and
display the temperature whenever it crossed a certain threshold. The temperature
threshold for this prototype implementation was set to 40 degree Celsius. The mobile
application was developed with Android development services environment. IRIS sensors
typically cover the range of 100 meters, so each of four units could detect temperature in
the range of 10,000 square meters. The prototype implementation establishes that this
4
network can be used for detecting and alarming the hazardous temperature in real world
with low investment in communication for consumer.
1. Introduction
The main benefits of using wireless sensor networks include low cost of implementation and
optimal energy usage. The main tasks that sensors of WSN perform are sensing the real
world environment, calculating the environment values and transferring those values to the
storage [1]. Continuous research and study in WSN has provided the small sized sensor
components which found there application in several useful systems such as vehicle tracking
systems, thermometers, motion detectors etc. The project deals with implementation of
similar WSN which has the ability to detect temperature values in real world environment
and store those values in the storage. The functionality of the project deals with notifying
the hazardous increase in temperature to the user through web application developed in
PHP or the Android mobile application over the internet, anytime anywhere. IRIS sensors
are responsible for sensing and storing the values in the storage through functionality
implemented in these sensors in TinyOS and nesC programming language. The same
environment uses MoteView java based software calls to notify and display the temperature
value in the computer. Android development services are responsible for notifying the
hazardous temperature on android devices and PHP application notifies the hazardous
temperature through we by displaying a pop up window. X-axis (56 mm), Y-axis (36 mm) and
Z-axis (18 mm) dimension value IRIS motes are used for the implementation of this heat
sensing project.
5
2. Objective
The objective of this project is to establish a WSN that can monitor the change in
temperature values at a particular location and whenever the temperature crosses a given
threshold value for hazardous temperature, it pops up the notification through either a
webpage on internet or a pop-up window on android mobile device. To accomplish this
objective, IRIS motes should adapt to heat sensors and they should transfer the collected
temperature values to the base station connected to storage device (usually a computer
database). The project was designed to find its application in forest agencies, wildlife
services and real estate where change in temperature often causes calamities like forest fire
and other major losses.
3. Motivation
The technological advancements in field of WSN have decreased the size, power
consumption and cost of wireless sensors considerably. The computational capabilities of
sensors have also improved due to research and studies. The capability of modern wireless
sensors to perform sensing and computation with less power requirements increases the
lifetime and sustainability of WSN in various applications. Several algorithms are available
for WSN implementation. This project deals with heat sensing at remote locations, so
energy efficiency is a major requirement and the most suitable algorithm for implementing
this network is Low-Energy Adaptive Clustering Hierarchy (LEACH) algorithm. The algorithm
works with evenly distributed workload by grouping the sensors into clusters and rotating
the base station among them on random basis. The even distribution of workload on various
nodes elongates the lifetime of the network twice the original lifetime [2]. With use of this
6
energy proficient algorithm the ciphered data can be transmitted by individual collector
nodes to base station with low power consumption.
4. Project Description
The project is serves as a prototype for implementing the temperature detection
mechanism with wireless sensor nodes. Energy efficient LEACH algorithm is used for data
transmission and accurate detection of temperature values from the environment. The
network was implemented with 3 intermediate nodes and 1 transceiver node which are
shown in figure 1. Each of the nodes contains the light sensors for signalling the node
activity for data sensing. The Computer base station was responsible for receiving, storing
and displaying the collected data values to the user. The programmed functionality of nodes
is described as follows
Intermediate nodes Functionality
Responsibility to route data to transceiver/sensor node.
Sensing and determining the heat level with temperature calculation.
Data forwarding and LED flash whenever data transmission takes place.
Transceiver Node Functionality
Storing record of data received from Intermediate nodes.
Define and control the routing path based on received data.
Receiving of Light conditions from Intermediate nodes.
Determined heating conditions using light intensity.
Transmitting the calculated data measurement to the base station
7
Notify the user whenever temperature crosses a given threshold and determine
which intermediate node transferred the hazardous temperature.
The communication between base station and sensors in the network was enabled through
use of transceiver node. The transceiver node is responsible for accepting requests for data
transmission from base station and data measurement values from the intermediate sensor
nodes. The sensors transmit the measured values to the computer base station and it can
also communicate to other sensors in the network. The base station makes requests
periodically to each sensor node via transceiver node to take the temperature reading. The
nodes in response to base station request collect the values and transmit it to the base
station through transceiver for analysis. The sensor notifies the base station with an
interruption whenever it encounters the collected temperature value to be higher than the
specified threshold in application.
8
5. Technical Specification
The transceiver node in this project is a cluster head and 3 intermediate nodes have
embedded light sensor to calculate light intensity and consequently judge the heat.
Crossbow IRIS serves as a central processor for this task and it is installed in all the 4 nodes
Intermediate
Node 1
Intermediate
Node 2
Intermediate
Node 3
Transceiver Node
Computer-Base
Station
Figure 1: Block Diagram of Heat Sensing WSN
Mobile (Android App)
Web Page/Service
Network
9
for measuring the values. The technical specification of IRIS is displayed in Table 1 [2]. The
rate of data transmission for IRIS radio frequency transceiver reaches high value of 250 kbps
with benefits of globally compatible ISM (Industrial Scientific and Medical) frequency band.
Table 1: Technical Specification of IRIS
Ambient Light sensor, Accelerometer and Barometric pressure sensor is incorporated in
MTS400CB environmental sensor board. All the 3 intermediate nodes are made by
interconnecting IRIS with a light sensor. The technical specification of MTS400CB is
presented in Table 2 [2]. The IRIS containing light sensor at the transceiver is connected to
USB interface MIB520 board. The MIB 520 USB Interface board facilitates the
communication between base station and sensors in order to transfer data from IRIS to the
computer storage. MIB520 board basically provides a USB cable for connection
establishment and a 51 pin connector that enables communication between IRIS motes and
the computer. Detailed Technical specification of MIB 520 USB interface board is mentioned
in Table 3 [2].
10
Table 2: Technical specification of MTS 400CB
Table 3: Technical specification of MIB520
6. Design Approach
The heat sensing project designed the network as a cluster grouping of sensor nodes. The
cluster composed of 1 transceiver node and 3 intermediate nodes. The transceiver has the
responsibility of heading the cluster nodes. TinyOS operating system was used for
establishing this network project. The transceiver node serving as cluster head was
connected to base station in which programmes were implemented with TinyOS and nesC
programming language. An energy efficient LEACH algorithm was implemented in sensors
for detecting the temperature values. The communication between sensors and base
station was intermediated by transceiver node/ cluster head.
11
The LEACH algorithm implemented in transceiver is based on information packets that
inform about heat intensity and transmitted by intermediate nodes. The decision of heat
hazardness is made upon the most recently collected information packet and these packets
are stored in computer database. The packets also contain an identification number that
identifies the node transmitting concerned packet. The transmitter node is connected to
base station that records and stores the transmitted data, IRIS mote performing the role of
head of the cluster and MIB520 board to establish communication. Additional code for
other required functionalities is implemented in IRIS through MIB520.
The Intermediate nodes are connected with the IRIS and light sensor and the program is
implemented in these nodes through MIB520 board. The MIB520 board is removed as soon
as program is installed in the intermediate nodes. The intermediate nodes thus cannot store
too much data due to limited storage capabilities without connection to the MIB520. Thus
these intermediate are capable of only transmitting the data packets containing heat data to
the transceiver. Another program was implemented in intermediate nodes that enable
them to switch the LED on whenever data transmission takes place and this helps in
visualizing the routing path of the packet transmission. MTS400CB was used as a heat
sensor in this implementation and it was connected to mote at every intermediate node.
The data was stored in IRIS as a numerical value for temperature and heat intensity
measured by MTS400CB sensor. Whenever the sensed value crosses the supplied threshold
for temperature, the functionality programmed for hazard situation was activated. In this
program the functionality in case of hazard was to notify the user on mobile or web
application over the internet. The data is supplied to the base station in form of information
packet containing node id. The packet is forwarded to transceiver periodically in every few
seconds with current status and most recent value of sensed data.
7. Project Implementation
The prototype implementation consists of WSN containing 1 computer and 4 IRIS board
with sensors (1 transceiver + 3 intermediate) to implement a heat detecting wireless sensor
network. The sensors were mounted on IRIS board and all the intermediate sensors were
12
kept at a equal distance from the transceiver. The data transmission took place from the
sensor in which artificial heat source was applied to increase the temperature from normal
room temperature and to make it cross the programmed threshold value. The application of
artificial heat source caused the LED to flash on that specific sensor and demonstrated the
transfer of data. The temperature data was thus transmitted to the transceiver which is
cluster head. The transceiver in turn transmitted the information packet containing node ID
and temperature value to the base station connected to computer. The network topology of
nodes was visualized through MoteView software tool that provide the graphical interface
and client application. The code implemented in sensor nodes is presented in Appendix A.
Figure 2: Implementation of Heat sensing WSN
Following results were obtained by implementation of this heat sensing WSN
13
Intermediate Node A detected heat=> Routing data from NODE A to TRANSCEIVER D
Intermediate Node B detects heat=> Routing data from NODE B to TRANSCEIVER D
Both node A and B detect heat=> Routed through TRANSCEIVER D.
No heat detection => No location specified to Receiver.
The sensor continuously transfers the received temperature values to the base station. The
output of the heat sensor network is shown on Figure 3.
Figure 3: Output of Heat Sensor Network
Further the Web page shown in Figure 4 was developed in PHP to display the alarm
notification whenever the temperature crossed the threshold value which was supplied 40
degree Celsius. The temperature values were supplied from the computer database which is
connected to underlying WSN. Apache server and MySQL database were used for
developing the web application. The code for the PHP application is provided in Appendix B.
14
Figure 4: Web Page Output and Pop Up Window
Android based mobile application was developed to inform user with the pop-up
notification in case of the sensed temperature crossing hazardous threshold value received
from the environment. Free public services API was used to develop this mobile application.
The temperature notification content that informed user through the internet on web as a
web content was transformed into android application through this software. The output
and display messages of the android application are shown in figure 5.
15
Figure 5: Mobile App output and Notification Pop Up
16
8. Summary
The prototype for heat sensing for hazardous temperature detection is successfully
implemented. 3 temperature sensors (intermediate nodes), four IRIS boards, and 1 MIB520 devices
have been used. The specifications of all the mentioned component were found sufficient to
implement this project. All our sensors were programmed in TinyOS operating system and nesC
programming language. Initially Cygwin command interface was used to test these sensors output
the temperature readings. The group then used Mote-View java based software tool that provided
the facility of displaying network topology with its graphical interface and client application between
a user and a deployed network of wireless sensors motes. The prototype can be implemented in
several locations such as dense forests where temperature change can cause disastrous outcomes
like forest fire so that those disasters can be avoided by taking appropriate measures in time. The
project can also find its application in home and building security for fire alarming system or it can
be used by fire services in towns to detect fire locations and take early actions to extinguish the fire.
17
References
[1] W. Liao and H. Wang, “An asynchronous MAC protocol for wireless sensor
networks,” J. Netw. Comput. Applicat., vol. 31, no. 4, pp. 807-820, Nov. 2008.
[2] T. To, M. Au, T. Nguyen, and M. Shinotsuka, “Light Sensing Wireless Network,” Dept.
Elect. Eng., Georgia Tech, Georgia, Proposal, Feb. 4, 2008.
[3] Alfandi.O, “A quick reference sheet for WSN Lab”. Retrieved April 2014.
(http://user.informatik.uni-
goettingen.de/~sensorlab/CourseDocs.php/SLQuickref.pdf).
[4] Crossbow, "Environmental sensor board," MTS420/400 datasheet, Dec. 2003
[Revised Aug. 2007].
[5] Crossbow, "Wireless measurement system," IRIS datasheet, Aug. 2004 [Revised Apr.
2007].
[6] Crossbow, “Crossbow Technology: IRIS 2.4GHz,” [Company Website], [cited 10 Sep.
2008], Available HTTP: http://www.xbow.com/Products/SelectCountry.aspx?sid=164
[7] Crossbow, “Crossbow Technology: MIB520-USB Gateway,” [Company Website],
(http://www.xbow.com/Products/productdetails.aspx?sid=227)
[8] Crossbow, “Crossbow Technology: MTS Sensor Boards,” [Company Website],
(http://www.xbow.com/Products/productdetails.aspx?sid=177)
18
APPENDIX A
Java Code implemented in MTS400CB sensor boards import static java.lang.System.out; import net.tinyos.message.*; import net.tinyos.util.*; import net.tinyos.packet.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; class Mts400Tester implements MessageListener{ private PhoenixSource phoenix; private MoteIF mif; public Mts400Tester(final String source){ phoenix=BuildSource.makePhoenix(source, PrintStreamMessenger.err); mif = new MoteIF(phoenix); mif.registerListener(new DataMsg(),this); } public void messageReceived(int dest_addr,Message msg) { if(msg instanceof DataMsg) { DataMsg results = (DataMsg)msg; int[] taosCalcData = null; double[] sensirionCalcData=null; out.println("The measured results are "); out.println(); out.println("Mote Address: "+results.get_Node_Address()); out.println("Intersema temperature: "+results.getElement_Intersema_data(0)); out.println("Intersema pressure: "+results.getElement_Intersema_data(1)); sensirionCalcData=calculateSensirion(results.get_Temp_data()); out.printf("Sensirion temperature: %.2f\n",sensirionCalcData[0]); String url = "jdbc:mysql://192.168.22.50/"; String dbName = "slsummer14_g4"; String driver = "com.mysql.jdbc.Driver"; String userName = "slsummer14_g4"; String password = "2xqsHDXTPW3RfrKlMzpJupm3ug"; try { int nodeId = results.get_Node_Address(); double sensirion_temp = sensirionCalcData[0]; if(nodeId == 9 || nodeId == 10 || nodeId == 11) { if (sensirion_temp > 40.00) { Class.forName(driver).newInstance();
19
Connection conn = DriverManager.getConnection(url+dbName,userName,password); Statement st = conn.createStatement(); String query = "INSERT INTO Heatsensing(node_id, intersema_temp, intersema_press, sensirion_temp) values(\""+results.get_Node_Address()+"\" , \""+ results.getElement_Intersema_data(0)+"\" , \""+ results.getElement_Intersema_data(1)+"\" , \""+ sensirionCalcData[0]+"\" )"; // sensirion_press, visible_light, infrared_light, submission_datetime int val = st.executeUpdate(query); if(val==1) { out.println("Temperature is more then threshold value and succesufully inserted"); } conn.close(); } } else { out.println("Data not from this network's node"); } } catch (Exception e) { e.printStackTrace(); } out.println(); out.println(); } } private double[] calculateSensirion(int Temperature){ double [] converted = new double[1]; converted[0]=-39.4+(0.01*(double)Temperature); return converted; } public static void main (String[] args) { if ( args.length == 2 && args[0].equals("-comm") ) { Mts400Tester hy = new Mts400Tester(args[1]); } else { System.err.println("usage: java Mts400Tester [-comm <source>]"); System.exit(1); }
20
} }
APPENDIX B
PHP code for Web Application
<?php
$page = $_SERVER['PHP_SELF'];
$sec = "10";
header("Refresh: $sec; url=http://sensorlab.informatik.uni-
goettingen.de/pc01/vijay.soppadandi/test.php");
$dbhostname = '192.168.22.50';
$dbusername = 'slsummer14_g4';
$dbpassword = '2xqsHDXTPW3RfrKlMzpJupm3ug';
// 2xqsHDXTPW3RfrKlMzpJupm3ug
//http://sensorlab.informatik.uni-goettingen.de/pc01/vijay.soppadandi/test.php
$conn = mysql_connect($dbhostname, $dbusername, $dbpassword);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("slsummer14_g4") or die(mysql_error());
$sql_statemanet = "select * from Heatsensing where alert is NULL order by PKID desc";
$rec_select = mysql_query( $sql_statemanet);
21
if(! $rec_select )
{
die('Could not retrieve data: ' . mysql_error());
}
//Displaying fetched records to HTML table
echo "<table border='1'>";
echo "<tr> <th>PKID</th>
<th>node_id</th>
<th>intersema_temp</th>
<th>intersema_press</th>
<th> sensirion_temp </th> </tr>";
//echo "<td> <tr>PKID</tr> <tr>node_id</tr> <tr>intersema_temp</tr>
<tr>intersema_press</tr> <tr> sensirion_temp </tr> </td>";
// Using mysql_fetch_array() to get the next row until end of table rows
while($row = mysql_fetch_array( $rec_select )) {
//echo "<p>ALERT: Temperature is more then threshold value.</p>";
// Print out the contents of each row into a table
$message = "Temperature is more then threshold value";
echo "<script type='text/javascript'>alert('$message');</script>";
echo "<tr>";
echo "<td>";
echo $row['PKID'];
echo "</td>";
//echo "</tr>";
//echo "<br/>";
// echo "<tr>";
22
echo "<td>";
echo $row['node_id'];
echo "</td>";
//echo "</tr>";
//echo "<br/>";
//echo "</tr></td>";
//echo "<tr><td>";
echo "<td>";
echo $row['intersema_temp'];
echo "</td>";
// echo "</tr></td>";
//echo "<tr><td>";
echo "<td>";
echo $row['intersema_press'];
echo "</td>";
//echo "</tr></td>";
//echo "<tr><td>";
echo "<td>";
echo sprintf('%0.2f', $row['sensirion_temp']);
echo "</td>";
//echo "</tr></td>";
echo "</tr>";
}
23
$sql_statemanet = "Update Heatsensing set alert = 0;";
$rec_select = mysql_query( $sql_statemanet);
if(! $rec_select )
{
die('Could not retrieve data: ' . mysql_error());
}
mysql_close($conn);
?>