In this second project of the chapter, we are going to do something different. We will monitor the temperature and humidity of the plant from the cloud dashboard that we already used earlier in the chapter. We are first going to configure the board, and then set up the cloud dashboard.
As we already saw how to use the aREST cloud platform earlier in the book, I will only highlight the most important parts of the code.
The first step is to include all the required libraries, including the aREST library:
#include <ESP8266WiFi.h> #include <PubSubClient.h> #include <aREST.h> #include <SHT1x.h>
Then, we give an ID to our device:
char* device_id = "gveie2y5";
As usual, you also need to put your Wi-Fi name and password here:
const char* ssid = "your-wifi"; const char* password = "your-password";
In the loop()
function of the sketch, we make the measurements from the sensor, and handle the connection with the aREST cloud platform:
// Read values from the sensor temperature = sht1x.readTemperatureC(); humidity = sht1x.readHumidity(); // Connect to the cloud rest.handle(client);
It is now time to configure the board. Grab all the code from the GitHub repository for the book, and then make sure to modify the code with your own credentials and device ID. Then, head over to:
If that's not done yet, create an account there and then a new dashboard:
Inside this newly created dashboard, create a new variable indicator with the following parameters:
You should immediately see a live measurement coming from the board:
Then, repeat the same step for the humidity measurement:
You can now monitor the temperature and humidity of your plant or garden, from anywhere in the world.
But we are still missing one key element: the pump. Wouldn't it be great to also be able to activate the water pump remotely when you see that the humidity is going down? Or even to have it automatically activated when the humidity is too low? This is what we are going to see in the next part of this chapter.
3.143.22.23