#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <WiFi.h>
#include <ThingSpeakap.in>
#define DHTPIN 4 //
#define DHTPIN DHT22 //
const char *ssid = "WOKWI_GUEST ";
const char *password = "";
const char *thingSpeakApikey = "HFIAMGC5G3F9LX8V"
const long Update Intervel = 15000;
DHT dht (DHIPIN,DHTTYPE);
WiFiiclient client ;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
dht begin ();
wifi . begin (ssid , passwor);
While (wifi.status() != WL_CONNECTED ) {
delay (1000)
serial.print ("connecthig to wifi...");
}
seriyal.print ("connecting to wif");
ThingSpeak. begin (cliient );
y
}
void loop() {
// Delay for a few seeconds to Avoid flooding the sensor
delay(2000); //
//Read temperachere and humidity data from the sensor
float humidity = dht.read temperature();
//check if any reading failleg and exit if so
if(isnan(humidity. )|| isnan(_SFR_IO_ADDR)){
serial. print.In("Failed to read from DHT sensor!");
return
}
//print temperature and humidity to the sosial monitor
serial.print("Temperatur");
serial.print(temperatur);
serial.print("°c");
serial.print("Humidit");
serial.print(humidit);
serial.print(" %");
//Update ThigSpeak channel with the sensor data:;
ThingSpeak.WriteField(2267508,1,temperature,thingSpeakApikey);
serial.printIn("Data sent to ThingSpeak:");
delay(Update Interva);
}