Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- #include <WiFiClientSecure.h>
- #include <UniversalTelegramBot.h>
- //edit BOTtoken, chat_id, message and wifi credentials
- #define BOTtoken "0123456789:AAAAAAAbbbbbcccccddddddeeeeeeffffffgggg"
- #define chat_id "9876543210"
- #define message "You have mail!"
- const char* ssid = "wifi-name";
- const char* password = "wifi-password";
- WiFiClientSecure client;
- UniversalTelegramBot bot(BOTtoken, client);
- void setup()
- {
- client.setInsecure();
- int tries=0;
- WiFi.mode(WIFI_STA);
- WiFi.begin(ssid, password);
- //tries for 15sec to establish a wifi connection
- while (WiFi.status() != WL_CONNECTED && tries<15)
- {
- delay(1000);
- tries++;
- }
- //if there was no successful wifi connection after 15 seconds go to deep sleep
- if (tries==15)
- {
- ESP.deepSleep(0);
- }
- }
- void loop()
- {
- //send message and go to deep sleep
- bot.sendMessage(chat_id, message, "");
- ESP.deepSleep(0);
- }
Add Comment
Please, Sign In to add comment