After having published my tutorial about sending SMS with the ESP32, I received some comments via the contact form of my website asking a way to send notifications for free. Today I’ll show you a way to do it; it will be also the occasion to write about IFTTT service and about developing custom components for the esp-idf framework.
IFTTT (IF This Then That) it’s a web service that allows to create applets connecting different services with the pattern if this happens, then do that action.
To better understand what you can do with IFTTT, here are some pre-built applets:
- send me an email if rain is expected tomorrow
- automatically post on Facebook the photos I share on Instagram
- turn on silence mode on my smartphone when I arrive at work
The main advantage of using IFTTT is indeed the availability of many services ready to use: starting from the ones which query weather forecast providers, to services which connect to famous social networks and even including services that can talk to smart devices like FitBit bracelets or Nest thermostats.
Among the many services IFTTT offers, one is very handy to integrate IFTTT with IoT devices: the Maker Webhooks service. As the name suggests, this service allows applets to interface with the Web. If you add it as a This service (trigger, source of the event that activates the applet) Maker Webhooks allows to send an event to the applet using a web request (GET or POST), while if you add it as a That service (action that the applet performs), Maker Webhooks allows the applet to make a web call:
The Maker Webhooks service is the first element of our applet: thanks to it we’ll be able to activate the applet with a web request performed by the ESP32 chip and we’ll be also able to pass optional values to the applet itself.
The second service we’ll be using is called Notifications: using this service the applet can send notifications to our smartphone. The only requirement is that our smartphone is running the IFTTT app and that we log in with the same account used to create the applet.
Let’s see how to build the applet. After having registered to the website, click on New Applet.
First click on this:
Type some letters of “Maker Webhooks” to search the service, then click on its icon:
Select the only trigger the service offers:
Type the name of the event that will activate the applet. You can choose the name we prefer; the same name will be used when making the web request:
Now click on that:
Search and select the Notifications service:
Click on the only action the service offers:
Customize the message that will be displayed as notification. You can also include some custom values that will be received by the applet via the web call, together with the event name:
Complete the wizard with a click on Finish:
To be able to send a request to the Maker Webhooks service, you must specify your personal key. Connect to the service’s homepage and click on Settings:
Copy the key, that is the string after /use/ in the service URL:
To simplify the interaction with the Maker Webhooks service, I developed a component that is ready to use with the esp-idf framework. You can compare components to libraries, reusable code elements for your programs. You only need to copy the component’s folder within the components folder of your project to be able to use it:
I prepared a demo program that sends notifications using IFTTT applets; its source code is on Github.
Here’s a video that shows how it works (italian subtitles are available):
[youtube id=”amb0Tdu2Lns” width=”600″ height=”350″]