This post may contain affiliate links. See the Affiliate Disclosure for more information.
Use of information on this site is at your own risk. View the Terms of Service.

AD: This post was reviewed by Grammarly, the Best Automated Proofreader.

I’ve had a bit of an Internet of Things (IoT) bug the last couple of weeks. For those of you who are new to the blog, welcome! I’m glad you’re following along with my tutorials. Hopefully you’re making some really cool things!

Before we dive right into prototyping and code, and whatnot, I wanted to provide you the backstory for how this project came to be.

Motivation for this Project

I was on a walk the other evening (walks are kind of my thing), and came home to a very dark house. It had me thinking, what if my lights automatically came on when I opened the patio door…

And I know, I could go out and buy something that already works out of the box, but being the brains behind Learn Robotics, I figured, “hey! let’s create a prototype!”

I got to thinking about all the ways we could do this –, Node-RED, Raspberry Pi, Arduino… then it dawned on me that if I used IFTTT and Arduino, I wouldn’t need to have a computer running Node-RED or a Python script all the time, and I could use the IFTTT compatibility to trigger my Philips Hue lights.

Connect Arduino to IFTTT for IoT Projects
  • Facebook
  • Twitter
  • Pinterest

So, in this tutorial, I’m going to walk you through how to connect your Arduino to IFTTT. In a later tutorial, I’ll walk you through a tiny (low-power) device that you can use to build your own trigger for your lights.

Things you’ll need

For this project, I will be using a Wemos D1 Mini. You could also use a NodeMCU or other WiFi-enabled Arduino controller (ESP8266). If you’re just getting started with IoT, I recommend picking up this NodeMCU kit and supplementing it with a Wemos D1 Mini. This will provide you the maximum sensors and prototyping components for under $40.

Connect Arduino to IFTTT for IoT Projects

Now that we have our components, it’s time to get prototyping. I’m keeping things SUPER simple and wiring up a rotational potentiometer to pin A0 on the Wemos.

Here’s a quick schematic:

Connect Arduino to IFTTT for IoT Projects
  • Facebook
  • Twitter
  • Pinterest

Go ahead and wire up your board before moving on with this tutorial. I also wrote a tutorial on how to wire a breadboard, to help you get started.

Ready to get started? I’ve broken this project into four steps.

  1. Connect the Wemos D1 Mini to the Internet (the good-ole www)
  2. Publish readings to an “Event” using the Webhooks channel
  3. Collect readings from the potentiometer
  4. Create an Applet in IFTTT to receive notifications from the Wemos

In a future tutorial, I plan to use this methodology to create a “trip” sensor and control my lights at night. (Which I will share with you once I build it!)

Now, let’s grab our Wemos, and get it connected to the Internet.

Step #1: Connect the Wemos D1 Mini to the Internet

Similarly to the Tutorial, you’ll connect your Wemos D1 Mini to the internet. First, we’ll identify the SSID (network name) and Password (network password). Then, we’ll create an account on IFTTT and open the Webhook service. I used the browser version of IFTTT to set all of this up.

On the Webhook service page, click “Documentation”. You’ll be brought to a page like this:

Connect Arduino to IFTTT for IoT Projects
  • Facebook
  • Twitter
  • Pinterest

Copy the key information. Now open up your Wemos program and define two IFTTT parameters: MakerIFTTT_Key[] and MakerIFTTT_Event[].

The IFTTT Key is the key you copied from the Documentation page on IFTTT. The {event} is the name of the event you want to track. I’ve named mine “wemos-trigger”.

Then, we’ll define a WiFiClient client and our potentiometer pin (pot). When all’s said and done, this is what your code should look like.

Now, we’ll setup the wifi connection. I’ve created a separate method for this, called setupWiFi().

This method will use your SSID and Password info to connect to your network. It allows 15 tries before it completely fails. We’ll call setupWiFi() method in our setup() method after initializing the serial monitor Serial.begin(115200). Lastly, we’ll set the pinMode for our potentiometer. Here’s the updated code.

Upload the code to your Wemos, and verify that you can connect to your network. Then, move on to Step #2.

Step #2: Publish readings to an “Event” using the Webhooks channel

Connect Arduino to IFTTT for IoT Projects
  • Facebook
  • Twitter
  • Pinterest

This is where the magic happens! We’re going to publish information from the Wemos to IFTTT using a POST Request. I modified this code from a tutorial I found using an Ethernet shield, so full credit for these helper methods goes to Neil Webber.

Essentially, there are two helper methods that help construct the POST data (aka, what we want to send to IFTTT). Then there’s a POST trigger method that fires the data up to IFTTT.

I’ve updated the code with these new methods. Neil did a great job of documenting each line, so it’s fairly easy to figure out what’s going on here.

On line #90, we collect a reading from the potentiometer using the analogRead(pot) method. The Webhook service on IFTTT allows you to send 3 values in a POST. I’m not using the other 2 values (other than accumulated time and a string “hello world”). Feel free to modify this for additional information or sensors connected to your Wemos.

Step #3: Collect readings from the potentiometer

So rather than publish every single potentiometer reading, I want to only send a POST when the potentiometer reading is different than the previous reading. I also want to account for a +/- 10% difference in readings. Therefore, we will only send a reading to IFTTT when the potentiometer reading is less than 90% of the current reading, or greater than 110% of the current reading.

To do this, I’ve created a separate method called checkSensorThenPub().

First, we read the potentiometer reading and store it in a variable, currPotValue. Then we calculate our thresholds (minus10perc and plus10perc). Then we delay for a timeframe (10-30 seconds) and collect a second reading. If the second reading is greater than plus10per or less than minus10perc, we call the updateEvent() method.

Call this method in your loop() method, and upload it to your Wemos!

You can make modifications to this code depending on your application!

Step #4: Create an Applet in IFTTT to receive notifications from the Wemos

Before we can fully test this out, you’ll need to create an Applet in IFTTT to receive notifications. Out of all the steps, this one is the easiest to configure, so congrats for making it this far!

Connect Arduino to IFTTT for IoT Projects
  • Facebook
  • Twitter
  • Pinterest

  1. Open IFTTT (either the smartphone app or the browser version).
  2. Click on “My Applets”
  3. Choose the New Applet button in the top right
  4. On the New Applet Page, click the +this blue button
  5. It will say “Choose a service”. Type in Webhooks in the Search Services textbox. choose Webhooks when it appears.
  6. Then, for Step 2 Choose trigger, select “Receive a web request”. Type “wemos-trigger” in the Event Name field. Press “Create Trigger” button
  7. Next, click the +then button.
  8. For Choose action service, type in “Notifications”. Select the Notifications option.
  9. Then, for the Choose action page, pick “Send a notification from the IFTTT app.” This requires the IFTTT app installed on your smartphone (or access to the Activity page in your browser).
  10. On the Complete action fields page, click “Create Action” button
  11. Finally, review and finish the Applet. Click the “Finish” button

Your Applet should be “ON” and ready to use. If your Wemos is connected to the Internet, and sending data, you should receive a notification in the IFTTT app or on the Activities page! 

The default values should be the potentiometer reading, the accrued time, and “hello world”. If you changed this, it’ll be whatever you set values 1-3 in the updateEvent() method.

Here’s what the notification looks like on the IFTTT iPhone App.

Connect Arduino to IFTTT for IoT Projects
  • Facebook
  • Twitter
  • Pinterest

Wrapping Up & Next Steps

And that’s it! We have our Arduino controller talking to IFTTT. Like I mentioned at the beginning of the article, the goal is to create a trip sensor to turn on my Philips Hue lights. This should give you a pretty solid start to solving this (and other IoT) projects using Arduino and IFTTT.

If you liked this article, be sure to click the 5-STAR review button below. This helps me gauge which articles you like, or find most helpful (so that I can write more of them!). If you want to support the work I do, feel free to buy me a coffee. Every article is fueled by many cups of coffee, so thank you! 🙂

Questions, comments, concerns? Drop them below. Happy to help you get your Arduino and IFTTT device up and running!

Like my work? Keep me caffeinated.

global robotics competition online

Get Notified of the Next Competition


Be the first to know when we launch our next online robotics competition. Plus gain FREE robotics tips to your inbox.

You have Successfully Subscribed!

liz miller learn robotics


Gain Access to FREE robotics projects.

You have Successfully Subscribed!


Enter your email below!

Get ready to build a tiny robot! Check your email for the download!

Gain Arduino Skills, FAST!

Take our online Arduino for Beginners Course, and learn to build projects using Arduino.

Enter your email to receive more information about the course.

learn to prototype with Arduino online course

You're in! Check your email for some awesome updates!

Pin It on Pinterest