This shows you the differences between two versions of the page.
|
iothings:proiecte:2021:temphumiditymonitoring [2022/01/28 00:05] maria.iuga [Software description] |
iothings:proiecte:2021:temphumiditymonitoring [2022/01/28 00:26] (current) maria.iuga [Project implementation] |
||
|---|---|---|---|
| Line 34: | Line 34: | ||
| ===== 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> | ||
| + | |||
| + | 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> | </code> | ||