jajn HA / Mbed OS wind

Files at this revision

API Documentation at this revision

Comitter:
david8251
Date:
Thu Jul 20 08:46:05 2017 +0000
Commit message:
wind direction

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 461d3043a9a7 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 20 08:46:05 2017 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+Serial wind(P0_2, P0_3);
+
+void windy();
+int main() {
+      while(1){
+          windy();
+          wait(3);    
+    }
+}
+void windy(){
+char command[17];
+int i = 0;
+int j=1;
+float  windSpeed;
+int windDirection;
+            for(j=1;j<17;j++)
+            {
+                command[i]= wind.getc();
+                i++;
+            }
+         pc.printf("\r\n");  
+         if(command[0]==0x3A){
+         windSpeed=((command[8]-48)*10000+(command[9]-48)*1000+(command[10]-48)*100+(command[12]-48)*10+(command[13]-48))/100.0;
+         windDirection= (command[4]-48)*100+(command[5]-48)*10+(command[6]-48);          
+         pc.printf("The Wind Speed is %.2f (m/s)\r\n",windSpeed);
+         pc.printf("The Wind Direction is %d",windDirection);
+         }
+         pc.printf("\r\n");   
+}
+
+//3A 30 31 3B 30 34 33 3B 30 30 32 2E 34 32 3B 46
+//The Wind Speed is 0.420000 (m/s)
+//                                The Wind Direction is 43
+
+// 3A 30 31 3B 33 33 31 3B 30 30 32 2E 33 36 3B 46
+//The Wind Speed is 2.36 (m/s)
+//The Wind Direction is 331
diff -r 000000000000 -r 461d3043a9a7 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Jul 20 08:46:05 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#0712b8adf6bbc7eb796d5dac26f95d79d40745ef