#include "DHTesp.h"
//#include <WiFi.h>
//#include <HTTPClient.h>
//#include <ThingSpeak.h>
//#define CHL_ID 2126335
//#define CHL_KY ""
//const char* serverName = "http://0e53-2402-e280-2138-38-a0b5-bb75-938f-571f.in.ngrok.io/commodity/test";
DHTesp dht;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
dht.setup(23,DHTesp::DHT22);
pinMode(22, OUTPUT);
// Serial.print("Connecting to WiFi");
// WiFi.begin("Wokwi-GUEST", "", 6);
// while (WiFi.status() != WL_CONNECTED) {
// delay(100);
// Serial.print(".");
// }
// Serial.println(" Connected!");
//ThingSpeak.begin(client);
}
void loop() {
// put your main code here, to run repeatedly:
TempAndHumidity data = dht.getTempAndHumidity();
Serial.println("Temp:" + String(data.temperature,2) + " C" );
if(data.temperature > 30){
digitalWrite(22, HIGH);
} else {
digitalWrite(22, LOW);
}
//ThingSpeak.writeField(CHL_ID,1,data.temperature,CHL_KY);
// if (WiFi.status() == WL_CONNECTED) {
// HTTPClient http;
// Serial.println("1:");
// http.begin( serverName);
// // Specify content-type header
// http.addHeader("Content-Type", "text/plain");
// // Data to send with HTTP POST
// //String httpRequestData = ;
// // Send HTTP POST request
// Serial.println("2:");
// int httpResponseCode = http.POST("testData");
// Serial.println("3:");
// Serial.println(httpResponseCode);
// http.end();
// }
delay(1000); // this speeds up the simulation
}