Webhooks key
Webhooks key
Triggering Webhooks Applets requires a unique key.
The key is available from the user profile (upper right side) by
clicking the My services menu option.
Look for the Webhooks service at the end of the page (services are
alphabetically ordered), click on it and then click on the Documentation button. A new page will show the key in a legend like
this: Your key is: ceubX8trC3ZXKFTrEMXc-Z.
Adding code
As mentioned before, we need to add some coding to connect the Arduino Uno to Internet (via the ESP8266 WiFi Module). The following lines show the code to insert for interaction with IFTTT.
Let’s start including two libraries to drive the WiFi module and IFTTT:
#include <esp8266wifi.h>
#include "IFTTTWebhook.h"
</esp8266wifi.h>
Then, add information related to WiFi connection (SSID and password):
#define WIFI_SSID "your SSID here"
#define WIFI_PASSWORD "your password here"
In the same way, we add information regarding IFTTT Applet (key and event
name):
#define IFTTT_API_KEY "ceubX8trC3ZXKFTrEMXc-Z" //the Webhooks key.
#define IFTTT_EVENT_NAME "oximetry_heart_rate_sensor" //the event name.
Add the following lines into the void
setup() function to establish an Internet connection and send sensor data
to IFTTT:
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
IFTTTWebhook wh(IFTTT_API_KEY, IFTTT_EVENT_NAME);
wh.trigger(value);
Each time the IFTTT Webhooks gets data from the sensor, it adds a new
row into the Google Sheets spreadsheet (creating a new spreadsheet if it
doesn’t exist) and stores in the first
column the date and time the lecture occurs. In the second column, it stores
the name of the event (remember, you can send to the same spreadsheet lectures
from different sensors, so it’s useful to differentiate each one from the
others).
The third column stores the water level value (from the value variable).
At the same time, the smartphone receives a notification from IFTTT (it
requires the installation of the IFTTT app in the smartphone).