Simpe IoT BoardにGrove温度センサを繋げてIFTTTにプッシュするプログラムです。

Dependencies:   ESP8266Interface IFTTT mbed

Fork of SimpleIoTBoard_sample by Junichi Katsu

Files at this revision

API Documentation at this revision

Comitter:
jksoft
Date:
Thu Nov 12 16:22:27 2015 +0000
Parent:
4:3994cd534bd5
Commit message:
??

Changed in this revision

IFTTT.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 3994cd534bd5 -r 2039ddc6f807 IFTTT.lib
--- a/IFTTT.lib	Mon Jul 27 11:43:18 2015 +0000
+++ b/IFTTT.lib	Thu Nov 12 16:22:27 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/mbedAustin/code/IFTTT/#15c6c9f87c32
+https://developer.mbed.org/users/mbedAustin/code/IFTTT/#416f902512f4
diff -r 3994cd534bd5 -r 2039ddc6f807 main.cpp
--- a/main.cpp	Mon Jul 27 11:43:18 2015 +0000
+++ b/main.cpp	Thu Nov 12 16:22:27 2015 +0000
@@ -4,9 +4,28 @@
 #include "ifttt.h"
 #include "SoftSerialSendOnry.h"
 
+AnalogIn thermistor(dp13);   /* Temperature sensor connected to Analog Grove connector */
+
 ESP8266Interface wifi(dp16,dp15,dp4,"SSID","Password",115200); // TX,RX,Reset,SSID,Password,Baud
+
 SoftSerialSendOnry pc(dp10); // tx
 
+float getTemperature()
+{
+    unsigned int a, beta = 3975;
+    float temperature, resistance;
+
+    a = thermistor.read_u16(); /* Read analog value */
+    
+    /* Calculate the resistance of the thermistor from analog votage read. */
+    resistance= (float) 10000.0 * ((65536.0 / a) - 1.0);
+    
+    /* Convert the resistance to temperature using Steinhart's Hart equation */
+    temperature=(1/((log(resistance/10000.0)/beta) + (1.0/298.15)))-273.15; 
+
+	return(temperature);	
+}
+
 int main()
 {
     pc.baud(9600);
@@ -17,7 +36,11 @@
     
     // Initialize ifttt object, add up to 3 optional values, trigger event. 
     IFTTT ifttt("EventName","Secret Key", &socket); // EventName, Secret Key, socket to use
+
+	char tmp[64];
 	
-    ifttt.addIngredients("value1","value2","value3");
+	sprintf(tmp,"%f",getTemperature());
+
+    ifttt.addIngredients(tmp,"value2","value3");
     ifttt.trigger(IFTTT_POST);
 }