Smart Door Lock System using esp32-cam and Telegram chatbot

Home automation gives you access to control devices in your home from a mobile device anywhere in the world. One of the biggest advantages of home automation is that it keeps your abode safe, and prevents accidental fires, water leaks, gas leaks, and other disasters. This project shows how we can use Telegram in our IoT and Home Automation projects. Home Security System using ESP32 CAM which will notify us on Telegram App about person entering the house by capturing and sending his/her photo to us and Door can be controlled by chatbot. With this project we can take multiple photos, unlock and lock the door with the Telegram app.

Version 1: Code

When anyone presses the doorbell, home owner will get a notification in the telegram app with a photo of that person. After that, we can easily unlock and lock the door from the telegram app.

Version 2: Code

Some images of authorized people are registered in the esp32-cam with SD card .

when someone is at the door , if the person is recognizable by the esp32cam as an authorized user then Door unlocks , else capture and send an image of the person to the home owner and let him / her take the decision.

In simple diagram :

Demo :

Changes to be made to reuse the code :

Importing Libraries

Start by importing the required libraries.

#include <Arduino.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include "esp_camera.h"
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>

Network Credentials

Insert your network credentials in the following variables.

const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";

Telegram User ID

Insert your chat ID. The one you’ve got from the IDBot.


Telegram Bot Token

Insert your Telegram Bot token you’ve got from Botfather on the BOTtoken variable.


Full code in the github repository :




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

This is the Main Difference of Writing Applications in Functional Programming vs.

Changing Summation Limits: A Computational Solution To A Programming Interview Question

Deploying a Springboot application/ JAR as a windows service using winsw

Go Interfaces, can be a type of its own….

Get started with Machine Learning on AWS

Moving Platforms in Unity

Day 7 of #30DaysOfCode | lifetime of variables in golang

2.5D Platformer: Wall Jumping

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium


Polycam can export to several different file formats. What are they?

Build a Weather Mobile App with Ionic

The differences between static and dynamic libraries