#include<WiFi.h>
#include <HTTPClient.h>
#include <DHT.h>
#define DHTPIN 15
#define DHTTYPE DHT22
DHT dht(DHTPIN,DHTTYPE);
const char* ssid = "Wokwi-GUEST";
const char* pass = "";
void setup(){
Serial.begin(115200);
WiFi.begin(ssid, pass);
while(WiFi.status() != WL_CONNECTED){
delay(100);
Serial.println(".");
}
Serial.println("WiFi Connected!");
Serial.println(WiFi.localIP());
dht.begin();
}
void loop(){
String serverUrl= "http://myfik.unisza.edu.my/cloud/072323/public/iotsystem/public/sensorlive/ali/";
float t =dht.readTemperature();
if (isnan(t)) {
Serial.println("Failed to Read from DHT sensor!");
return;
}else{
HTTPClient http;
String value = String(t);
http.begin(serverUrl+value);
int httpResponCode = http.GET();
if(httpResponCode ==200)
Serial.println("Success send to server: "+value);
else
Serial.println("Failed send to server: "+ value);
}
delay(5000);
}