ThingSpeak IoT Notification with IFTTT
This blog post is part two of the ThingSpeak IoT posts, part one you can find here.
In this post we react to the humidity value of the sensor, if it’s too humid. The optimal humidity of a room is between 40% to 60%, so we will send an email when the value is bigger than 60. To do so, we need 3 services:
If you do not have an IFTTT account yet, create one. Go to „My Applets“ in the top menu, then select „New Applet“. Click on the „+this“ link to define which events triggers the applet.
- Search and choose „Webhooks“ as service
- Use the „Receive a web request“ service
- Choose an event name, in this case i choose „humidity“
Now you defined the trigger of the applet, next you have to define the reaction. To do so, click on the „+that“ link.
- Search and choose „Email“ as service
- Use the „Send me an email“ service
- Define the subject and the message body of the email. Value1, value2 and value3 you can send within the request we create later on.
Click on „Create Action“ and the „Finish“ to create and activate the applet.
For the next step you need your webhook URL, where you have to send the event to. Click on your account in the upper right corner, select „Services“ and „Webhooks“. On the webhooks page click on „Settings“, then visit the URL provided in „Account Info“ (should look something like this: https://maker.ifttt.com/use/YOURKEY). You will get a page that shows your key and an example how to trigger an event (the event URL looks like this: https://maker.ifttt.com/trigger/EVENTNAME/with/key/YOURKEY). Insert the event name you choose to trigger and copy the URL, you will need it in the next step.
To activate the previously defined event on IFTTT we need a HTTP request from ThingSpeak. This can be done with the ThingHTTP app, which you can find on the top menu in the category „Apps“. To create a new request click on the „New ThingHTTP“ Button. Paste the previously copied URL into the „URL“ Field. Method is „POST“ and „Content Type“ is „application/json“ if you want to send some additional information in the body. Give it a name and then save the new ThingHTTP.
Now we need an app that reacts to our humidity sensor value and triggers the ThingHTTP app. This can be done in ThingSpeak with the React app. You will also find it in the Apps category. Click on „New React“ to create a new one and set the values like in the picture below.
Now you will receive an email, if the humidity value is too high.