Weather Station Development

Mockups | Pre-existing Development Files | Links | Incoming Data | Outgoing Data
Functional Specifications |Function Points | Data Flow Analysis | System Analysis Diagram | System Analysis

Front page mock up

Download data mock up

Pre-existing Development Files

Relevant Links

Incoming Data

The datalogger stores and sends data in a comma delimited, ascii string, one record per line. There are several types/intervals of data which are identified by the first field of each record. Remember that fields may change over time, so it must be easy to alter code to accomodate changes.

Interval Identifers:

Below are all the fields which are in each record, separated by their respective Intervals:

10 Minute Data:

Table Name: 10_minute_data

Field
#

Description Example db column name db data type
0 Array Identifier 101 n/a n/a
1 Year 2001

date_time
condense into date-time?
9999-12-31 23:59:59

datetime
2 Day of year 54
3 Hour and minute, 1200 = noon, 2400 = midnight 1010
4 Air temperature, deg C 2.020 air_temp float
5 Relative Humidity, % 81.0 relative_humidity float
6 Calculated Vapor Pressure, kPa 0.443 calc_vapor_pressure float
7 Calculated Dew Point temperature, deg C -4.320 calc_dew_point_temp float
8 Station Barometric pressure, millibars (mb) 997 barametric_pressure smallint?
9 Rain accumulated during 10 minute interval, cm 0.001 rain_accumulated float
10 Mean horizontal Wind speed, meters per second 0.806 mean_wind_speed float
11 Unit vector mean wind direction, compass degrees 156.9 mean_wind_direction float
12 Standard deviation of wind direction 31.28 std_dev_wind_direction float
13 Wind speed from Tradewinds cup anenometer, mps 0.013 tradewinds_wind_speed float
14 Solar insolation, watts per meter squared 138.2 solar_insolation float

60 Minute Data:

Table Name: 60_minute_data
Field
#
Description Example db column name db data type
0 Array Identifier 102 n/a (stripped) n/a
1 Year 2001 date_time
condense into date-time?
9999-12-31 23:59:59
datetime
2 Day of year 54
3 Hour and minute, 1200 = noon, 2400 = midnight 1000
4 Air temp, deg C 0.600 air_temp float
5 Relative Humidity, % 29.60 relative_humidity float
6 60 minute avg Vapor Pressure, kPa 0.248 avg_vapor_pressure float
7 60 minute avg Dew Point temperature, deg C -11.88 avg_dew_point_temp float
8 60 minute avg Station Barometric pressure, mb 1010 avg_barametric_pressure smallint?
9 Rain accumulated during 60 minute interval, cm 0.000 rain_accumulated float
10 60 min mean horizontal Wind Speed, mps 1.666 mean_wind_speed float
11 60 minute mean wind direction, compass degrees 306.0 mean_wind_direction float
12 60 minute Standard deviation of wind direction 20.75 std_dev_wind_direction float
13 Wind speed from Tradewinds cup anenometer, mps 6.692 tradewinds_wind_speed float
14 60 min avg Solar insolation, w/m^2 495.0 solar_insolation float
15 60 minute Soil temperature deg C, 5cm depth 2.332 soil_temp_5cm float
16 60 minute Soil temperature deg C 50 cm depth 1.232 soil_temp_50cm float
17 60 minute Soil temperature, deg C, 100 cm depth 3.234 soil_temp_100cm float

24 hour data:

Table Name: 24_hour_data
Field
#
Description Example db column name db data type
0 Array Identifier 103 n/a stripped n/a
1 Year 2001 date_time
condense into date-time?
9999-12-31 23:59:59
datetime
2 Day of year 54
3 24 hour avg air temp, deg C 4.880
4 Minimum air temp last 24 hours, deg C -2.893 min_air_temp float
5 Hour and minute of minimum air temp reading 616 min_air_temp_time time
6 Maximum air temp last 24 hours, deg C 13.17 max_air_temp float
7 Hour and minute of maximum air temp reading 1324 min_air_temp_time time
8 24 hour avg Relative Humidity 55.34 avg_relative_humidity float
9 Minimum RH last 24 hours 22.52 min_relative_humidity float
10 Hour and minute of minimum RH reading 1517 min_relative_humidity_time time
11 Maximum RH last 24 hours 96.7 max_relative_humidity float
12 Hour and minute of maximum RH reading 625 max_relative_humidity_time time
13 24 hour avg Vapor Pressure, kPa 0.425 avg_vapor_pressure float
14 Minimum Vapor Pressure last 24 hours 0.283 min_vapor_pressure float
15 Hour and minute of minimum Vap Pres reading 1511 min_vapor_pressure_time time
16 Maximum Vapor Pressure last 24 hours 0.560 max_vapor_pressure float
17 Hour and minute of maximum Vap Pres reading 14 max_vapor_pressure_time time
18 24 hour avg Dew Point, deg C -5.112 avg_dew_point float
19 Minimum Dew Point last 24 hours, deg C -10.17 min_dew_point float
20 Hour and minute of minimum Dew Point reading 1511 min_dew_point_time time
21 Maximum Dew Point last 24 hours, deg C -1.199 max_dew_point float
22 Hour and minute of maximum Dew Point reading 14 max_dew_point_time time
23 24 avg station Barometric Pressure, mb 1003 avg_barometric_pressure smallint?
24 Minimum Baro Press last 24 hours, mb 1000 min_barometric_pressure smallint?
25 Hour and minute of minimum Baro Press reading 51 min_barometric_pressure_time time
26 Maximum Baro Press last 24 hours. Mb 1005 max_barometric_pressure smallint?
27 Hour and minute of maximum Baro Press reading 756 max_barometric_pressure_time time
28 Total rainfall accumulation last 24 hours, cm 0.000 rainfall_accumulation float
29 24 hour avg windspeed, meters per second 0.589 avg_windspeed float
30 24 hour avg wind Direction, compass degrees 245.0 avg_wind_direction float
31 Stnd Deviation of 24 hour Wind Direction 69.87 std_dev_wind_direction float
32 Maximum windspeed last 24 hours, mps 3.332 max_windspeed float
33 Hour and minute of max wind speed 1542 max_windspeed_time time
34 24 avg of Tradewinds cup anenometer, mps 0.071 avg_windspeed_tradewinds float
35 Maximum Tradewinds windspeed, last 24 hours, mps 16.77 max_windspeed_tradewinds float
36 Hour and minute of Tradewinds MAX 1541 max_windspeed_tradewinds_time time
37 24 hour avg solar insolation, watts per meter^2 202.0 avg_solar_insolation float
38 Maximum solar insolation last 24 hours, w/m^2 918 max_solar_insolation float
39 Hour and minute of solar insolation MAX 1244 max_solar_insolation time
40 24 hour avg Soil Temp a (5cm depth), deg C 10.010 avg_soil_temp_5cm float
41 Minimum Soil Temp a last 24 hours, deg C 1.089 min_soil_temp_5cm float
42 Hour and minute of MIN Soil temp a 1212 min_soil_temp_5cm_time time
43 Maximum Soil Temp a last 24 hours, deg C 4.938 max_soil_temp_5cm float
44 Hour and minute of MAX Soil temp a 1318 max_soil_temp_5cm_time time
45 24 hour avg Soil Temp b (50cm depth), deg C 3.087 avg_soil_temp_50cm float
46 Minimum Soil Temp b last 24 hours, deg C 2.281 min_soil_temp_50cm float
47 Hour and minute of MIN Soil temp b 643 min_soil_temp_50cm_time time
48 Maximum Soil Temp b last 24 hours, deg C 5.329 max_soil_temp_50cm float
49 Hour and minute of MAX Soil temp b 1345 max_soil_temp_50cm_temp time
50 24 hour avg Soil Temp c (100cm depth), deg C 3.443 avg_soil_temp_100cm float
51 Minimum Soil Temp c last 24 hours, deg C 4.553 min_soil_temp_100cm float
52 Hour and minute of MIN Soil temp c 1023 min_soil_temp_100cm_time time
53 Maximum Soil Temp c last 24 hours, deg C 4.221 max_soil_temp_100cm float
54 Hour and minute of MAX Soil temp c 2312 max_soil_temp_100cm_time time

Station Data:

Table Name: station_data
Field
#
Description Example db column name db data type
0 Array Identifier 104 n/a (stripped) n/a
1 Year 2001 date
condensed
datetime
2 Day 54
3 Program signature 2400 program_signature smallint
4 24 hour MIN Battery voltage -0.288 min_battery_voltage float
5 24 hour MAX enclosure humidity (RH%) 61.91 max_enclosure_humidity float

 

Outgoing Data

Front Page General Public Data

Functional Specs

Data Manipulation functions

array get_data($time_interval, $start_time, [$end_time])
Function: get_data
Description: gets specifed data from database
beginning at $start_time through $end_time. If $end_time is not included, function will simply return single item of $start_time
Inputs:

  • $time_interval - which table to get the data from
  • $start_time - first item to get
  • $end_time - last item to get.

Output: returns array of all data points for requested time_stamp.
Issues: Should it just return a requested data point as apposed to an array of all data points at the specified time_stamp? May be more efficient, however, we will likely need more than one piece of data to be returned, which would require multiple queries. The function could except multiple data_points, but this could get hairy if you want 15 data points (or up to 55!)
Should it take one input time_stamp and just do one query, or should it take a start date and end date and do one < > query?

Approximate LOC: 30

Testing Protocol: To test function get_data run page: get_data_test.php
Pass variables time_interval, start_time and optionally end_time in the url (ie. get_data_test.php?time_interval=10&start_time=2001-03-28%2023:34:00&end_time=2001-04-28%2023:34:00) A table of weather should be returned. The output will vary depending on the time interval. Write the output.

 

float sum_data($time_interval, $data_point, $start_time, $end_time)
Function: sum_data
Description: Sums the specified data_point between specified start_time and end_time. To be used for accumulated rainfall, or averaging data.
Inputs:

  • $time_interval - which table to get the data from (10_minute_data, 60_minute_data, 24_hour_data)
  • $data_point - type of data you want. (Ex. air_temp, relative_humidity)
  • $start_time - first item to sum (2001-12-31 23:59:59)
  • $end_time - last entry to sum

Output: returns summed data as a float
Issues: data_point has lots of possibilites, this could be a pain to keep track of, is there a better way?

Approximate LOC: 20

Testing Protocol: To test function sum_data run page: sum_data_test.php
Pass variables time_interval, data_point, start_time, and end_time in the url (ie. sum_data_test.php?time_interval=60&data_point=air_temp&start_time=2001-03-28%2023:34:00&end_time=2001-04-28%2023:34:00) The resulting page should return a table of values, with the sum of those values at the end. Verify that the end value is indeed the sum of the previous results.

 

int calc_num_data_points($time_interval, $start_time, $end_time)
Function: calc_num_data_points
Description: calculates the number of data points are available between the start_date and end_date of a specified time interval. In theory it could to a calculation on it's own, but in reality, it should probably do a query on the db and use the number or records returned (matched).
Inputs:

  • $time_interval - which table to get the data from (10_minute_data, 60_minute_data, 24_hour_data)
  • $start_time - first item (2001-12-31 23:59:59)
  • $end_time - last item

Output: returns number of data points between start_time and end_time

Approximate LOC: 15

Testing Protocol: To test the function calc_num_data_points run: calc_num_data_points_test.php
Pass variables time_interval, start_time, and end_time in the url (ie. calc_num_data_points_test.php?time_interval=60&start_time=2001-03-28%2023:34:00&end_time=2001-04-28%2023:34:00) The resulting page should return a table of time stamps between the start_time and end_time. At the end of the table, there should be a number whichis the number of data points listed above. Count the number of data points in the table and verify that the end number is the same as your calculated sum.

 

float average_data($summed_data, $num_data_points)
Function: average_data
Description: averages data by dividing input by num_data_points
Inputs:

  • $summed_data - float data to be averaged, likely generated by sum_data() function
  • $num_data_points - the number of data points summed_data consists of

Output: returns average data

Approximate LOC: 20

Testing Protocol: To test the function average_data run the page: average_data_test.php
Pass variables summed_data and num_data_points in the url (ie. average_data_test.php?summed_data=50&num_data_points=10) The resulting page should return a float number which is the summed_data divided by num_data_points.

Database Connection Functions

db_connect($host, $user, $pass, $db_name)
Function: db_connect
Description: reads database connection parameters from config file (settings.conf), connects to database, and selects the database.
Inputs:

  • $host
  • $user
  • $pass
  • $db_name

Approximate LOC: 20

Testing protocol: To test the db_connect function, run the page: db_connect_test.php
Using the settings in the file "settings.conf" the page will attempt to connect to the database. If successful, the resulting page will return, "Database Connection Successful", if the database connection is unsuccessful, the resulting page will return, "Databse Connection Unsuccessful".

 
...all sorts of stuff possibly missing... ack.

Testing Protocols

array get_data($time_interval, $start_time, [$end_time])

 

float sum_data($time_interval, $data_point, $start_time, $end_time)

int calc_num_data_points($time_interval, $start_time, $end_time)

float average_data($summed_data, $num_data_points)

int db_connect($host, $user, $pass, $db_name)


Function Points (mostly front page stuff)

User Inputs

None really. The system is pretty much one way. We are feeding data (lots of it) to the user.

User Outputs

There will be approximately nine outputs on the front page. See outgoing data section for a list. Each output has varying levels of difficulty but most will be based on the same functions.

User Inquiries

The only data the user asks for is initial inquiry of typing a url into a browser. This doesn't really count I guess, but it does then cause several db queries to get information that the user expects. On the page where the user is asking for specific data, there will be one request for data. The complexity will be moderate, but ideally the returned data will be retrieved using the same functions that are used to generate the front page.

Files

The main page is where most of the action will occur. Each section (air temp, wind, etc) will have it's own sub-page with more detailed information. Initially these pages will be fairly simple and share most of their code, providing a low level of complexity. Later, graphs and images will be used raising the complexity level. Approximate files for users: 10

External Interfaces

The main external interface (assuming I know what one actually is) is the interface between the datalogger and the SQL engine. The complexity level here is fairly high as we need to talk directly to an external piece of hardware.


Data Flow Analysis

DATA IN

DATA OUT

System Analysis Schematic


WEATHER STATION SYSTEM ANALYSIS

Abstract
The big picture idea is to provide data from a datalogger and present it in an easy to 
understand and easy to manipulate way for the end user. Dataloggers can provide data
from various sources, in this case, we are looking at a weather station with several 
sensors, and possibly in micro-metering of homes project.

The end user for the weather station project will be:
-Users interested in basic weather information such as current temperature.
-Faculty & Students interested in doing research using a wide range of the data.
-Farmers interested in knowing when to plant, harvest, etc crops

The end user for a micro-metering situation would be:
-Home owner interested in where the energy is going and how to conserve it.
-General public interested in energy consumption of energy efficient homes.

-Hardware
	-CR10X Campbell Scientific Datalogger
		-Use existing windows software
		-Use existing Linux software
		-Modify existing Linux software
		-Create new Linux software
	-Platform independent server
		-Any server which can provide a robust serving enviroment and
		 provide standard tools such as PERL, PHP, MySQL
	-Platform independent clients
		-Provide data via a platform independent delivery method.
		 Likely through a web browser and possibly another custom
		 application.

-Software
	-Download data from datalogger - requires serial communication to
	 datalogger
	-Verify and store data in database
	-Serve information to client

People
	-Client - Steve Roof
	-Programmer(s) to provide serial communication between datalogger and
	 server
	-Database programmer(s)
	-Web programmer(s)
	-Interface designers
	-Documentation writers

-Data
	-Datalogger data stream in ascii, comma delimited format
	-For robust and easy data manipulation, must be stored in a database
	-Data retrieved at 10 minute, 1 hour, and 1 day intervals.


-Procedures
	-Talk about it.
	-Plan it.
	-Program it.
	-Document it.
	-Use it.

-Enterprise Model
	-Information Flow (I don't know, sounds like suit speak to me.)

-Feasability

   -Economic
		-Only expensive hardware requirement is the datalogger itself
		 which is being provided
		-Open Source and Free software development tools will be more
		 than sufficient.

   -Technical
   		-Talking to datalogger via serial communication
   		-Interacting with a database with various API's including
		 perl_dbi and php

   -Legal
   		-Campbell Scientific (datalogger manufacturor) doesn't seem to
		 care.  They have provided us with datalogger specifications in
		 the included manual. Although they won't sue us, they certainly
		 will not provide support because they are morons, and don't
		 know what Linux is.

   -Alternatives
   		-The CR10X datalogger has no seamless method for providing an
		 automated stream of data available to platform independent
		 clients upon demand.