Created
May 24, 2018 18:35
-
-
Save vlna/8187d8c87f907c76f3d7a5e627f73f34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Just demo to test Telegram delivery | |
* | |
*/ | |
#include <ESP8266WiFi.h> | |
#include <WiFiClientSecure.h> | |
#include <TelegramBot.h> | |
const char* ssid = ""; | |
const char* password = ""; | |
// Initialize Telegram BOT | |
const char BotToken[] = ""; | |
const char ChatID[] = ""; //use @my_id_bot to get this number | |
WiFiClientSecure net_ssl; | |
TelegramBot bot (BotToken, net_ssl); | |
void setup() { | |
Serial.begin(115200); | |
delay(10); | |
// We start by connecting to a WiFi network | |
Serial.println(); | |
Serial.println(); | |
Serial.print("Connecting to "); | |
Serial.println(ssid); | |
/* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default, | |
would try to act as both a client and an access-point and could cause | |
network-issues with your other WiFi-devices on your WiFi-network. */ | |
WiFi.mode(WIFI_STA); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
Serial.print("."); | |
} | |
Serial.println(""); | |
Serial.println("WiFi connected"); | |
Serial.println("IP address: "); | |
Serial.println(WiFi.localIP()); | |
} | |
int value = 0; | |
void loop() { | |
delay(5000); | |
++value; | |
Serial.println(String(value)); | |
bot.sendMessage(ChatID, String(value)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment