Hello, I am trying to make an notification system through ESP8266 and Telegram Bot to multiple User_ID.
I own a solar system and Power Grid is not available allthe time in my country, so I want to connect the ESP8266 to Power Grid line and get notified when it is available.
I managed to get it to work according to tutos and with Telegram Bots, but I would like to add more Telegran User_ID in the code, so can get notification on multiple devices.
This is what I came out as a code :
A telegram bot that sends you a message when ESP
starts up
Parts:
D1 Mini ESP8266 * - http://s.click.aliexpress.com/e/uzFUnIe
(or any ESP8266 board)
https://github.com/sponsors/witnessmenow/
Written by Brian Lough
YouTube: https://www.youtube.com/brianlough
Tindie: https://www.tindie.com/stores/brianlough/
Twitter: https://twitter.com/witnessmenow
*******************************************************************/
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
// Wifi network station credentials
#define WIFI_SSID "HOME_WIFI"
#define WIFI_PASSWORD "Itissasecret"
// Telegram BOT Token (Get from Botfather)
#define BOT_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
// Use @myidbot (IDBot) to find out the chat ID of an individual or a group
// Also note that you need to click "start" on a bot before it can
// message you
#define CHAT_ID "5555555555555"
X509List cert(TELEGRAM_CERTIFICATE_ROOT);
WiFiClientSecure secured_client;
UniversalTelegramBot bot(BOT_TOKEN, secured_client);
void setup() {
Serial.begin(115200);
Serial.println();
// attempt to connect to Wifi network:
Serial.print("Connecting to Wifi SSID ");
Serial.print(WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
secured_client.setTrustAnchors(&cert); // Add root certificate for api.telegram.org
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(500);
}
Serial.print("\nWiFi connected. IP address: ");
Serial.println(WiFi.localIP());
Serial.print("Retrieving time: ");
configTime(0, 0, "pool.ntp.org"); // get UTC time via NTP
time_t now = time(nullptr);
while (now < 24 * 3600)
{
Serial.print(".");
delay(100);
now = time(nullptr);
}
Serial.println(now);
bot.sendMessage(CHAT_ID, "Bot started up", "");
delay(15000);
bot.sendMessage(CHAT_ID, "Power Grid is available.", "");
}
void loop() {
}**
Thank you for any help, or some tutos and scripts.