#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
const char* token = "HzhmckyOmzKXLNu4PitCbIivfVNfKdfLnUlQKYvHNCQ";
#include "DHT.h"
#define DHTPIN 32
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
dht.begin();
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.println(" READY ");
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin("https://notify-api.line.me/api/notify");
http.addHeader("Authorization", "Bearer " + String(token));
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
if(t >= 39.4) http.POST("message=High temperature !!!");
int httpCode = http.POST("READY . . ."); // Use an empty POST request to send only headers
if (httpCode > 0) {
String response = http.getString();
Serial.print("HTTP Response code: ");
Serial.println(httpCode);
Serial.print("Server response: ");
Serial.println(response);
Serial.print("Humidity: ");
Serial.println(h);
Serial.print("Temperature: ");
Serial.println(t);
} else {
Serial.println(".....");
}
http.end();
delay(5000); //
}
}