0% found this document useful (0 votes)
351 views35 pages

A PROJECT REPORT 25 13 Final

This document is a project report on home automation using a Telegram bot. It was submitted by students Sanika Sachin Thakur and Shubham Rajesh Nagvekar for their MSc in Computer Science. The report includes an introduction that provides an overview of home automation and its objectives. It also includes sections on related work, methodology, system implementation, troubleshooting, and conclusions. The methodology section includes block diagrams, flow charts, and details on the hardware and software used to build the home automation system controlled by a Telegram bot.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
351 views35 pages

A PROJECT REPORT 25 13 Final

This document is a project report on home automation using a Telegram bot. It was submitted by students Sanika Sachin Thakur and Shubham Rajesh Nagvekar for their MSc in Computer Science. The report includes an introduction that provides an overview of home automation and its objectives. It also includes sections on related work, methodology, system implementation, troubleshooting, and conclusions. The methodology section includes block diagrams, flow charts, and details on the hardware and software used to build the home automation system controlled by a Telegram bot.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

A PROJECT REPORT

ON
HOME AUTOMATION USING TELEGRAM BOT

SUBMITTED BY
SANIKA SACHIN THAKUR
&
SHUBHAM RAJESH NAGVEKAR

SEAT NO: 25, 13

PROJECT GUIDE
Mrs. KARISHMA JAIN

MSc. (COMPUTER SCIENCE)


SEM - IV 2022 – 2023

CONDUCTED AT
CHIKITSAK SAMUHA’S

S. S. & L.S. PATKAR COLLEGE OF ARTS & SCIENCE


AND
V. P. VARDE COLLEGE OF COMMERCE & ECONOMICS
GOREGAON (W). MUMBAI -40006
ACKNOWLEDGEMENT

I take this opportunity of submitting this report to express my profound


gratitude to the management of “S.S. & L.S. Patkar College of Science and Commerce”
for giving me the opportunity to accomplish this project work.

I am also thankful to all the teachers for their kind support and help.

I would like to express my special thanks of gratitude to my project guide Mrs.


Karishma Jain as well as our respected Head of the department Mrs. Manali Patil. Who
gave me the golden opportunity to do this wonderful project on the topic Home
automation Using Telegram Bot which also helped me in doing a lot of Research and I
came to know about so many new things I am really thankful to them.

Finally, I would also like to thank my friends who helped me a lot in finalizing
and successful completion this project within the limited time frame. Thanking you,
INDEX
SR. NO TITLE PAGE NO.
1. Introduction 4-8
Overview 5
Objective 6
Requirements of Contents 7
Gantt Chart 8
2. Related Work 9-11
Existing System 10
Problem Statement 11
3. Methodology 12-20
Block Diagram 13
Flow Chart 14
Working 15
Circuit Diagram 16
Hardware Components Used 17
Software Tools Used 19
4. System Implementation 21-29
Telegram Bot Setup 22
Raspian OS Installation in Raspberry Pi 4 23
Execution in Raspberry Pi OS 24
Raspberry Pi OS Remote Setup 27
Results 28
5. Troubleshooting 30-31
Troubleshooting 31
6. Conclusion & Reference 32-35
Conclusion 33
Reference 34
INTRODUCTION
OVERVIEW
Home Automation Is Building Automation System For A House, Which Is Called A Smart Home.
Home Automation System Monitors and Control All the Home Appliances. Making the normal day
to day work easy and convenient. Home automation can quickly bring the future in to our homes
by incorporating security, climate, and household gadgets and transforms our regular home into a
futuristic smart home. These smart home systems can be used for simple or elaborate tasks by
integrating devices and gadgets inside and outside of your home. A simple definition for home
automation is the ability to do tasks automatically and monitor or change status remotely. Common
tasks include turning off lights when no one is in the room, locking doors via smartphone, automates
air condition systems that can sense and memorize temperature settings and appliances that help
you reduce the time you spend in the kitchen. In the IoT home automation ecosystem, you can
control your devices like light, fan, TV, etc. A domestic automation system can monitor and/or
manage home attributes adore lighting, climate, enjoyment systems, and appliances. It is very
helpful to control your home devices. The Internet of Things, IoT, is in a huge way and people are
rapidly inventing new gadgets that enhances lives. The price of microcontrollers with the ability to
talk over a network keeps dropping and developers can now tinker and build things inexpensively.
OBJECTIVE
Home Automation allows you to control your energy consumption. Smart home automation
systems are sensitive to daylight and with this sensitivity, you can use your lighting system in
economic mode. Keeping the room temperature at a constant value in your home heating or
cooling systems, you can save energy while heating your home. With smart socket automation
systems, it operates your energy-consuming household appliances in energy-saving mode. With
the Smart Home automation system, you can connect and control your home with your mobile
phone or tablet and get your home in a safe mode with a single button. When you leave home,
you can protect your home against intruders by activating your cameras and motion sensors. In
addition, you can monitor your home on your smartphone with automation systems developed in
smartphone systems. You can instantly monitor the situations around your home. Using iot-based
smart home systems, you can secure the security of your family and home. How is this security
provided? Sensors are used to develop smart devices in the field of technology. With these
sensors, high-tech smart devices are designed. When motion is detected when you are not at home,
it will automatically light up to allow intruders to walk away and better security cameras. So you
can protect your home from intruders. With smart home automation systems, you can do your
daily work without wasting your time. When you can’t find time in your busy work schedule, it
may be difficult for you to do these things, even if it is simple household chores. That’s exactly
where smart home automation systems come in.
REQUIREMENTS OF CONTENTS
Sr. No. Components Specification Quantity required
1 Raspberry Pi4 B 2GB RAM 1
2 Relay Board 2-Channel Board 1
3 Charging Adapter 5-9Volts 1
4 Electric Sockets - 2
5 Connecting wires - As per requirement
GANTT CHART

A Gantt chart is a useful graphical tool which shows activities or tasks performed against time. It is
also known as visual presentation of a project where the activities are broken down and displayed on
a chart which makes it is easy to understand and interpret. A Gantt chart is a popular tool in project
management. It basically drills down activities which need to be done by a fixed time period. It is
commonly used for tracking project schedules.
RELATED WORK
EXISTING SYSTEM
1. sP.N.V.S.N. Murthy, S. Tejeswara Rao, and G. Mohana Rao have published research on
home automation using Telegram. This research includes a circuit design using Raspberry Pi
with IoT and Telegram Bot to control home applications, as well as a syringe pump equipped
with a NodeMCU8266 WiFi module to provide notifications via a smartphone. A
comparative study between Telegram and other messaging services was also conducted by
Murthy et al. Additionally, Murthy et al. designed an application that provides the ability to
create a chatbot without programming language requirements.

2. V. Subba Reddy, Sreevardhan Cheerla, Syed Inthiyaz, et al have published research on face
recognition and home automation using Telegram Bot. This research includes a PI board with
"Telegram Bot" to send the IOT programming to detect and express moistness an area. The
paper also includes manipulation of home appliances using voice indoors. Out of twenty-five
identity trials, the success rate or SR of face identity test was 84%.

3. Dhiraj Sunehra and G. Venkat Ramana have published research on a webpage and telegram
bot controlled home automation system using Raspberry Pi3. This system implements IoT to
automate the control of connected things in a house. The Raspberry Pi3 processor can be
controlled using the developed web page and Telegram Bot. In this IoT project, an AC lamp
can be controlled with a text message from Telegram application using Raspberry Pi.

4. Yasirli Amri and Mukhammad Andri Setiawan have published research on improving the
smart home concept with the Internet of Things (IoT) concept using Raspberry Pi and
NodeMCU. The paper proposes a smart home system that provides energy efficiency, energy
monitoring, security, and privacy management[1]. The communication between user and the
system is done using Telegram Bot. Yasirli Amri is an author of this paper who has also
published other papers on IoT. Mukhammad Andri Setiawan is a Chief Information Officer at
Universitas Islam Indonesia.
PROBLEM STATEMENT
Home automation refers to control the home appliances by using computer technology. Computer
Systems enables from remote control of lighting through to complex micro-controller or computer
based networks with various degrees of intelligence and automation. Home automation provides
security, energy efficiency and ease of use hence, it is adopted more. It also provides remote
interface to home appliances to provide control and monitoring on a web browser.
The field of Automation has well advanced in Industries, as majority of automobile industry
plants as well as bottling plants have Automated assembly lines. But automation has not yet
penetrated in the homes especially in India. If automation was to be used in homes than everyday
life would be get eased. Simple example of use of automation in home can be seen in the transfer
of water from the under-ground water tank to the over-head water tank, by sensing the level of
water in both the tanks. This process eases the every time effort the user has to put in for filling
the tank and also helps in saving water. Also people are getting more acquainted daily with the
use of Smartphone and tablets which are capable of doing much of PC’s work handy. So we have
decided to make a low cost Embedded System in which the smart phones can be used to help
automate entire home. In this system the user will have remote access and control over all the
subsystems present in the house.
METHODOLOGY
BLOCK DIAGRAM

Fig 1. Block diagram of Home Automation System using Telegram Bot


FLOW CHART

Start

User sends
command to the
telegram bot

Telegram
bot checks
the
command

Device will turn ON Device will turn OFF


WORKING
This projecst presents a way to connect Home Appliances to the mobile and further control it. This
project contains Raspberry Pi4 which will act as a main controller in this project, as we have to
install Raspbian OS in Raspberry Pi, once the Raspberry Pi OS is set we create a python code in
Raspberry Pi4 using “if-else” statement. In smart Phone we have created a Telegram Bot using
Telegram App and get a unique Authentication Code(Auth Code) and then copy-paste the Auth
Code in the Python code created in the Raspberry Pi4. Telegram Bot connects the Raspberry pi4 to
the mobile to give commands and switch the appliances On/Off. We have also used 2 channel relay
which is connected to Raspberry Pi4 via GPIOS pins available in Raspberry Pi4.

PROCESS:

Telegram Python Run code Telegram Light


Bot Setup Code CMD APP Input Operation
CIRCUIT DIAGRAM
HARDWARE COMPONENTS USED

A) Raspberry Pi 4

Fig 3. Raspberry Pi4 B

Raspberry Pi 4 Model B was released in June 2019[1] with a 1.5 GHz 64-bit quad core ARM
Cortex-A72 processor, on-board 802.11ac Wi-Fi, Bluetooth 5, full gigabit Ethernet (throughput
not limited), two USB 2.0 ports, two USB 3.0 ports, 1–8 GB of RAM, and dual-monitor support
via a pair of micro HDMI (HDMI Type D) ports for up to 4K resolution. The version with 1 GB
RAM has been abandoned and the prices of the 2 GB version have been reduced. The 8 GB
version has a revised circuit board. The Pi 4 is also powered via a USB-C port, enabling
additional power to be provided to downstream peripherals, when used with an appropriate PSU.
But the Pi can only be operated with 5 volts and not 9 or 12 volts like other mini computers of
this class.

Features of Raspberry Pi4 B:

1. A high-performance 64-bit quad-core processor


2. Dual display support with resolutions up to 4K via a pair of micro-HDMI ports
3. Hardware video decoding up to 4Kp60
4. 2 GB of RAM
5. A connection to the dual-band wireless local area network 2.4/5.0 GHz
6. Bluetooth 5.0 / Gigabit Ethernet / USB 3.0 / PoE features (via a separate HAT PoE add-on
module)
B) Relay Board(2-channel)

Fig 4. 2-Channel Relay Board

The 2 Channels Relay Module is a convenient board which can be used to control high voltage,
high current load such as motor, solenoid valves, lamps and AC load. It is designed to interface
with microcontroller such as Arduino, PIC and etc. The relays terminal (COM, NO and NC) is
being brought out with screw terminal. It also comes with a LED to indicate the status of relay.
Features of Relay Board:
1. Digital output controllable
2. Compatible with any 5V microcontroller such as Arduino.
3. Rated through-current: 10A (NO) 5A (NC)
4. Control signal: TTL level
5. Max. switching voltage 250VAC/30VDC
6. Max. switching current 10A
7. Size: 50mm x 38mm x 17mm
SOFTWARE TOOLS USED
A) Telegram Application:

Fig 5. Telegram App

Telegram is a cross-platform messaging service with enhanced encryption and privacy. Most
messages feature client-to-server encryption, but Secret Chat messages have end-to-end
encryption. Telegram also supports group chats and self-destructing messages as well.
Specifications of Telegram App:
1. Developed by: Telegram FZ LLC, Telegram Messenger Inc
2. Supports: Android, iOS, Windows, Linux, macOS, Web Platform
3. End-to-End Encryption

B) Fritzing

Fig 6. Fritzing

Fritzing is an open-source initiative to develop amateur or hobby CAD software for the design of
electronics hardware, to support designers and artists ready to move from experimenting with a
prototype to building a more permanent circuit. It was developed at the University of Applied
Sciences Potsdam.
C) Raspberry Pi Imager

Fig 7. Raspberry pi

Raspberry Pi Imager is the quick and easy way to install Raspberry Pi OS and other operating
systems to a microSD card, ready to use with your Raspberry Pi. Download and install Raspberry
Pi Imager to a computer with an SD card reader. Put the SD card you'll use with your Raspberry Pi
into the reader and run Raspberry Pi Imager.

D) Thonny Python

Fig 8. Thonny Python

Thonny is an integrated development environment for Python that is designed for beginners.
It supports different ways of stepping through the code, step-by-step expression evaluation,
detailed visualization of the call stack and a mode for explaining the concepts of references and
heap.
SYSTEM IMPLEMENTATION
TELEGRAM BOT SETUP
First, go to telegram.org and download telegram aplication. Create an account then sign in it whatever
you’re on a mobile phone or others. Here, I’m using an Android phone. Open Telegram and you’ll see
a search just go there type “BotFather”. Click “start” then type “/newbot” to create a new bot.

Then give the Telegram bot a unique username. Note that the bot name must end with the word "bot"
(case-insensitive). Copy and save the Telegram bot's access token for later steps.
RASPIAN OS INSTALLATION IN RASPBERRY PI 4
To install Raspberry Pi OS on a Raspberry Pi 4 using Raspberry Pi Imager, follow these steps:
1. Download and install the Raspberry Pi Imager for your operating system.

2. Insert a microSD card into your computer.


3. Open the Raspberry Pi Imager and select "Raspberry Pi OS" from the list of operating
systems.
4. Choose your microSD card as the storage device.
5. Click "Write" to begin writing the image to the microSD card.

6. Once complete, insert the microSD card into your Raspberry Pi 4 and power it on.
EXECUTION IN RASPBERRY PI OS

A) Install Telepot Package in Raspberry pi:

To install the telepot package on a Raspberry Pi, open a terminal and enter the following
commands:
a. sudo apt-get update
b. sudo apt-get install python-pip
c. sudo pip install telepot

B) Coding

Now we create a python file in raspberry pi and create a code to control home appliances and set
GPIOS in code, after this paste the Auth code in the program and then connect the relay
according to the GPIOS entered in the code.

Program:

import time, datetime import


RPi.GPIO as GPIOimport telepot
from telepot.loop import MessageLoop

Device01 = 26
Device02 = 19
Device03 = 13
Device04 = 6

now = datetime.datetime.now()
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

#LED Device01 GPIO.setup(Device01,


GPIO.OUT)
GPIO.output(Device01, 0) #Off initially#LED Device02
GPIO.setup(Device02, GPIO.OUT)
GPIO.output(Device02, 0) #Off initially#LED Device03
GPIO.setup(Device03, GPIO.OUT)
GPIO.output(Device03, 0) #Off initially#LED Device04
GPIO.setup(Device04, GPIO.OUT) GPIO.output(Device04, 0) #Off
initially

def action(msg):
chat_id = msg['chat']['id']command =
msg['text']
print ('Received: %s' % command)

if 'on' in command: message =


"Turned on "
if 'Device01' in command:
message = message + "Device01 "
GPIO.output(Device01, 1)
if 'Device02' in command:
message = message + "Device02 "
GPIO.output(Device02, 1)
if 'Device03' in command:
message = message + "Device03 "
GPIO.output(Device03, 1)
if 'Device04' in command:
message = message + "Device04 "
GPIO.output(Device04, 1)
if 'all' in command:
message = message + "all "
GPIO.output(Device01, 1)
GPIO.output(Device02, 1)
GPIO.output(Device03, 1)
GPIO.output(Device04, 1) message =
message + "light(s)"
telegram_bot.sendMessage (chat_id, message)

if 'off' in command: message = "Turned


off "
if 'Device01' in command:
message = message + "Device01 "
GPIO.output(Device01, 0)
if 'Device02' in command:
message = message + "Device02 "
GPIO.output(Device02, 0)
if 'Device03' in command:
message = message + "Device03 "
GPIO.output(Device03, 0)
if 'Device04' in command:
message = message + "Device04 "
GPIO.output(Device04, 0)
if 'all' in command:
message = message + "all "
GPIO.output(Device01, 0)
GPIO.output(Device02, 0)
GPIO.output(Device03, 0)
GPIO.output(Device04, 0) message =
message + "light(s)"
telegram_bot.sendMessage (chat_id, message)
telegram_bot = telepot.Bot('6043695698:AAE43QaSgiPywZLggTKjtGpOuqT3mTsCe9A')print
(telegram_bot.getMe())

MessageLoop(telegram_bot, action).run_as_thread()print ('Up and


Running. ............................................... ')

while 1:
time.sleep(10)
RASPBERRY PI OS REMOTE SETUP

1. Install VNC Viewer on device you want to access Raspian OS remotely.


2. Then turn ON your device Wi-Fi connection & also turn ON your Raspberry Pi.
3. Connect your device to Raspberry Pi.
4. Find Raspberry Pi IP address on your WAN settings.
5. Open VNC Viewer and enter Raspberry Pi IP address to connect.
6. Then Enter Login Credentials which was created at the time of Raspian OS setup.
7. This will open Raspian OS window on your device wirelessly.
RESULTS

A) INPUT MESSAGE TO TELEGRAM BOT


Now open CMD window and open the python file in the CMD window and give command using
telegram to operate the appliances. So, as soon as one sends a message as set in the python code
(i.e. ‘On1/Off1, On2/Off2”) in the telegram app it will send the message to Raspberry Pi to
High/Low the GPIOS which are connected to relay, the raspberry pi will get the input from
telegram bot and will send the signal to GIOPS library and GIPOS will be accessed accordingly.
After getting signal from Raspberry Pi4 it gets to relay board via connecting wires connected across
GPIOS and Relay input pins.
B) OUTPUT

C) TEST CASES:

Test Case Test


Module Inputs Expected Output Actual Output
Id Result
User should be User is logged
Valid
logged in and in and redirected
1. Login account Pass
redirected to the to the Raspian
credentials
Raspian OS OS
Valid Output on
Code Run in Program should run
2. Program telegram bot Pass
Thonny Python without errors
Code using command

Output
Start Command Valid
3. Command Verified Raspberry pi Pass
to telegram bot Command
will Turn On

Send Command
to telegram bot Valid Output based on
4. Command Verified Pass
to turn ON/OFF Command given command
your device

Output
Stop Command Valid
5. to telegram bot command
Command Verified Raspberry pi Pass
will Turn off
TROUBLESHOOTING
TROUBLESHOOTING

A) Problems/Faults in Project
We came across various problems while making the project in which the two major problems
were: 1) Pairing the Raspberry pi with Telegram App as the Auth code was getting some kind of
error, 2) Python syntax Error and naming error for components
1) In the first case we witnessed the error in Authentication code as we were not able to get the
correct auth code after creating the Telegram Bot on Telegram App.
2) In the second case we got a syntax error as we tried to increase the connection from 1 gpios pin
to 2 gpios pins.

B) Steps to solve problems/faults in project


1) We created a bot with “Father bot” which makes the work of creating a telegram bot much easier
than any other bot does.
2) We analyzed the error and got to know that it was occurring due to the naming for Switches as
for example: On1/Off1 and On2/Off2
CONCLUSION & REFERENCE
CONCLUSION
Home automation using Telegram bot is a promising technology that allows users to control their
home appliances remotely through their phone. The main contribution of this technology is the
potential of the Telegram application applied to the IoT through Telegram Bot API on the
communication. This technology can be used to control devices such as lights, fans, and air
conditioners by sending commands like "Turn light on".
The system uses open-source hardware such as Raspberry Pi and ESP 32. The communication
between user and the system is done using Telegram Bot. The system can also be used for face
recognition and home automation.
In conclusion, home automation using Telegram bot is a cost-effective way to control your home
appliances remotely. It provides an easy-to-use interface that allows users to send commands via
messaging services like Telegram. This technology has great potential in the future of smart homes.
REFERENCES
1. “Home Automation using Telegram” by P.N.V.S.N. Murthy , S. Tejeswara Rao, G. Mohana
Rao (M.Tech, CSE Department, MVGR College of Engineering, Vizianagaram, India)
2. “Face Recognition and Home Automation Using Telegram Bot” by V Subba Reddy,
Sreevardhan Cheerla, Syed Inthiyaz, VNN Chakravarthy, Gopi Rame (Department of Electronics
and Communication Engineering, Koneru Lakshmaiah Education Foundation, Green Fields,
Vaddeswaram, Guntur (Dist), Andhra Pradesh, India - 522502 )
3. “Webpage And Telegram Bot Controlled Home Automation System Using Raspberry Pi3”
by Dhiraj Sunehra, G. Venkat Ramana
4. “Improving Smart Home Concept with the Internet of Things Concept Using RaspberryPi
and NodeMCU” by Yasirli Amri, Mukhammad Andri Setiawan
THANK YOU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy