Shebin Jose Jacob
Published © GPL3+

Telegram Bot with ESP8266

Divine control of ESP8266 with telegram bot.

EasyFull instructions provided1 hour19,935
Telegram Bot with ESP8266

Things used in this project

Story

Read more

Schematics

schema

Wifitoarduino jz26ak1qwk

Code

ESP8266_Telegram.ino

C/C++
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <TelegramBot.h>


#define LED 1
// Initialize Wifi connection to the router
const char* ssid     = "xxxx";
const char* password = "yyyy";


// Initialize Telegram BOT
const char BotToken[] = "xxxxxxxxxxx";

WiFiClientSecure net_ssl;
TelegramBot bot (BotToken, net_ssl);

 // the number of the LED pin  
void setup() 
{  
 Serial.begin(115200);  
 while (!Serial) {}  //Start running when the serial is open 
 delay(3000);  
 // attempt to connect to Wifi network:  
 Serial.print("Connecting Wifi: ");  
 Serial.println(ssid);  
 while (WiFi.begin(ssid, password) != WL_CONNECTED) 
       {  
   Serial.print(".");  
   delay(500);  
 }  
 Serial.println("");  
 Serial.println("WiFi connected");  
 bot.begin();  
 pinMode(LED, OUTPUT);  
}  
void loop() 
{  
 message m = bot.getUpdates(); // Read new messages  
 if (m.text.equals("on")) 
       {  
   digitalWrite(LED, 1);   
   bot.sendMessage(m.chat_id, "The Led is now ON");  
 }  
 else if (m.text.equals("off")) 
       {  
   digitalWrite(LED, 0);   
   bot.sendMessage(m.chat_id, "The Led is now OFF");  
 }  
}  

Credits

Shebin Jose Jacob

Shebin Jose Jacob

1 project • 2 followers
I know only one language, the language of 0's and 1's

Comments