This example sends temperature and humidity data to Ambient through ethernet. (Japanese: IoT用のクラウドサービス「Ambient」にLPC1768とイーサーネットを使ってデーターを送信するサンプルです。Ambientはマイコンから送られたセンサーデーターを受信し、蓄積し、可視化(グラフ化)します。 https://ambidata.io)

Dependencies:   AmbientLib EthernetInterface HDC1000 mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
AmbientData
Date:
Wed Jan 25 12:30:24 2017 +0000
Parent:
3:b17b789c0030
Commit message:
Ambient?????????

Changed in this revision

AmbientLib.lib 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
diff -r b17b789c0030 -r 51b4356b3198 AmbientLib.lib
--- a/AmbientLib.lib	Mon Jun 13 12:05:32 2016 +0000
+++ b/AmbientLib.lib	Wed Jan 25 12:30:24 2017 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/AmbientData/code/AmbientLib/#a724fe60de46
+http://developer.mbed.org/users/AmbientData/code/AmbientLib/#fcbd652bbb7a
diff -r b17b789c0030 -r 51b4356b3198 main.cpp
--- a/main.cpp	Mon Jun 13 12:05:32 2016 +0000
+++ b/main.cpp	Wed Jan 25 12:30:24 2017 +0000
@@ -3,8 +3,8 @@
 #include "Ambient.h"
 #include "HDC1000.h"
 
-unsigned int channelId = 100;
-const char* writeKey = "ライトキー";
+unsigned int channelId = 517;
+const char* writeKey = "0f63cc33c424afd0";
 Ambient ambient;
 
 HDC1000      hdc1000(p9,p10);
@@ -24,20 +24,20 @@
 
     while (true) {
         float temp, humid;
-        char tempbuf[12], humidbuf[12];
+        char humidbuf[12];
 
         hdc1000.get();
         temp = hdc1000.temperature();
         humid = hdc1000.humidity();
 
-        sprintf(tempbuf, "%2.1f", temp);
-        ambient.set(1, tempbuf);
-        sprintf(humidbuf, "%2.0f", humid);
+        printf("temp= %2.0f, humid= %2.0f\r\n", temp, humid);
+
+        ambient.set(1, temp);
+        snprintf(humidbuf, sizeof(humidbuf), "%2.0f", humid);
         ambient.set(2, humidbuf);
-        printf("Temp: %s C, Humid: %s %%\r\n", tempbuf, humidbuf);
-        
+
         ambient.send();
         
-        wait(30.0);
+        wait(300.0);
     }
 }