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:44:01 2010 +0000
Parent:
1:23400c328a71
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 23400c328a71 -r 920a4e65129d main.cpp
--- a/main.cpp	Tue Oct 12 16:07:08 2010 +0000
+++ b/main.cpp	Tue Oct 12 16:44:01 2010 +0000
@@ -12,12 +12,28 @@
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX);
 AnalogIn photo(p18);
+AnalogIn moist(p16);
+AnalogIn uv(p15);
 
 float get_photo (AnalogIn &ain) {
     float f;
     
     f = ain * 5.0 / 1000; // A
-    return f / 0.0000026;
+    return f / 0.0000026; // lx
+}
+
+float get_moist (AnalogIn &ain) {
+    float f;
+    
+    f = ain * 5.0; // V
+    return f / ((3.3 - f) / 10.0); // k ohm
+}
+
+float get_uv (AnalogIn &ain) {
+    float f;
+    
+    f = ain * 5.0 / 100000; // A
+    return f / 0.000384; // mW/cm2
 }
 
 int main() {
@@ -32,7 +48,9 @@
 
         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));
+        pc.printf("l:%6.2f lx\n", get_photo(photo));
+        pc.printf("l:%6.2f k ohm\n", get_moist(moist));
+        pc.printf("l:%6.2f mW/cm2\n", get_uv(uv));
 
         myled = 0;
         wait(10);