1 Remote XBee Weather Station Maintenance Report Sergio Pais Draft 4 April 12, 2015 CEN 4935 Senior Software Engineering Project Instructor: Dr. Janusz Zalewski Software Engineering Program Florida Gulf Coast University Ft. Myers, FL 33965
1
Remote XBee Weather Station
Maintenance Report
Sergio Pais
Draft 4
April 12, 2015
CEN 4935 Senior Software Engineering Project
Instructor: Dr. Janusz Zalewski
Software Engineering Program
Florida Gulf Coast University
Ft. Myers, FL 33965
2
1. Introduction
1.1 General Overview
The Remote XBee Weather Station project is the result of two past students’ efforts. Christopher
McCoy extended the most recent iteration to have Internet accessibility in 2011. [1] The project
is supposed to take the wireless weather station that was completed by Bradd Konert in 2009 and
store the temperature and humidity values to a database, which is then made accessible to a web
page, as shown in Figure 1.
Figure 1: Physical Diagram
1.2 Requirements Specification
Arduino Requirements
A1) The software shall poll the temperature and humidity sensor (SHT15) every 15
minutes.
A2) The software shall restart the polling process when hardware is rebooted.
Web Server Requirements
W1) The software shall display a table of recent temperature and humidity
readings on a windows IIS server.
W2) The software shall store temperature and humidity information in an Access
database.
3
W3) The software shall restart when the server is restarted.
1.3 Design and Implementation This section describes the software implementation of the project. Included is the illustration
and source code for the C# application that reads the transmitted data, the database used to store
the data and lastly the ASP.net webpage that reads and displays the data contained in the
database.
1.3.1 Arduino Software Implementation
This implementation is written in C and uploaded to the Arduino microcontroller using
an IDE provided by Arduino. An explanation of loading this code is located in the testing
section. The operation of the software is illustrated in the flowchart shown in Figure 1.3.1.1.
4
Figure 1.3.1.1: Arduino software operating flowchart
When the Arduino is signaled setUp() is called. In this function the SHT15 sensor is
reset in preparation for reading. Once complete the loop begins and the two functions that signal
the sensor to read the temperature and humidity are called.
In order to read the temperature three things occur. First, a function named resetSHT()
is called. This function sleeps for one second to allow the sensor to calibrate. Once the function
wakes up it signals the sensor for the temperature. This value is then returned to the main
function and stored in a variable.
5
The steps to read the humidity are the exact same as those for the temperature. The only
difference is a different sensor is signaled and the value returned is stored in a separate variable.
There are two print steps outlined above. Those are included in this section strictly for
testing purposes.
The code for the software that is loaded on the Arduino microcontroller is located in
Appendix A.
1.3.2 C# Implementation
Once the Arduino board is transmitting via XBee the data being read from the weather
sensor it must be read from the communications port at the server. This is accomplished by a
small application written in C# located on the server. This application operates using two timers.
The first timer sleeps the entire application for 30 minutes. Once the timer expires an event
called a tick is generated. This tick event calls another method where all the data acquisition
occurs.
The communications port is opened once a tick occurs. The port opening signals the
Arduino board via XBee to begin executing its instructions. Immediately after the port opens the
application sleeps a second time for 5 seconds (this is due to the way the temperature and
humidity are read on the Arduino). Once the timer expires the buffer is read, data stored in
variables, the buffer is cleared and the port closed.
The application then writes the received data to the database. The data are received as a
string that contains both the temperature and the humidity. This string is then broken into
corresponding parts and saved in separate strings that are sent to the method that connects to the
database and writes the new values.
The above steps are shown in Figure 1.3.2.1.
6
Figure 1.3.2.1: C# Flowchart
7
Figure 1.3.2.2: C# class diagram
As shown in Figure 1.3.2.3, the user interface includes only two buttons and a small text
field to indicate that the application is running. One to begin reading and one to stop reading.
Once the start reading button is pressed by the user the software begins listening for the event.
Once this even occurs the data are read to a buffer variable and then written to the database
(Section 1.3.3).
Figure 1.3.2.3: Reader User Interface
The source code for this application is located in Appendix 1, Section 2.
8
Alternatively one can implement the code for a C# console application as shown in
Appendix 1, Section 4, to create an application that will load when the server starts and runs in
the background, regardless of what user is logged in. Using the previous example (Appendix 1,
Section 2) requires a specific user to login, execute the application and press the start reading
button. While this may be acceptable for some cases, an automatic approach is likely more
desirable. The functionality of this application is identical to the one above minus the user
interface.
Below are the required steps to create a batch file and add it to the Windows startup services:
1. Open notepad and write the following line:
C:/Inetpub/wwwroot/csmccoy/weatherstation.exe
2. Save this file as a .bat file.
3. Place this file on the following directory:
C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup
4. Click on start then run and type in “gpedit.msc”.
5. Click on “Windows Setting” in the window that appears.
6. Click on Scripts (Startup/Shutdown).
7. Click on Startup
8. Click on Add…
9. Click on Browse…
10. Navigate to the directory where you have batch file is located and select it.
11. Lastly, click open and press ok on the next two windows.
12. Reboot the server hardware and the application will now run as a background service
independent of any user.
9
1.3.3. Database Implementation
The database requirements are minimal. As a result a simple Microsoft Access database
has been implemented. There are three fields to be stored: temperature, humidity and the time.
The temperature and humidity are read from the communication port while the time is recorded
when the event occurs. These three values are then written to the database.
To setup the database, the following steps must be followed:
1. Open Microsoft Access and create a new database naming it tempHumid.mdb
(Figure 1.3.3.1, 1.3.3.2).
2. Right-click on the table and select Design View from the menu (Figure 1.3.3.1).
3. Rename the table to tempHumid when prompted (Figure 1.3.3.4).
4. Fill out the required fields (Figure 1.3.3.5). Since there is no data manipulation with
these values setting them as string data types is acceptable.
5. Once complete, double click on the table and press yes when prompted to save the
table (Figure 1.3.3.6).
6. You database is now created. Verify the one created matches Figure 1.3.3.7.
7. A partially filled database will look like Figure 1.3.3.8.
10
Figure 1.3.3.1: Create a new blank database
11
Figure 1.3.3.2: Name the database as shown.
12
Figure 1.3.3.3: Right-click on the table and select design view.
13
Figure 1.3.3.4: Rename the table as shown above.
14
Figure 1.3.3.5: Enter the fields as shown above.
15
Figure 1.3.3.6: Double click the table and save the table changes when prompted.
Figure 1.3.3.7: Completed table should match image above.
16
Figure 1.3.3.8: Properly configured and populated database
17
1.3.4. ASP Page Implementation
The webpage consists of a table in the middle of a page that displays the information
queried from the database. Once the page is loaded, the user can read the information about this
project and press the “View Sensor Data” (Figure 1.3.4.1) button located at the bottom of the
page. In the new window the data queried from the database is displayed in table format (Figure
1.3.4.2). The user can then review the data. The source code for these pages is located in
Appendix 1, Section 3.
Figure 1.3.4.1: Main project page
18
Figure 1.3.4.2: ASP page with queried data
19
2. Maintenance Manual
2.1 Developers Operating Instructions
2.1.1 Hardware Components and Assembly
The following components are used to complete the project:
1. Arduino 2560 Mega microcontroller board (Figure 2.1.1.1) [2]
2. XBee shield mounted (Figure 2.1.1.2) [3]
3. SHT15 Temperature/Humidity sensor (Figure 2.1.1.3) [4]
4. XBee Pro transceiver mounted on a host development board (Figure 2.1.1.4) [5]
5. Assembled components (Figure 2.1.1.5)
Figure 2.1.1.1: Arduino Mega 2560
20
Figure 2.1.1.2: XBee on shield
21
Figure 2.1.1.3: SHT15 Temperature and Humidity Sensor
22
Figure 2.1.1.4: XBee Pro on development board
23
Figure 2.1.1.5: Assembled Components
Connecting the sensor to the microcontroller is a simple and straightforward process (see figure
2.1.1.6), as described below:
1. Begin by connecting the VCC pin on the sensor board to the 5V pin on the Arduino
microcontroller. This provides power to the sensor. No soldering is required.
2. Next connect the GND on the sensor board to the GND port on the microcontroller, next
to the 5V pin.
3. Connect the DATA pin on the sensor to pin 9 on the microcontroller.
4. Connect the SCK (System Clock) pin to pin 8 on the microcontroller.
24
The actual sensor connected is shown in Figure 2.1.1.7 and the connected XBee is shown in
Figure 2.1.1.8.
Figure 2.1.6: Wiring Diagram
The XBee shield communicates with microcontroller through 6 pins in the center of the
microcontroller. Simply line up the pins and gently press the shield onto the microcontroller.
Due to the alignment of the ports and pins on both the shield and microcontroller there is only
one way for these to connect. This is all that is required to interface the sensor and the Arduino
microcontroller.
25
Figure 2.1.1.7: Sensor connected to microcontroller
Figure 2.1.1.8: Sensor and XBee shield connected to microcontroller
26
2.1.2. XBee Configuration (Optional)
This section is only relevant if you are using older XBee transceivers. By default each
should communicate with no additional configuration. However, if necessary the following steps
should be followed:
1. With the sensor disconnected mount the XBee shield to the Arduino microcontroller.
2. The two transceivers should work with no configuration. If they do not continue on to
step 3.
The following steps were obtained from http://antipastohw.blogspot.com/2009/01/xbee-
shield-to-xbee-shield.html.
3. Download X-CTU from Digi’s website:
http://www.digi.com/support/productdetl.jsp?pid=3352&osvid=57&tp=4&s=316
4. Put both Arduinos in Reset.
5. Attach a USB cable from one arduino to Computer "A". Attach the other USB cable to
the other arduino and Computer "B". Open X-CTU.
6. Go to the "Modem Configuration" tab... set the Modem: XBEE to "XB24-B" AND set
the Function Set to "ZNET 2.5 ROUTER/END DEVICE AT" (Figure 2.1.2.1)
7. Next is the Networking and Addressing Parameters...
8. PAN ID = 1111 (Figure 2.1.2.2)
27
Figure 2.2.1: Step 6
9. Destination Address High = 13A200 (I found this out by typing "AT" commands into a
terminal program... first type in "+++" the xbee will return an "OK" you are now in
command mode... if you type "ATSH" then "" (enter), the xbee will give you it's own
high address (source address) ) (Figure 2.1.2.2)
28
Figure 2.1.2.2: Step 8, 9, 10 and 11
10. Destination Address Low = 403E2502 (I found this out by typing "AT" commands into a
terminal program) (Figure 2.1.2.2)
29
Figure 2.1.2.3: Step 13
11. Click the "Write" button on the Modem Configuration tab and wait for the XBee to
program (Figure 2.1.2.3)
12. If some funny error comes up... click the button on the xbee shield and try to program it
again
13. Go to the "Modem Configuration" tab on computer B... set the Modem: XBEE to "XB24-
B" AND set the Function Set to "ZNET 2.5 COORDINATOR AT” (Figure 2.1.2.4)
30
Figure 2.1.2.4: Step 13
14. Next is the Networking and Addressing Parameters for the other XBee.
15. PAN ID = 1111
16. Scan Channels = 15 (not sure if this is even needed)
17. Channel Verification = 0
18. Destination Address High = 13A200 (I found this out by typing "AT" commands into a
terminal program... first type in "+++" the xbee will return an "OK" you are now in
command mode... if you type "ATSH" then "" (enter), the xbee will give you it's own
high address (source address) )
19. Destination Address Low = 404A4FC4 (I found this out by typing "AT" commands into a
terminal program)
20. Broadcast Radius = 0
31
21. Click the "Write" button on the Modem Configuration tab and wait for the XBee to
program
22. If some funny error comes up... click the button on the xbee shield and try to program it
again
23. Place code below into Arduino software:
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print('H');
delay(1000);
Serial.print('L');
delay(1000);
}
24. Make sure the jumpers on the Arduino board are swapped to USB from XBee so the
sketch will load. Press the reset button on the Arduino board then the “upload” button on
the software to upload the sketch.
25. Once complete open the serial monitor in the software, ensure it is monitoring the correct
port and then watch for “H’s” and “L’s” to print.
32
2.1.3 Arduino, Sensor and XBee Testing
The following steps are needed to configure and program the Arduino microcontroller to
communicate with the SHT15 temperature sensor and then transmit to data to the correct output
pin to be transmitted over the XBee transceivers.
1. Assemble the components as shown in section 2.1.1 and 2.1.2 (optional).
2. If the Arduino IDE is not currently installed, download from
http://arduino.cc/en/Main/Software selecting the correct operating system from the list.
3. Once assembled go to the computer and open the Arduino software.
4. Create a new sketch (Figure 2.1.3.1)
Figure 2.1.3.1: New sketch creation
33
5. Copy the code from section Appendix A, Section 1 Arduino Source Code to the sketch
window.
6. Once the code is copied choose go Tools, Board and ensure that the Mega 2560 is
selected (Figure 2.1.3.2).
Figure 2.1.3.2: Proper board selection.
34
7. Lastly press the reset button on the microcontroller and then the upload button on the
Arduino IDE (Figure 2.1.3.3).
Figure 2.1.3.3: Upload button.
8. Once the upload is complete a message will print in the black section at the bottom. If
there is a problem it will also be listed here.
9. Open the serial monitor (Figure 2.1.3.4) and you should see temperature and humidity
data being printed (Figure 2.1.3.5).
35
Figure 2.1.3.4: Serial monitor button used to monitor results
36
Figure 2.1.3.5: Correct results.
37
2.2 User Information
The following is a detailed description of how the equipment functions. Follow the steps
outlined below to test the project.
1. Open your preferred web browser. Please not that some older browsers do not support
HTML5 and CSS3. In these cases some of the formatting will not be displayed properly.
2. In the address bar enter 69.88.163.18 and press the “Enter”.
3. Once the webpage loads select “Remote Weather Station – Christopher McCoy” from
the list of projects (Figure 2.2.1).
Figure 2.2.1: Select “Remote Weather Station – Christopher McCoy”
38
4. The page that loads is the main project page (Figure 2.2.2). The title is the name of the
class and the project. A paragraph outlining the main goals of the project is located
below the title. To query the database and view the contained data press the “View
Sensor Data” button (Figure 2.2.3)
Figure 2.2.2: Main project page.
Figure 2.2.3: Press this button to query the database and view results
39
5. A new page will then be loaded with the queried data displayed in a formatted table
(Figure 2.2.4).
Figure 2.2.4: ASP page with formatted, queried data
40
3. Troubleshooting
3.1 C:/Inetpub/wwwroot/csmccoy/weatherstation.exe exists according to previous report and
implement a section here about restarting the server.
3.2 Make sure USB COM4 is used.
3.3 Login script to start the weatherstation.exe resides in the zalewski account.
41
4. References
[1] C. McCoy, Remote XBee Weather Station, FGCU CNT 4104 Software Project In Computer
Networks, pp. 1-94, December 2011.
[2] SparkFun Electronics. Arduino Mega 2560 R3, 2015.
URL: https://www.sparkfun.com/products/11061
[3] Arduino. Xbee Shield, 2015.
URL: http://arduino.cc/en/Main/ArduinoXbeeShield
[4] SparkFun Electronics. XBee Pro 60mW Wire Antenna - Series 1, 2011.
URL: http://www.sparkfun.com/products/8742
[5] SparkFun Electronics. XBee Explorer USB, 2011.
URL: http://www.sparkfun.com/products/8687