Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example IFTTT and Arduino for SGuru 2017
IFTTT Channel Maker Posting Example
Andres Sabas @ The Inventor's House
Original Creation Date: Jan 10, 2016
This example demonstrates how to use the TCP client
functionality of the ESP8266 WiFiSecure library to post
to a IFTTT event on
Development environment specifics:
IDE: Arduino 1.6.5
Hardware Platform:
ESP8266 HUZZAH Adafruit
or NodeMCU: 1.0
This code is beerware; if you see me (or any other The Inventor's House
member) at the local, and you've found our code helpful,
please buy us a round!
Distributed as-is; no warranty is given.
//Include that library first:
#include <ESP8266WiFi.h>
// Include the ESP8266 WiFiSecure library:
#include <WiFiClientSecure.h>
// WiFi Network Definitions //
// Replace these two character strings with the name and
// password of your WiFi network.
const char mySSID[] = "YourWiFiName";
const char myPSK[] = "YourWifiPassword";
// IFTTT Constants //
// IFTTT destination server:
const char* IFTTTServer = "";
// IFTTT https por:
const int httpsPort = 443;
// IFTTT Event:
const String MakerIFTTT_Event = "button";
// IFTTT private key:
const String MakerIFTTT_Key = "YourPrivateKeyIFTTT";
String httpHeader = "POST /trigger/"+MakerIFTTT_Event+"/with/key/"+MakerIFTTT_Key +" HTTP/1.1\r\n" +
"Host: " + IFTTTServer + "\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n\r\n";
void setup()
int status;
Serial.print(F("connecting to "));
WiFi.begin(mySSID, myPSK);
while (WiFi.status() != WL_CONNECTED) {
Serial.println(F("WiFi connected"));
Serial.println(F("IP address is: "));
Serial.println(F("Press any key to post to IFTTT!"));
void loop()
// If a character has been received over serial:
if (Serial.available())
// !!! Make sure we haven't posted recently
// Post to IFTTT!
// Then clear the serial buffer:
while (Serial.available());
void postToIFTTT()
// Create a client, and initiate a connection
WiFiClientSecure client;
if (client.connect(IFTTTServer, httpsPort) <= 0)
Serial.println(F("Failed to connect to server."));
Serial.println(F("Posting to IFTT Event!"));
// available() will return the number of characters
// currently in the receive buffer.
while (client.available())
Serial.write(; // read() gets the FIFO char
// connected() is a boolean return value - 1 if the
// connection is active, 0 if it's closed.
if (client.connected())
client.stop(); // stop() closes a TCP connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.