ワークショップ用のプログラム

Dependencies:   AmbientLib SimpleIoTBoardLib mbed

Fork of AmbientExampleSITB by Takehiko Shimojima

Files at this revision

API Documentation at this revision

Comitter:
AmbientData
Date:
Sat May 07 02:27:04 2016 +0000
Child:
1:07639e90e2e8
Commit message:
Initial submission

Changed in this revision

AmbientLib.lib Show annotated file Show diff for this revision Revisions of this file
SimpleIoTBoardLib.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AmbientLib.lib	Sat May 07 02:27:04 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/AmbientData/code/AmbientLib/#7dca16f75bae
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SimpleIoTBoardLib.lib	Sat May 07 02:27:04 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/jksoft/code/SimpleIoTBoardLib/#890c12951e96
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat May 07 02:27:04 2016 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+#include "math.h"
+#include "ESP8266Interface.h"
+#include "TCPSocketConnection.h"
+#include "SoftSerialSendOnry.h"
+
+#include "Ambient.h"
+
+ESP8266Interface wifi(dp16,dp15,dp4,"SSID","Password",115200); // TX,RX,Reset,SSID,Password,Baud
+
+unsigned int channelId = 100;
+const char* writeKey = "ライトキー";
+AMBIENT ambient;
+
+AnalogIn thermistor(dp13);
+const int B=4275; // B value of the thermistor
+
+SoftSerialSendOnry pc(dp10);
+
+int main()
+{
+    TCPSocketConnection socket;
+
+    pc.baud(9600);
+
+    wifi.init(); //Reset
+    wifi.connect(); //Use DHCP
+    pc.printf("IP Address is %s\r\n", wifi.getIPAddress());
+
+    ambient.init(channelId, writeKey, &socket);
+
+    while (true) {
+        float temp;
+        char tempbuf[12];
+        int a = thermistor.read_u16();
+        
+        float R = 65535.0/((float)a)-1.0;
+        R = 100000.0*R;
+
+        //convert to temperature via datasheet ;
+        temp = 1.0/(log(R/100000.0)/B+1/298.15)-273.15;
+        
+        pc.printf("%4.2f\r\n", temp);
+
+        sprintf(tempbuf, "%2.1f", temp);
+        ambient.set(1, tempbuf);
+
+        ambient.send();
+
+        wait(30.0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat May 07 02:27:04 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file