Sending data via text message

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:

  1. To do that, the first step is to connect the SMS channel to your IFTTT account. It's very simple, and you will just have to put in your phone number:
    Sending data via text message
  2. It's now time to create a new recipe. This time, use data as the name of the event:
    Sending data via text message
  3. Then, select the newly created SMS channel as the action of the recipe:
    Sending data via text message
  4. Now, we are going to build a more complex message than earlier, because we want to have the information about the measurements done by the ESP8266 in the message. Thanks to IFTTT, it's very easy using the assistant to add values coming from the trigger channel:
    Sending data via text message
  5. This is how your message should look at the end:
    Sending data via text message
  6. Finally, create the recipe:
    Sending data via text message

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:

  1. You need to include the DHT library:
    #include "DHT.h"
  2. Then, we set the DHT sensor pin and type:
    #define DHTPIN 5
    #define DHTTYPE DHT11
  3. We also create an instance of the DHT sensor:
    DHT dht(DHTPIN, DHTTYPE, 15);
  4. This time, we name the event data:
    const char* eventName   = "data";
  5. In the setup() function of the sketch, we initialize the DHT sensor:
    dht.begin();
  6. Then, inside the loop() function, we measure data from the sensor:
    float h = dht.readHumidity();
    float t = dht.readTemperature();
  7. After that, we put the data that was just measured into the request:
    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:

Sending data via text message
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.172.132