温度をIFTTTにプッシュするサンプルです。

Dependencies:   EthernetInterface IFTTT mbed-rtos mbed

Fork of IFTTT_Ethernet_Example by Austin Blackstone

Committer:
jksoft
Date:
Mon Sep 14 14:48:30 2015 +0000
Revision:
2:6b86ba5c0e84
Parent:
1:3010b44f07ff
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 0:0f0676c43e4b 1 #include "mbed.h"
mbedAustin 0:0f0676c43e4b 2 #include "EthernetInterface.h"
mbedAustin 1:3010b44f07ff 3 #include "TCPSocketConnection.h"
mbedAustin 1:3010b44f07ff 4 #include "ifttt.h"
mbedAustin 1:3010b44f07ff 5
mbedAustin 0:0f0676c43e4b 6 EthernetInterface eth;
mbedAustin 1:3010b44f07ff 7 RawSerial pc(USBTX, USBRX); // tx, rx
jksoft 2:6b86ba5c0e84 8 AnalogIn ain(p15);
mbedAustin 0:0f0676c43e4b 9
mbedAustin 1:3010b44f07ff 10 int main()
mbedAustin 0:0f0676c43e4b 11 {
mbedAustin 1:3010b44f07ff 12 pc.baud(9600);
mbedAustin 0:0f0676c43e4b 13 eth.init(); //Use DHCP
mbedAustin 0:0f0676c43e4b 14 eth.connect();
mbedAustin 0:0f0676c43e4b 15 printf("IP Address is %s \n\r", eth.getIPAddress());
mbedAustin 1:3010b44f07ff 16 TCPSocketConnection socket;
mbedAustin 1:3010b44f07ff 17
mbedAustin 1:3010b44f07ff 18 // Initialize ifttt object, add up to 3 optional values, trigger event.
mbedAustin 1:3010b44f07ff 19 IFTTT ifttt("YourEventName","ChangeToYourSecretKey", &socket); // EventName, Secret Key, socket to use
jksoft 2:6b86ba5c0e84 20
jksoft 2:6b86ba5c0e84 21 float tmp;
jksoft 2:6b86ba5c0e84 22 char msg[10];
jksoft 2:6b86ba5c0e84 23
jksoft 2:6b86ba5c0e84 24 tmp = (ain - 0.1818)/0.00303;
jksoft 2:6b86ba5c0e84 25
jksoft 2:6b86ba5c0e84 26 sprintf(msg,"%f",tmp);
jksoft 2:6b86ba5c0e84 27
jksoft 2:6b86ba5c0e84 28 printf("msg:%s\r\n",msg);
mbedAustin 1:3010b44f07ff 29
mbedAustin 1:3010b44f07ff 30 // Send Data using POST
jksoft 2:6b86ba5c0e84 31 ifttt.addIngredients(msg,"","");
mbedAustin 1:3010b44f07ff 32 ifttt.trigger(IFTTT_POST);
mbedAustin 1:3010b44f07ff 33
mbedAustin 1:3010b44f07ff 34 eth.disconnect();
mbedAustin 0:0f0676c43e4b 35 while(1) {
mbedAustin 0:0f0676c43e4b 36 }
mbedAustin 0:0f0676c43e4b 37 }