Codigo pronto

This commit is contained in:
2022-06-09 23:19:00 -03:00
parent 20a38cb9de
commit 1aab701138
2 changed files with 17 additions and 4 deletions

View File

@@ -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

View File

@@ -7,6 +7,7 @@
#include "ESPAsyncWebServer.h"
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <HTTPClient.h>
// 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();
}
}