diff --git a/platformio.ini b/platformio.ini index e421c09..5ff3c19 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,8 +12,9 @@ platform = espressif32 board = esp32doit-devkit-v1 framework = arduino -monitor_speed = 74880 +monitor_speed = 115200 lib_deps = adafruit/DHT sensor library@^1.4.3 adafruit/Adafruit Unified Sensor@^1.1.5 me-no-dev/ESP Async WebServer@^1.2.3 + bblanchon/ArduinoJson@^6.19.4 diff --git a/src/main.cpp b/src/main.cpp index 9b367da..7e8a6fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ #include "ESPAsyncWebServer.h" #include #include +#include // Replace with your network credentials const char* ssid = "IME-Servicos"; @@ -20,7 +21,7 @@ const char* password = "REPLACE_WITH_YOUR_PASSWORD"; //#define DHTTYPE DHT21 // DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); - +HTTPClient http; // Create AsyncWebServer object on port 80 AsyncWebServer server(80); @@ -130,7 +131,7 @@ String processor(const String& var){ void setup(){ // Serial port for debugging purposes - Serial.begin(74880); + Serial.begin(115200); dht.begin(); @@ -163,5 +164,16 @@ void setup(){ } void loop(){ - + delay(10000); + float t = dht.readTemperature(); + float h = dht.readHumidity(); + if(t > 30 || h > 80){ + String alertString = "ALERT+t+%3D+" + String(t) + "%2C+h+%3D+" + String(h); + Serial.printf("ALERT t = %f, h = %f\n\r", t, h); + String url = "http://52.70.34.69/alert/-777756182?alert=" + alertString; + Serial.println(url); + Serial.println(http.begin(url)); + Serial.println(http.GET()); + http.end(); + } } \ No newline at end of file