Security System via IFTTT

With this project, we create a security device that employs a PIR Sensor to detect intruders or stray animals entering your home. In case of a breach, you will receive an email alert.

We’ll utilize Webhooks as the fundamental service. A POST request is sent to IFTTT’s service from UNO R4.

Required Components

In this project, we need the following components.

It’s definitely convenient to buy a whole kit, here’s the link:




Elite Explorer Kit


Elite Explorer Kit

You can also buy them separately from the links below.



Arduino Uno R4 WiFi


Jumper Wires


PIR Motion Sensor Module






Setting up IFTTT

IFTTT is a free service that offers various methods to link different data services together.

Let’s create an Applet that responds to a webhook (custom URL) sending data to IFTTT, which will then send you an email.

Please follow the steps below on IFTTT.

  1. Visit IFTTT to log in or create an account.

  2. Click on Create.

  3. Add an If This event.

  4. Search for Webhooks.

  5. Select Receive a web request.

  6. Fill in the event name (e.g., SecurityWarning), and click Create trigger.

  7. Add a Then That event.

  8. Search for Email.

  9. Choose Send me an email.

  10. Enter the Subject and Body, then click Create action.

  1. Click Continue to finish the setup.

  1. Adjust the title name as needed.

  1. You’ll be automatically redirected to the Applet details page, where you can see that the Applet is currently connected and you can toggle the switch to enable/disable it.

  1. Now that we’ve created the IFTTT Applet, we also need the webhooks key, which can be obtained from Webhooks Settings to allow your device to access IFTTT.

  1. Copy the webhooks key to “arduino_secrets.h” and fill in your SSID and password.

    #define SECRET_SSID "your_ssid"        // your network SSID (name)
    #define SECRET_PASS "your_password"        // your network password (used for WPA, or as a key for WEP)
    #define WEBHOOKS_KEY "your_key"

Run the Code


  • You can open the file 03_ifttt_pir.ino under the path of elite-explorer-kit-main\iot_project\03_ifttt_pir directly.

  • Or copy this code into Arduino IDE.


In the code, SSID and password are stored in arduino_secrets.h. Before uploading this example, you need to modify them with your own WiFi credentials. Additionally, for security purposes, ensure that this information is kept confidential when sharing or storing the code.


To prevent your mailbox from being flooded, please debug the PIR Motion Sensor Module beforehand before running the code for this project.

How it works?

  1. Include the necessary libraries and header files:

    • "WiFiS3.h": Used for managing Wi-Fi connections.

    • "arduino_secrets.h": Contains Wi-Fi network name and password to safeguard sensitive information.

  2. Define some global variables and constants:

    • ssid: Name of the Wi-Fi network.

    • pass: Wi-Fi network password.

    • status: Status of the Wi-Fi connection.

    • client: Client used for communicating with the Wi-Fi server.

    • server: Address of the IFTTT Webhook server.

    • event: Name of the IFTTT Webhook event.

    • webRequestURL: Constructed URL for sending HTTP requests, including the Webhook event name and key.

    • pirPin: Digital pin to which the PIR sensor is connected.

    • motionDetected: Flag variable to track motion detection.

  3. setup() function:

    • Initializes serial communication.

    • Checks for the presence of the Wi-Fi module and outputs its firmware version.

    • Attempts to connect to the Wi-Fi network, with retries if unsuccessful.

    • Sets the pin connected to the PIR sensor to input mode.

  4. readResponse() function:

    • Reads HTTP response data from the IFTTT server and prints it to the serial console.

  5. loop() function:

    • Calls the readResponse() function to read HTTP response data.

    • Checks for motion using the PIR sensor. If motion is detected and was not detected previously:
      • Prints “Motion detected!” to the console.

      • Calls the triggerIFTTTEvent() function to send an HTTP request to the IFTTT server, triggering the Webhook event.

      • Sets the motionDetected flag to true to indicate motion has been detected.

    • If no motion is detected, sets the motionDetected flag to false.

  6. triggerIFTTTEvent() function:

    • Establishes a connection with the IFTTT server.

    • Sends an HTTP GET request, including the URL of the Webhook event and other HTTP headers.

  7. printWifiStatus() function:

    • Outputs information about the connected Wi-Fi network, including SSID, IP address, and signal strength (RSSI) to the serial console.