This shows you the differences between two versions of the page.
iothings:proiecte:2021:temphumiditymonitoring [2022/01/27 22:41] maria.iuga [Software description] |
iothings:proiecte:2021:temphumiditymonitoring [2022/01/28 00:26] (current) maria.iuga [Project implementation] |
||
---|---|---|---|
Line 16: | Line 16: | ||
* GPIO26 pin of the ESP32 with the S pin of the DHT11 sensor; | * GPIO26 pin of the ESP32 with the S pin of the DHT11 sensor; | ||
* GND pin of the ESP32 with the GND pin of the DHT11 sensor; | * GND pin of the ESP32 with the GND pin of the DHT11 sensor; | ||
- | * VIN (5V) pin in the ESP32 with VCC pin of the DHT11 sensor; | + | * VIN (5V) pin in the ESP32 with VCC pin of the DHT11 sensor. |
{{ :iothings:proiecte:2021:img.jpg?700 |}} | {{ :iothings:proiecte:2021:img.jpg?700 |}} | ||
Line 26: | Line 26: | ||
The ESP32 board was programmed using Arudino IDE and its programming language. | The ESP32 board was programmed using Arudino IDE and its programming language. | ||
- | **Aduino IDE** is an open-source software used for writing, compiling & uploading code. Programs written using Arduino Software (IDE) are called sketches. | + | **Aduino IDE** – is an open-source software used for writing, compiling & uploading code. Programs written using Arduino Software (IDE) are called sketches. |
The main libraries used for the project are: | The main libraries used for the project are: | ||
- | * **DHT.h** is an Arduino library for DHT11, DHT12 and other temperature and humidity sensors; | + | * **DHT.h** is used an Arduino library for DHT11, DHT12 and other temperature and humidity sensors; |
- | * **Wifi.h** used for ESP32 to connect with the network and communicate with the IFTTT service. | + | * **Wifi.h** is used for ESP32 to connect with the network and communicate with the IFTTT service. |
===== Project implementation ===== | ===== Project implementation ===== | ||
+ | |||
+ | Arduino IDE functions used to record and send the data from the sensor to Webhooks from IFTTTT. | ||
+ | |||
<code> | <code> | ||
- | void setup () | + | void setup () { |
//initialize the serial monitor for debugging | //initialize the serial monitor for debugging | ||
- | Serial.begin(115200); | + | Serial.begin(115200); |
+ | Serial.println("DHT11 sensor!"); | ||
+ | //call begin to start sensor | ||
+ | dht.begin(); | ||
+ | // Connect to Wi-Fi | ||
+ | WiFi.begin(ssid, password); | ||
+ | while (WiFi.status() != WL_CONNECTED) { | ||
+ | delay(500); | ||
+ | Serial.print("."); | ||
+ | } | ||
+ | Serial.println(""); | ||
+ | Serial.println("WiFi connected"); | ||
+ | } | ||
</code> | </code> | ||
+ | |||
+ | Two rules were set in the project. | ||
+ | |||
+ | 1.If the temperature is higher than 25 C, an email is sent through an applet (named high temp) with the message “Temperature too high!”; | ||
+ | <code> | ||
+ | if (t > high_temp ){ | ||
+ | if (!client.connect(host, httpPort)) { | ||
+ | Serial.println("connection failed"); | ||
+ | return; | ||
+ | } | ||
+ | else | ||
+ | Serial.println("conected"); | ||
+ | client.print(String("POST ") + url_high_low_temp + " HTTP/1.1\r\n" + | ||
+ | "Host: " + host + "\r\n" + | ||
+ | "Content-Type: application/x-www-form-urlencoded\r\n" + | ||
+ | "Content-Length: 41\r\n\r\n" + | ||
+ | "value1=" + t + | ||
+ | "&value2="+"Temperature too high "+"\r\n"); | ||
+ | delay(15000); | ||
+ | } | ||
+ | </code> | ||
+ | 2.If the temperature is lower than 24 C, an email is sent through the same applet with the message “Temperature too low!”. | ||
+ | <code> | ||
+ | if (t < low_temp ){ | ||
+ | if (!client.connect(host, httpPort)) { | ||
+ | Serial.println("connection failed"); | ||
+ | return; | ||
+ | } | ||
+ | else | ||
+ | Serial.println("conected"); | ||
+ | client.print(String("POST ") + url_high_low_temp + " HTTP/1.1\r\n" + | ||
+ | "Host: " + host + "\r\n" + | ||
+ | "Content-Type: application/x-www-form-urlencoded\r\n" + | ||
+ | "Content-Length: 40\r\n\r\n" + | ||
+ | "value1=" + t + | ||
+ | "&value2=" + "Temperature too low "+"\r\n"); | ||
+ | delay(15000); | ||
+ | } | ||
+ | |||
+ | </code> | ||
+ | |||
+ | IFTTT applets used to receive data from Arduino IDE and send them to Adafruit IO platform and send an email | ||
+ | The temperature and humidity data are sent to Adafruit IO platform through two applets named temperature and humidity. | ||
+ | |||
+ | {{ :iothings:proiecte:2021:img51.png?700 |}} | ||
+ | |||
+ | The applet Emergency Email Transmission receives two values via Webhooks and it uses the first value to display the temperature recorded and the second value display the warning message accordingly to the temperature recorded (high/low) then sends an email structured like in below image. | ||
+ | |||
+ | {{ :iothings:proiecte:2021:img2.png?700 |}} | ||
+ | |||
+ | The emails sent by the applet are as follows and differs, as two rules are set. | ||
+ | |||
+ | {{ :iothings:proiecte:2021:imag31.png?700 |}} | ||
+ | |||
+ | |||
+ | Adafruit IO platform receives data from IFTTT and displays it accordingly. | ||
+ | The readings of the sensors are displayed in Adafruit Dashboard. The humidity data is displayed live and the temperature is displayed over a course of 24h. | ||
+ | |||
+ | {{ :iothings:proiecte:2021:img.3.png?700 |}} | ||
+ | |||
+ | |||
===== Conclusion ===== | ===== Conclusion ===== | ||
- | Using the IFTTT service and Adafruit IO platform is an easy way to monitor the temperature and humidity inside a room from anywhere remotely. | + | Using the IFTTT service and Adafruit IO platform is an easy way to monitor remotely the temperature and humidity inside a room from anywhere. |
===== Resources ===== | ===== Resources ===== |