Interface with the If This Then That (IFTTT). This example uses both POST and GET to interface with IFTTT. Up to 3 values can be sent along with the trigger event name.

Dependencies:   ESP8266Interface IFTTT mbed

Fork of IFTTT_Ethernet_Example by Austin Blackstone

Committer:
mbedAustin
Date:
Sun Jan 03 02:04:31 2016 +0000
Revision:
4:3c8b0feb18e4
Parent:
1:15dd4d0a3af0
updated IFTTT library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 0:0f0676c43e4b 1 #include "mbed.h"
mbedAustin 1:15dd4d0a3af0 2 #include "ESP8266Interface.h"
mbedAustin 1:15dd4d0a3af0 3 #include "TCPSocketConnection.h"
mbedAustin 1:15dd4d0a3af0 4 #include "ifttt.h"
mbedAustin 1:15dd4d0a3af0 5
mbedAustin 1:15dd4d0a3af0 6 ESP8266Interface wifi(D1,D0,D2,"ssid","passkey",115200); // TX,RX,Reset,SSID,Password,Baud
mbedAustin 1:15dd4d0a3af0 7 RawSerial pc(USBTX, USBRX); // tx, rx
mbedAustin 0:0f0676c43e4b 8
mbedAustin 1:15dd4d0a3af0 9 int main()
mbedAustin 0:0f0676c43e4b 10 {
mbedAustin 1:15dd4d0a3af0 11 pc.baud(9600);
mbedAustin 1:15dd4d0a3af0 12 wifi.init(); //Reset
mbedAustin 1:15dd4d0a3af0 13 wifi.connect(); //Use DHCP
mbedAustin 1:15dd4d0a3af0 14 printf("IP Address is %s \n\r", wifi.getIPAddress());
mbedAustin 1:15dd4d0a3af0 15 TCPSocketConnection socket;
mbedAustin 0:0f0676c43e4b 16
mbedAustin 1:15dd4d0a3af0 17 // Initialize ifttt object, add up to 3 optional values, trigger event.
mbedAustin 1:15dd4d0a3af0 18 IFTTT ifttt("YourEventName","ChangeToYourSecretKey", &socket); // EventName, Secret Key, socket to use
mbedAustin 1:15dd4d0a3af0 19 ifttt.addIngredients("this is awesome","test-ing","data!!!"); // 3 optional Values to send along with trigger.
mbedAustin 1:15dd4d0a3af0 20 ifttt.trigger();
mbedAustin 1:15dd4d0a3af0 21
mbedAustin 1:15dd4d0a3af0 22 ifttt.addIngredients("Sending","GET","data");
mbedAustin 1:15dd4d0a3af0 23 ifttt.trigger(IFTTT_GET);
mbedAustin 1:15dd4d0a3af0 24
mbedAustin 1:15dd4d0a3af0 25 ifttt.addIngredients("Sending","POST","things");
mbedAustin 1:15dd4d0a3af0 26 ifttt.trigger(IFTTT_POST);
mbedAustin 0:0f0676c43e4b 27 while(1) {
mbedAustin 0:0f0676c43e4b 28 }
mbedAustin 0:0f0676c43e4b 29 }