Example Code for Arduino-IFTTT

Last revision 2026/01/31

This article explains how to use Arduino to work with IFTTT, setting up automated triggers and actions to send emails using Webhooks and Email in a step-by-step guide.

What is IFTTT?

If This Then That (commonly known as IFTTT), is a web-based service that allows users to create chains of conditional statements triggered by changes that occur within other web services. It is both a website and a mobile app of free service with the following slogan: "Put the Internet to work for you".

IFTTT aims to help people use the open API of various websites to monitor the triggers set by users. If triggers are triggered, actions set by users will be executed. Usually, we can create n applets to meet our various automation needs.

DFR0654-IFTTT

Sending Email

This application utilizes two small programs, Webhooks and Email, to achieve sending an HTTP POST request every 10 seconds. Once the Trigger is activated, the Action is executed to send a data email.

Operation Steps

  • Access the IFTTT website: https://ifttt.com/

  • Register an account if you don't have one.

  • Configure IFTTT

  • Step 1. Create Trigger

  1. Sign in the IFTTT, click "create" to create your APP.
    DFR0654-IFTTT step 1

  2. Click "Add" in ”If This".
    DFR0654-IFTTT step 2

  3. Input "Webhooks".
    DFR0654-IFTTT step 3

  4. Click to enter "Webhooks", and select "Receive a web request".
    DFR0654-IFTTT step 4

  5. Next, create our Event Name "message" and click "Create trigger" to complete the setup for "this".
    DFR0654-IFTTT step 5

  • Step 2. Create Action
  1. After setting up the trigger for "this", proceed to add the action instruction for "that" by clicking "Add" in the "Then That" section.
    DFR0654-IFTTT step 6

  2. Search and click on "Email".
    DFR0654-IFTTT step 7

  3. Select "Send me am email".
    DFR0654-IFTTT step 8

  4. Once selected, you can edit the email content by entering the email subject in the "subject" field and the email body in the "Body" field. Then click "Create action" to complete the creation.
    DFR0654-IFTTT step 9

  5. Click "Continue".
    DFR0654-IFTTT step 10

  6. Review and then click "Finish".
    DFR0654-IFTTT step 11

  • Step 3. Find IFTTT_Key
  1. Click "My services"
    DFR0654-IFTTT step 12

  2. Click "Webhooks"
    DFR0654-IFTTT step 13

  3. Click "Documentation"
    DFR0654-IFTTT step 14

  4. Copy the key at the position shown below in the diagram.
    DFR0654-IFTTT step 15

Sample Code

  • Burning Arduino sketch
  • Open the built-in sample sketch
    DFR0654-IFTTT Code

If a "message" is received, FireBeetle 2 ESP32-E send email to the preset email address.

#include <WiFi.h>
#include <HTTPClient.h>
//Configure WiFi name and password
char *WIFI_SSID           = "WIFI_SSID";
char *WIFI_PASSWORD       = "WIFI_PASSWORD";
//Configure IFTTT
char *IFTTT_ENVENT        = "Your_Event";
char *IFTTT_KEY           = "Your_Key";
//IFTTT Send Message
char *IFTTT_VALUE_1       = "Value1";
char *IFTTT_VALUE_2       = "Value2";
char *IFTTT_VALUE_3       = "Value3";
HTTPClient ifttt;
unsigned long lastTime = 0;
unsigned long timerDelay = 10000;
void setup() {
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Wifi Connect Success");
}
void loop() {
//Send an HTTP POST request every 10 seconds
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
      ifttt.IFTTTBeging(IFTTT_ENVENT,IFTTT_KEY);
      int dataSendState = ifttt.IFTTTSend(IFTTT_VALUE_1,IFTTT_VALUE_2,IFTTT_VALUE_3);
       Serial.println(dataSendState);//Whether the printing data is sent successfully
    }else {
    Serial.println("WiFi Disconnected");
    }
lastTime = millis();
  }
}
  • Configure Parameters in Arduino Code
//Configure WiFi name and password
char *WIFI_SSID           = "WIFI_SSID";//Input WiFi name 
char *WIFI_PASSWORD       = "WIFI_PASSWORD";//Input WiFi Password 
//Configure IFTTT
char *IFTTT_ENVENT        = "Your_Event";//Input Event Name 
char *IFTTT_KEY           = "Your_Key";//Input the key you found in IFTTT
//IFTTT Send Message
char *IFTTT_VALUE_1       = "Value1";
char *IFTTT_VALUE_2       = "Value2";
char *IFTTT_VALUE_3       = "Value3";//Configure the three values in email information 

Result

Receive the data from FireBeele-ESP32-E in the Email box.

DFR0654-IFTTT result

Was this article helpful?

TOP