Junichi Katsu / Mbed 2 deprecated IFTTT_Ethernet_LM61

Dependencies:   EthernetInterface IFTTT mbed-rtos mbed

Fork of IFTTT_Ethernet_Example by Austin Blackstone

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "EthernetInterface.h"
00003 #include "TCPSocketConnection.h"
00004 #include "ifttt.h"
00005 
00006 EthernetInterface eth;
00007 RawSerial pc(USBTX, USBRX); // tx, rx
00008 AnalogIn ain(p15);
00009 
00010 int main()
00011 {
00012     pc.baud(9600);
00013     eth.init(); //Use DHCP
00014     eth.connect();
00015     printf("IP Address is %s \n\r", eth.getIPAddress());
00016     TCPSocketConnection socket;
00017 
00018     // Initialize ifttt object, add up to 3 optional values, trigger event.
00019     IFTTT ifttt("YourEventName","ChangeToYourSecretKey", &socket); // EventName, Secret Key, socket to use
00020     
00021     float tmp;
00022     char msg[10];
00023     
00024     tmp = (ain - 0.1818)/0.00303;
00025     
00026     sprintf(msg,"%f",tmp);
00027     
00028     printf("msg:%s\r\n",msg);
00029 
00030     // Send Data using POST
00031     ifttt.addIngredients(msg,"","");
00032     ifttt.trigger(IFTTT_POST);
00033 
00034     eth.disconnect();
00035     while(1) {
00036     }
00037 }