Skip to content

pavilac/Telegram-Arduino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram-Arduino Home Alarm

Telegram Home alarm is capable of:

  • On/Off alarm through Telegram
  • Send you alerts when intrusion is detected (PIR sensor)
  • Add new allowed users
  • Add new commands and sensors on code depending on your needs

Introduction

This code is based on Telegram BOT Library for ESP8266. Creates an interface between a Telegram Bot and a Arduino (Any), providing total control over it. It is composed by two Arduino codes and a ESP8266TelegramBOT modified library:

  1. ESP8266 code
  2. Arduino UNO code
  3. ESP8266TelegramBOT.h Original library

Telegram BOT

First, it is necessary to create a Telegram Bot, once you do it you are given an Access Token, Name and Username that must be added to ESP code in next section. To create your Telegram Bot, talk to BotFather and follow a few simple steps described here.

Check last Telegram API documentation at: https://core.telegram.org/bots/api.

ESP8266 code

It creates an interface between Telegram API and a Arduino. It connects to WiFi, checks telegram bot messages and send them through ESP serial port to any Arduino. It uses three libraries:

  • ESP8266WiFi.h
  • WiFiClientSecure.h
  • ESP8266TelegramBOT.h modified version inside ESP8266-TelegramBot directory. It was modified to allow https and avoid serial printings although it can be helpful at beginning to check connection status.

Installation

The downloaded libraries can be included as a new library into the Arduino IDE selecting the menu:

Sketch / include Library / Add .Zip library

Programming ESP8266 01

Programming ESP8266 01 can be a bit tricky. Next connection diagram could be useful. If you do not own a FDTI, it is always possible to replace it by an Arduino UNO taking off the microcontroller.

Arduino UNO code

This code reads serial port for messages from ESP8266. If message is available, checks authorization and do the required command. Code can be found on ArduinoCode library.

Commands

Next commands can be send to Telegram bot being listened by ESP8266 and Arduino:

  • /start gives a welcome message
  • /code returns usercode. Important to autorize a new user
  • /on turns on alarm sending a notification to authorized users
  • /off turn off alarm, switch off sound, and sends a notification to authorized users
  • /add+usercode adds a new user to the security system