//#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include "DHT.h"
#define DHTPIN 13
#define DHTTYPE DHT22 // DHT 22
DHT dht(DHTPIN, DHTTYPE);
// Initialize Wifi connection to the router
char ssid[] = "WIFI GRATIS"; // your network SSID (name)
char password[] = "sateayam"; // your network key
// Initialize Telegram BOT
#define BOTtoken "7794880616:AAEvNZFYkKn_ifAGpgKMcPsxVO9u8pAyYLM" // your Bot Token (Get from Botfather)
#define chat_id "5769542529"
WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);
void setup() {
Serial.begin(115200);
dht.begin();
client.setInsecure();
// Set WiFi to station mode and disconnect from an AP if it was Previously
// connected
//WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
// attempt to connect to Wifi network:
Serial.print("Connecting Wifi: ");
Serial.println(ssid);
//WiFi.begin(ssid, password);
// while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.println(F("°C "));
delay (3000);
if ( h >35 and t>25 ){
bot.sendChatAction(chat_id, "typing");
delay (3000);
String suhu = "intensitas Kelembaban : " ;
suhu += int(h);
suhu += "%\n";
suhu += "intensitas Suhu: ";
suhu += int (t);
suhu += "°C \n";
suhu += "Ruangan Suhu Panas sekali dan gerah ";
bot.sendMessage(chat_id, suhu, "");
Serial.println ("mengirim ke telegram");
}
}