mbed Weather Station for Weatherduino on mbeduino http://mbed.org/users/okini3939/notebook/weatherduino-on-mbed/

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
okini3939
Date:
Tue Oct 12 16:07:08 2010 +0000
Parent:
0:6e444b317905
Child:
2:920a4e65129d
Commit message:

Changed in this revision

BMP085/.meta Show diff for this revision Revisions of this file
SHT_v1/.meta Show diff for this revision Revisions of this file
WeatherMeters/.meta Show diff for this revision Revisions of this file
WeatherMeters/WeatherMeters.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BMP085/.meta	Mon Sep 27 15:52:09 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-<?xml version="1.0"?>
-<root>
-  <global/>
-  <data>
-    <created_ts>1284884707</created_ts>
-    <last_mod_ts>1284884707</last_mod_ts>
-    <is_archive>0</is_archive>
-    <is_published>0</is_published>
-    <is_svn>0</is_svn>
-    <is_module>0</is_module>
-    <is_lib>1</is_lib>
-    <path>/Weather/BMP085</path>
-    <lines>40</lines>
-    <enable_beta_0006>true</enable_beta_0006>
-    <compiler_version>1.3.0.13</compiler_version>
-    <rmchars>4979</rmchars>
-    <duration>1288</duration>
-    <chars>470</chars>
-  </data>
-</root>
--- a/SHT_v1/.meta	Mon Sep 27 15:52:09 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<root>
-  <global/>
-  <data>
-    <created_ts>1284884416</created_ts>
-    <last_mod_ts>1284989117</last_mod_ts>
-    <is_archive>0</is_archive>
-    <is_published>0</is_published>
-    <is_svn>0</is_svn>
-    <is_module>0</is_module>
-    <is_lib>1</is_lib>
-    <url>http://mbed.org/users/roselea/programs/SHT_v1</url>
-    <url_full>http://mbed.org/users/roselea/programs/SHT_v1/5ye5b</url_full>
-    <rev>5ye5b</rev>
-  </data>
-</root>
--- a/WeatherMeters/.meta	Mon Sep 27 15:52:09 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-<?xml version="1.0"?>
-<root>
-  <global/>
-  <data>
-    <created_ts>1285492351</created_ts>
-    <last_mod_ts>1285492351</last_mod_ts>
-    <is_archive>0</is_archive>
-    <is_published>0</is_published>
-    <is_svn>0</is_svn>
-    <is_module>0</is_module>
-    <is_lib>1</is_lib>
-    <path>/Weather/WeatherMeters</path>
-    <chars>1478</chars>
-    <enable_beta_0006>true</enable_beta_0006>
-    <compiler_version>1.3.0.13</compiler_version>
-    <lines>99</lines>
-    <duration>2492</duration>
-    <rmchars>2730</rmchars>
-  </data>
-</root>
--- a/WeatherMeters/WeatherMeters.cpp	Mon Sep 27 15:52:09 2010 +0000
+++ b/WeatherMeters/WeatherMeters.cpp	Tue Oct 12 16:07:08 2010 +0000
@@ -51,13 +51,13 @@
     float v;
 
     if (windspeed == 0) windvane = ain01;
-	v = windvane * WEATHER_VREF; // V
-	v = v / ((WEATHER_VREF - v) / 10000.0); // ohm
-	for (i = 0; i < 16; i ++) {
-		if (v > tbl_windvane[i][1] * 0.9 && v < tbl_windvane[i][1] * 1.1) {
-			return tbl_windvane[i][0];
-		}
-	}
+    v = windvane * WEATHER_VREF; // V
+    v = v / ((WEATHER_VREF - v) / 10000.0); // ohm
+    for (i = 0; i < 16; i ++) {
+        if (v > tbl_windvane[i][1] * 0.9 && v < tbl_windvane[i][1] * 1.1) {
+            return tbl_windvane[i][0];
+        }
+    }
     return 0;
 }
 
@@ -93,17 +93,17 @@
         time_anemo ++;
     }
     
-	time_rain ++;
-	if (time_rain >= 4 * 300) {
-		n = 0;
-		for (i = 11; i > 0; i --) {
-			buf_rain[i] = buf_rain[i - 1];
-			n = n + buf_rain[i];
-		}
-		buf_rain[0] = count_rain;
-		n = n + buf_rain[0];
-		count_rain = 0;
-		time_rain = 0;
-		raingauge = n;
-	}
+    time_rain ++;
+    if (time_rain >= 4 * 300) {
+        n = 0;
+        for (i = 11; i > 0; i --) {
+            buf_rain[i] = buf_rain[i - 1];
+            n = n + buf_rain[i];
+        }
+        buf_rain[0] = count_rain;
+        n = n + buf_rain[0];
+        count_rain = 0;
+        time_rain = 0;
+        raingauge = n;
+    }
 }
--- a/main.cpp	Mon Sep 27 15:52:09 2010 +0000
+++ b/main.cpp	Tue Oct 12 16:07:08 2010 +0000
@@ -11,6 +11,14 @@
 
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX);
+AnalogIn photo(p18);
+
+float get_photo (AnalogIn &ain) {
+    float f;
+    
+    f = ain * 5.0 / 1000; // A
+    return f / 0.0000026;
+}
 
 int main() {
     while(1) {
@@ -24,6 +32,8 @@
 
         pc.printf("a:%6.2f m/s / v:%6.2f / r:%6.2f mm\n", wmeters.get_windspeed(), wmeters.get_windvane(), wmeters.get_raingauge());
 
+        pc.printf("l:%6.2f lux\n", get_photo(photo));
+
         myled = 0;
         wait(10);
     }