#include "DHTesp.h"
#include <WiFi.h>
#include<HTTPClient.h>
#include "ArduinoJson.h"
DHTesp dht;
WiFiClient client;
String APIKey = "45FIQVZJKS0JO0LP"; //Write API Key
HTTPClient http;
String url="https://api.thingspeak.com/channels/2322035/feeds.json?api_key=GZ3LORKPJLG8RJ1X&results=2";
void setup() {
Serial.begin (115200);
Serial.println("Hello, ESP32!");
dht.setup (15, DHTesp::DHT22);
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED){
delay (250);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
http.begin(url);
}
void loop() {
int httpResponseCode = http.GET();
if (httpResponseCode > 0) {
Serial.print("HTTP ");
Serial.println(httpResponseCode);
String payload = http.getString();
//Serial.print("Json file: ");
//Serial.println(payload);
DynamicJsonDocument doc(1024);
deserializeJson(doc, payload);
String Created = doc["feeds"][0]["created_at"];
Serial.println(Created);
}
delay(3000);
}