#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ESP8266TelegramBOT.h>
const char* ssid = "nama_wifi_ku";
const char* password = "pass_wifi_ku";
WiFiServer server(80);
#define BOTtoken "token_telegram_bot" //token of FlashledBOT
#define BOTname "contoh"
#define BOTusername "contoh_bot"
TelegramBOT bot(BOTtoken, BOTname, BOTusername);
int Bot_mtbs = 1000;
long Bot_lasttime;
bool Start = false;
int sensor1 = digitalRead(D0);
void Bot_ExecMessages() {
for (int i = 1; i < bot.message[0][0].toInt() + 1; i++) {
bot.message[i][5]=bot.message[i][5].substring(1,bot.message[i][5].length());
if (bot.message[i][5] == "ledon") {
digitalWrite(LED_BUILTIN, LOW);
bot.sendMessage(bot.message[i][4], "Led is ON", "");
}
if (bot.message[i][5] == "ledoff") {
digitalWrite(LED_BUILTIN, HIGH);
bot.sendMessage(bot.message[i][4], "Led is OFF", "");
}
if (bot.message[i][5] == "sensor"){
String updateSensor = "Disini update sensor";
bot.sendMessage(bot.message[i][4], updateSensor, "");
}
if ( sensor1 == 0 ){
Serial.println("Ada alarm di sensor 1, segera check kondisi nya");
String msgSensor1 = "Ada alarm di sensor 1, segera check kondisi nya";
bot.sendMessage(bot.message[i][4],msgSensor1, "");
}
if (bot.message[i][5] == "start") {
String wellcome = "Wellcome from mikroavr_bot, your personal Bot on alarm realtime notification";
String wellcome1 = "/ledon : to switch the Led ON";
String wellcome2 = "/ledoff : to switch the Led OFF";
String wellcome3 = "/sensor : status all sensor";
bot.sendMessage(bot.message[i][4], wellcome, "");
bot.sendMessage(bot.message[i][4], wellcome1, "");
bot.sendMessage(bot.message[i][4], wellcome2, "");
bot.sendMessage(bot.message[i][4], wellcome3, "");
Start = true;
}
}
bot.message[0][0] = "";
}
Comments
Post a Comment