We are now going to use the same hardware to make a completely different project. We'll use IFTTT again to send measurement data from the ESP8266 chip to your mobile phone:
Now that the recipe is active, we can move on to the creation of the Arduino sketch. As there are many elements in common with the previous sketch, I will only detail the important elements here:
#include "DHT.h"
#define DHTPIN 5 #define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE, 15);
data
:const char* eventName = "data";
setup()
function of the sketch, we initialize the DHT sensor:dht.begin();
loop()
function, we measure data from the sensor:float h = dht.readHumidity(); float t = dht.readTemperature();
String url = "/trigger/"; url += eventName; url += "/with/key/"; url += key; url += "?value1="; url += String(t); url += "&value2="; url += String(h);
It's now time to test the sketch! Grab it from the GitHub repository for the book, and make sure to modify the sketch with your Wi-Fi settings and IFTTT data.
Then, upload the code to the board. After a few moments, you should receive a message on your mobile phone showing the data that was measured:
18.223.172.132