Logging data to Dweet.io
We are now going to see how to log the temperature and humidity measurements in the cloud. We will use the Dweet.io cloud service here, which is very convenient for logging data online:
Note
As the code for this part is very long, we will only see the important parts here. You can of course get all the code from the GitHub repository for this project at https://github.com/openhomeautomation/iot-esp8266.
Again all the measurements are done inside the loop()
function of the sketch, which makes the code repeat every 10 seconds, using a delay()
function.
Inside this loop, we connect to the Dweet.io server with:
WiFiClient client; const int httpPort = 80; if (!client.connect(host, httpPort)) { Serial.println("connection failed"); return; }
Then, we read the data from the sensor with:
int h = dht.readHumidity(); int t = dht.readTemperature();
After that, we send data to the Dweet.io server with:
client.print(String("GET /dweet/for/myesp8266?temperature...