// This code is work good
// send Temputre to bot telegram
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
String botToken = "8423838682:AAHx5RF3rneCrVNeXdLMBMUov-u4R-GZieo";
String chatID = "284146772";
void sendTelegramMessage(String message) {
HTTPClient http;
String url = "https://api.telegram.org/bot" + botToken +
"/sendMessage?chat_id=" + chatID +
"&text=" + message;
http.begin(url);
int httpResponseCode = http.GET();
http.end();
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
sendTelegramMessage("ESP32 is Connected!");
}
void loop() {
// Genrate Random Value for Temp
int sensorValue = random(20, 40); // مثال قراءة بيانات
String msg = "Temperature: " + String(sensorValue);
sendTelegramMessage(msg);
delay(10000); // كل 10 ثواني
// can we use DTH11 , DTH22 sensor and send to bot