You are on page 1of 77

A

PROJECT WORK
ON

IOT OPERATED DOOR LOCK USING ESP32CAM MODULE

Submitted in Partial Fulfillment of the requirements for the award of


Degree of
BACHELOR OF TECHNOLOGY
In
ELECTRONICS AND COMMUNICATION ENGINEERING

Submitted to

DR. APJ ABDUL KALAM TECHNICAL UNIVERSITY ,


LUCKNOW, UTTAR PRADESH
Submitted By
1. SURAJ KUMAR TAYAL (2006950319002)
2. MEENU (2006950319001)
3. SAKSHI (1906950310039)
4. MAHIMA RANI (1906950310014)

Under the Supervision of


Mrs. Indu
(Asst. Prof, Dept of ECE)

(2019-2023)
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
SHRI RAM GROUP OF COLLEGES
Parikarma Marg, Laxman Vihar Colony, Civil Lines South, Muzzafarnagar, U.P.251001
DECLARATION

I hereby declare that the work is being presented in the project, entitled “IOT
operated door lock using ESP32 CAM” partial fulfillment of the requirements for the
award of BACHELOR OF TECHNOLOGY in (Electronics and communication)
submitted in the department of Electronics and Communication Engineering (Shri Ram
Group of Colleges, Muzaffarnagar) is an authentic record of my own work carried under
the guidance of Asst. prof. Mrs. Indu. I have not submitted the matter embodied in this
report for the award of my degree.

SUPERVISIOR SURAJ KUMAR TAYAL

ASST.PROF. MRS. INDU Roll No: 2006950319002

MEENU
Roll No: 2006950319002

MAHIMA RANI
Roll No: 1906950310014

SAKSHI
Roll No: 1906950310039

CERTIFICATE
iv
This is to certify that the project entitled “IOT operated door lock using ESP
CAM module” is being submitted by SURAJ KUMAR TAYAL (2006950319002),
MEENU (2006950319001), MAHIMA RANI (1906950310014), SAKSHI
(1906950310039) in partial fulfillment for the award of degree of “BACHELOR OF
TECHNOLOGY” in Electronics and Communication Engineering of the ‘Shri Ram
Group of Colleges, Muzaffarnagar’ (Affiliated to- Dr. APJ Abdul Kalam Technical
University, Lucknow) is a record of their own work, carried out under my supervision.

H.O.D EXTERNAL EXAMINER

MRS. KANUPRIYA
Dept of Electronics and comm. Engineering
Shri Ram Group of Colleges,
Muzaffarnagar (U.P.), 251001

SUPERVISOR

ASST.PROF. MRS. INDU


Dept of Electronics and comm. Engineering
Shri Ram Group of Colleges,
Muzaffarnagar (U.P.), 251001
ABSTRACT

In terms of house security, the door is crucial. To keep the residence secure, the
owner will keep the door locked at all times. However, owing to a rush when leaving the
house, the house owner may forget to lock the door, or they may be unsure if they have
closed the door or not. In this project, we have presented a “IOT operated door lock
using ESP32 CAM module”. In this simple working model, when a person hits the
doorbell, the owner receives a notification on his/her phone with a photo of that person.
The owner can also unlock the door from a mobile phone after checking the photo.
The proposed Door Security System application Door Lock with ESP32 and
Internet of Things (IoT) technology to monitor the status of the door, manages the door,
and increase security in a home. Blink is a communication protocol that connects a
Smartphone to a door lock system and is used to increase the security of a home. Door
plays an important role in home security. To secure the house, the occupants of the house
will always have the door locked.
However, sometimes the house occupants forget to lock the door due to hurry
when leaving the house, or they may doubt whether they have locked the door or not. We
propose an application called Door Security System which is based on Android using
Internet of Things (IoT) technology to monitor the status of the door, controlling the door
and increasing security in a house. MQTT cloud is utilized as the communication protocol
between Smartphone and door lock system. PIR sensor is implemented in the door lock to
detect the movement near the door, while touch sensor is installed on the door handle to
recognize the human hand. With the advancement of technology and the increasing use of
IOT, digital door locks have become very common these days. Digital lock doesn’t require
any physical key but it uses RFID, fingerprint, passwords, etc. to control the door lock. In
past, we have developed many digital door locks applications using these various
technologies. That it can be monitored by the mobile and can grant the permission to
access the door. It also enabled with notification when someone is detected by the system
and alerts to the owner. A door is one of the defense features to take care of physical
security of the house. If the door of the home is often opened easily, a thief can easily enter
and steal the contents of the house. At first, a door only requires a physical key to lock or
unlock the door but on the other hand, with the advancement of technology, a more modern
door has been innovated, namely the digital door which will lock or unlock doors without
requiring any physical key. We propose an application called Face detection Door lock.
This is predicated on Arduino using Internet of Things (IOT) technology to watch the
status of the door, control the door and increase security.
ACKNOWLEDGEMENT

It gives us a great sense of pleasure to present the report of B.Tech. Project


undertaken during B.Tech final year. We owe special debt of gratitude to Professor Mrs.
Indu (Asst. prof.) Department of Electronics and Communication Engineering, Shri Ram
Group of Colleges, Muzaffarnagar, for her content support and guidance throughout the
course of our work. Her sincerity, thoroughness and perservance have been a constant
source inspiration for us. It is only her cognizant effort that our endeavors have been light
of the day. We also take the opportunity to acknowledge to contribution to Professor Mrs.
Kanupriya, Head of Department of Electronics and Communication Engineering, Shri Ram
Group of Colleges, Muzaffarnagar, for her full support and assistance during the
development of project.
We also do not like to miss the opportunity to acknowledge the contribution of all faculty
member of the department for their kind assistance and cooperation during the
development of our project. Last but not least we acknowledge our friends for their
contribution on the completion of the project.

Signature: Signature:

Name: Suraj Kumar Tayal Name: Meenu


Roll No: 2006950319002 Roll No: 2006950319001
Date: Date:

Signature: Signature:

Name: Mahima Rani Name: Sakshi


Roll No: 1906950310014 Roll No: 1906950310039
Date: Date:

vii
TABLE OF CONTENTS

Page No
Cover page
Declaration …..………………………………………………………………………….i
Certificate..….…………………………………………………………………………..ii
Abstract…………………………………………………………………………..……..iii
Ackowledgement……………………………………………………………………….iv
Table of contents……………………………………….……………….………………v
List of figures…………….……………………..……………………..……………….vii
Literature Review………………………………………………………..…….............viii
Scope of work in the project……………………………………………..…………..…ix

Chapter -1 (Introduction)……...………………………………………………….…1-3

1.1 Problem statement…………………………………………………………………..1


1.2 Proposed system………………………………………...…………………..............2
1.3 Introduction……………………………………………………………….………...3

Chapter-2(Components And Working)...................................................................4-24

2.1ESP32 CAM ………………………….…………………………………………......5


2.2Electronic Lock……………………………………………………………………...7
2.3Transistor…………………………………………….…………………….……..….9
2.4Regulator………………………………….………………………………...............11
2.5Diode………………………………………………………………………………..13
2.6 Resistor…………………………………………………………………….…….....15
2.7 10k register……………………………………………………………….………...17
2.8 Capacitor………………………………………………………………….………..19
2.9 Push Switch……………………………………………………………….………..21
2.10 DC supply…………………………………………………………………….......24

Chapter-3 (Testing and Implementation)..............................................................25-46

3.1Working……………………………………………………………………………..25
3.2 Circuit diagram …………………...………………………………………………..26
3.3 Configuration of telegram app…………………………………………….……......27
3.4 Program ESP32 Cam with USB To TTL…………..……………………….……...28
3.5 Arduino IDE setup for ESP32 Cam………………………………………………..29
3.6 Program ESP32 Cam with Arduino IDE…………………………………………..32
3.7 Code ………………………………………………………………………….…...38
Chapter-4 ( Result Analysis)...................................................................................47-50

Result Analysis……………………………………………………………………..….47

Chapter-5 ( Applications)........................................................................................51-55

5.1QR Code Scanner …………………………………………………………....…….51


5.2Motion detection squid game ………………………………………………...........52
5.3 Gesture Controlled virtual mouse …………………….………………….………..53
5.4Diy AI camera with Google vision …………………….…….…….……..…........54
5.5Face recognition attendence system …………………..….…………………..........55

Chapter-6(Advantagges and Disadvantages).........................................................56-59

6.1 Advantage…………………………………………………………………………..56
6.2 Disadvantage……………………………………………………………………….59

Chapter-7( Future Enhancements)..............................................................................60

7.1 Future enhancement………………………………………………………………..60

Chapter-8 (Conclusion and Reference)..................................................................61-62

8.1 Conclusion……………...………………………………………………….…….…61
8.2 Reference……………………………………………………………….…………..62
LIST OF FIGURES

1. INTRODUCTION

1.1 Block diagram of the project 2

2. COMPONENTS AND MATERIAL USED

2.1 ESP-32 CAM module 6


2.2 Electronic lock 8
2.3 NPN transistor 10
2.4 Regulator 12
2.5 Diode 14
2.6 1k register 16
2.7 10k register 18
2.8 DC capacitor 20
2.9 Push switch 22
2.10 Dc supply 23

3. TESTING AND IMPLEMENTATION

3.1 Circuit diagram of ESP-32 CAM 26


3.2 ESP-32 CAM programming with USB to TTL convertor 28

4. RESULT ANALYSIS

4.1 IOT operated door lock with ESP-32 CAM 47


4.2 Testing ESP-32 CAM with telegram app 48
4.3 ESP-32 CAM capturing multiple photos 49
4.4 ESP-32 CAM is lock/unlock the door 50
LITERATURE REVIEW

Since past few years most of the industries are working in the fields of loT based
project the major motto of all these is to make things easy and smart. These became
need for digitalizing with loT security tools by these our daily life locks become smart
and also introduced the locks movable with stepper motor and need to digital number
pad to get input from user, and it need to add infrared or any Bluetooth module to
operate all these devices. A major difference in smart wifi door lock is that no need to
use stepper motor and the application detects the person entered at the door and send
images in the telegram application. We have eliminated unwanted components of
stepper motor and drivers which are in existing models. We have added newer and
unparalleled features of Wifi based door lock as an access point to open or close the
door. It is unique and user friendly. This wifi based door lock system allowing people to
get more interested in because of its leatures and advantages and also due to its
functionality. There are some of drawbacks in that based on that the industries working
in this field and improving the security models day by day.

The creation of smart home is where the parts of a home is manipulated and
designed to operate wirelessly, where an example of parts of a home is the door. The
original basic function of a smart door is to increase a home's security system. By
creating a smart door, it can enhance a home's security system by installing an
automated door lock, which enables access to authorized user's. and installing
surveillance system, which can help in catching a criminal.
The system should be scalable so that new devices can easily be integrated into it. It
should provide a user- friendly interface on the host side, so that the devices can be
easily setup, monitored and controlled. This interface should also provide some
diagnostic services so that if there is any problem with the system, it can be tracked
down. Moreover the overall system should be fast enough to realize the true power of
wireless technology. Finally the system should be cost effective.Currently, there are lots
of thefts are going on, become significant issues for all. By these of wifi based door
lock become more secure in these fields, here we can use fingerprint scanner for
fingerprint recognition, so others cannot enter inside.
SCOPE OF WORK IN THE PROJECT
CHAPTER 1

INTRODUCTION

1.1 PROBLEM STATEMENT

People nowadays are busy with daily activities. Recently, the number of break-
in and attack of these easy targets is increasing. Sometimes if the gas, smoke or fire
catches means we get to know about that some amount of time. If we detect this earlier
means we can take an action. Android Based Smart door locking system is designed to
prevent unauthorized access, trespassing and intrusion. Banks, corporate offices,
financial organization, jeweler shops, and government organization are some of the
common targets where unauthorized access, trespassing and intrusion take place.
Normally the aim behind such activities is stealing money, jewels or any important
documents for individual gain. The purpose of Android Based Smart door locking
system is to provide a smart solution to overcome these challenges and provide a
feasible solution. This system works on pre- decided password concept. It increases the
security level to prevent an unauthorized unlocking done by attacker. In case the user
forgets the passwords, system gives the flexibility to the user to change or reset the
password. This automatic password based lock system gives user more secure way of
locking-unlocking the system.
The most common examples of smart devices are wearable’s like watches.
Smart watches such as the Apple Watch and Fit bit have penetrated the market not very
long ago. Such devices have also entered our homes with products such as Amazon
Echo, a voice assistant, which users can talk with to play music, provide weather, and
control other IOT devices. An exponential growth is expected for the IOT market and
an increasing number of smart devices show the inclination of the industry toward
offering these interconnected solutions to increase convenience, but also the high
adoption rate of the population. The idea behind the modern day smart locks is to unify
the functionality provided by convenient and secure access control methods with the
convenience of internet connectivity and remote control. There are a few products on
the market that offer these systems and we will talk about two of them, once again
focusing on the features they offer and potential disadvantages, as these products will
serve as inspiration for our actual product implementation.
1.2 PROPOSED SYSTEM

 To overcome these problems there is a need to install a home security system which
can detect intrusion and trigger alarm. A home security system is one line of defense a
home can provide intrudes. Such systems can also help to protect a home from fire and
gas leakage by bringing a home’s smoke detectors under its control.
 To Interact with our security system and get notified about all the alerts we need to
create Telegram Bot on Telegram Application in our smart phone.
 In terms of house security, the door is crucial. Now days everyone has smart phones
and having internet access easily.
 Here we want to develop a smart door control with telegram app. We can access
telegram app from PC or mobile phone. We can lock and unlock door by controlling
valve from telegram app. Also, it will send photo whenever doing lock and unlock.
 Anyone nowadays is concerned about security, whether it is data security or the
security of their own home. In this project, we'll use the Camera (ESP32 CAM) to
create an IOT-based Wi-Fi Door Lock system with telegram app.
 In this simple working model, once an individual hits the doorbell, the owner receives
a notification on his/her phone with a photograph of that person.
 The owner can also unlock the door from a mobile phone after checking the photo.
 In this ESP32 CAM project, we have explained how to make Wi-Fi door lock with
photo capture usingESP32CAM and Telegram app.
 With this IOT project you can take multiple photos, unlock and lock the door from
anywhere in the world with the Telegram app.
 When anyone presses the doorbell, you will get a notification in the telegram app with
a photo of that person.
 After that, you can easily unlock and lock the door from the telegram app.
 So this IOT project also can be used as a home security system.
 In this report, we have explained all the steps to make this Wi-Fi door lock with photo
capture
1.3 BLOCK DIAGRAM

The block diagram of the project entitled “IOT operated door lock using ESP32 CAM
module”, is given below. This includes button, ESP32 CAM module, and door lock,
internet to connect our project with the telegram app and to activate lock from telegram.

ESP 32 CAM
Button Module Door Lock

Internet

Activate Lock from


Telegram

Telegram Take Picture from


Telegram

Fig 1.1: Block Diagram of IOT Operated door lock using


ESP32 CAM module
Door plays a vital role in home security. To secure the house, occupants of the
house can continuously have the door Locked. However, generally the house occupants
forgot to lock the door because of hurry once going the house, or they will doubt whether
or not they have secured the door or not. We propose a Project referred to as Door Security
System that is predicated on mechanical man victimization Internet of Things (IOT)
technology to watch the standing of the Door, dominant the Door and increase security in
an exceedingly house.
A door is one amongst the defense options to keep up physical security of the
house. If the door of the house is often opened simply, an outlaw can easily enter and steal
the contents of the house. At first, a door solely incorporated a physical key to lock or
unlock the door however then, with the advancement of technology, an additional trendy
door has been innovated, specifically the digital door which will lock or unlock doors
while not requiring any physical Key.
There are many security systems but this technology is best security system which
cannot be hacked by anyone because everyone has different facial characteristics. A facial
framework is a framework which gets the facial images and detects a characteristic of man
using camera. This is an application for investigating or checking a man image in a
computerized form we want to provide high level security to protect home by IOT
technology.
IOT technology is one of most commonly used technology in the fast-growing
world because it provides high security the use of IOT will give some high security level
and also it helps in accessing or controlling the system remotely. So, here we are trying to
provide a face detection- based door unlock system based on IOT technology. IOT has
some characteristics like sensing, actuating and communication in the system. System can
be automated easily. So, we can go on developing a smart home by smart security system.

In this project, we've given a wise Wi–Fi Door Lock mistreatment the ESP32
CAM and therefore the wire App. during this straightforward operating model, once an
individual hits the doorbell, the owner receives a notification on his/her phone with a
photograph of that person. The owner also can unlock the door from a transportable when
checking the photo. The aim of the project is dominant the Door and increase Security in
an exceedingly House. It’s a cool technology wherever we are able to unlock mobile
phones or to access any application that needs high security. With ESP 32 CAM, we can
attempt develop an easy project that uses your face as ID. Since ESP32 board already
comes with Camera internet Server example code that caters for video stream, So this can
be a simple however terribly helpful home automation project exploitation ESP 32 camera
module.
CHAPTER 2

COMPONENTS AND WORKING

o Hardware

2.1 ESP32CAM board


2.2 12V Electronic Lock
2.3 TIP122 NPN Transistor
2.4 7805 5V regulator
2.5 1N4007 diode
2.6 1k 0.25-watt Resistor
2.7 10k 0.25-watt Resistor
2.8 100uF 25V DC Capacitor
2.9 Push Switch
2.10 12V DC supply

o Software

 Arduino IDE
2.1 ESP32CAM Board

The ESP32 CAM is a full-featured microcontroller that also has an integrated


video camera and micro SD card socket. It’s inexpensive and easy to use, and is perfect
for IOT devices requiring a camera with advanced functions like image tracking and
recognition. The sample software distributed by express if includes a sketch that allows
you to build a web-based camera with a sophisticated control panel. After you get the hang
of programming the device, you’ll find that it is very easy to use. Not bad for a board that
costs about ten dollars, including the camera!
The ESP32 CAM module has fewer I/O pins than the previous ESP32 module we
looked at. Many of the GPIO pins are used internally for the camera and the micro SD card
port. Another thing missing from the ESP32 CAM module is a USB port. In order to
program this device, you’ll need to make use of an FTDI adapter. One thing to note about
this module is that it has components on both sides of the printed circuit board. The “top”
of the board has the connector for the camera module, as well as the micro SD (sometimes
called “TF”) card socket. You’ll also note a square white LED on the top of the module,
this can act as a “flash” for illuminating the subject you are trying to view with the camera.
The underside of the circuit board has the ESP32-S module. It also has a
connector for an external antenna, as well as an internal antenna that is etched onto the
circuit board. I’ll explain how to use the external antenna shortly. Another key component
located underneath the board is the reset switch. Because there are so many components on
the bottom of the module you may find it easier not to use a solder less breadboard when
experimenting with the ESP32 CAM module. The use of jumpers with female DuPont
connectors is recommended.
Using the ESP32 CAM is similar to using the ESP32 modules we looked at
previously, with one major difference. The ESP32 CAM board has no USB port, so you
can’t just connect it up to your computer and start loading programs. Instead, you will need
to add an external FTDI adapter. This is the same adapter you would use programming an
Arduino Pro Mini, so if you’ve worked with the Pro Mini then you probably already have
one of these. The ESP32 CAM is a small size, low power consumption camera module
based on ESP32. It comes with an OV2640 camera and provides onboard TF card slot. The
ESP32 CAM can be widely used in intelligent IOT applications such as wireless video
monitoring, Wi-Fi image upload, QR identification, and so on. The ESP32 CAM is a small
size, low power consumption camera module based on ESP32. It comes with an OV2640
camera and provides onboard TF card slot.
The ESP32 CAM can be widely used in intelligent IOT applications such as
wireless video monitoring, Wi-Fi image upload, QR identification, and so on. ESP32 CAM
is a low-cost ESP32-based development board with onboard camera, small in size. It is an
ideal solution for IOT application, prototypes constructions and DIY projects. The board
integrates Wi-Fi, traditional Bluetooth and low power BLE, with 2 high performance 32-
bit LX6 CPUs. It adopts 7-stage pipeline architecture, on-chip sensor, Hall sensor,
temperature sensor and so on, and its main frequency adjustment ranges from 80MHz to
240MHz.
The ESP32CAM suit for IOT applications such as:
 Smart home devices image upload
 Wireless monitoring
 Intelligent agriculture
 QR wireless identification
 facial recognition

 The ESP32 CAM is a very small camera module with the ESP32-S chip that costs
approximately $10. Besides the OV2640 camera, and several GPIOs to connect
peripherals, it also features a micro SD card slot that can be useful to store images taken
with the camera or to store files to serve to clients.
 ESP32 can perform as a complete standalone system or as a slave device to a host MCU,
reducing communication stack overhead on the main application processor. ESP32 can
interface with other systems to provide Wi-Fi and Bluetooth functionality through its SPI
/ SDIO or I2C / UART interfaces.

Fig 2.1: ESP32 CAM Module


2.2 12V Electronic Lock

This is a simple to use 12V Electronic Cabinet/Door Lock. You can use it to lock
and unlock Cabinets/Doors using a 12V power supply. These Locks are basically
electromagnets: they are made of a big coil of copper wire with an armature (a slug of
metal) in the middle. This 12V Cabinet Door Electromagnetic Solenoid Lock can be used
for locking sell-machine, storage shelf, file cabinet and etc. It is steady, durable, and
energy-saving and had a long lifespan. In the anti-theft and shockproof design, the lock is
better than other kinds of locks.12V Solenoid lock has a slug with a slanted cut and a good
mounting bracket. It's basically an electronic lock, designed for a basic cabinet, safe or
door. When 9-12VDC is applied, the slug pulls in so it doesn't stick out and the door can be
opened. It does not use any power in this state. It is very easy to install for automatic door
lock systems like electric door lock with the mounting board. This solenoid in particular is
nice and strong.

Specifications of 12V solenoid lock:

 Operating voltage: 12VDC


 Draws 650mA at 12V, 500 mA at 9V when activated
 Designed for 1-10 seconds long activation time
 Wire length: 222.25mm

Electric door locks are a new and improved way to keep your home secure. They
replace your keys or work in conjunction with them. When you have electronic door locks,
you will be able to remotely lock and unlock your doors as well as monitor whether they
are locked or not. You can use a key fob, your car, a mobile application, or a key code to
unlock them. These were first found on cars; they are now available in homes and
apartments as well. For any type of door lock, you need a key of sorts to get into it.
However, keys aren’t always efficient because they require the use of your hands
(problematic if you have to carry something inside or you are older and have arthritis), you
need to carry them (not always great for children who are prone to losing things), and take
time (not good if the weather is poor or you live in a dangerous area). The lock system
works just like a traditional lock – with a latch and a bolt. Traditionally, keys work with a
pin and tumbler system where the lock cylinder is held in place and the key turns them and
moves the lock a certain distance – enough to allow the door to open. There are other ways
to get this open, but they often take a certain amount of skill and a long time.
12V Solenoid lock has a slug with a slanted cut and a good mounting bracket. It's
basically an electronic lock, designed for a basic cabinet, safe or door. When 9-12VDC is
applied, the slug pulls in so it doesn't stick out and the door can be opened. It does not use
any power in this state. It is very easy to install for automatic door lock systems like
electric door lock with the mounting board. This solenoid in particular is nice and strong.
A continuous duty solenoid works much like a regular starter solenoid, opening and
closing a circuit in order to turn the power flow off and on. As you might have guessed,
however, in the case of a continuous duty solenoid the power flow is more of a constant,
whereas a starter solenoid operates intermittently.
12V Solenoid locks are basically electromagnets: they are made of a big coil of
copper wire with an armature (a slug of metal) in the middle. When the coil is energized,
the slug is pulled into the center of the coil. This makes the solenoid able to pull from one
end. The 12V DC solenoid lock is used for locking sell-machine, storage shelf, file cabinet
and etc. The solenoid 12V lock works as the circuits disconnects, and it will unlock as the
instant power-on.

Fig 2.2: 12 volt Electronic lock


2.3 NPN Transistor

A transistor is a semiconductor device used to amplify or switch electrical signals


and power. It is one of the basic building blocks of modern electronics. It is composed
of semiconductor material, usually with at least three terminals for connection to an
electronic circuit. A voltage or current applied to one pair of the transistor's terminals
controls the current through another pair of terminals. Because the controlled (output)
power can be higher than the controlling (input) power, a transistor can amplify a signal.
Some transistors are packaged individually, but many more in miniature form are found
embedded in integrated circuits. Most transistors are made from very pure silicon, and
some from germanium, but certain other semiconductor materials are sometimes used. A
transistor may have only one kind of charge carrier, in a field-effect transistor, or may have
two kinds of charge carriers in bipolar junction transistor devices. Compared with
the vacuum tube, transistors are generally smaller and require less power to operate.
Certain vacuum tubes have advantages over transistors at very high operating frequencies
or high operating voltages. Many types of transistors are made to standardized
specifications by multiple manufacturers.
Transistors are commonly used in digital circuits as electronic switches which can
be either in an "on" or "off" state, both for high-power applications such as switched-mode
power supplies and for low-power applications such as logic gates. Important parameters
for this application include the current switched, the voltage handled, and the switching
speed, characterized by the times. In a switching circuit, the goal is to simulate, as near as
possible, the ideal switch having the properties of an open circuit when off, the short circuit
when on, and an instantaneous transition between the two states. Parameters are chosen
such that the "off" output is limited to leakage currents too small to affect connected
circuitry, the resistance of the transistor in the "on" state is too small to affect circuitry, and
the transition between the two states is fast enough not to have a detrimental effect.
In a grounded-emitter transistor circuit, such as the light-switch circuit shown, as
the base voltage rises, the emitter and collector currents rise exponentially. The collector
voltage drops because of reduced resistance from the collector to the emitter. If the voltage
difference between the collector and emitter were zero (or near zero), the collector current
would be limited only by the load resistance (light bulb) and the supply voltage. This is
called saturation because the current is flowing from collector to emitter freely. When
saturated, the switch is said to be on. The use of bipolar transistors for switching
applications requires biasing the transistor so that it operates between its cut-off region in
the off-state and the saturation region (on). This requires sufficient base drive current. As
the transistor provides current gain, it facilitates the switching of a relatively large current
in the collector by a much smaller current into the base terminal.
The ratio of these currents varies depending on the type of transistor, and even for
a particular type, varies depending on the collector current. In the example of a light-switch
circuit, as shown, the resistor is chosen to provide enough base current to ensure the
transistor is saturated. The base resistor value is calculated from the supply voltage,
transistor C-E junction voltage drop, collector current, and amplification factor beta.
The TIP122 is a Darlington pair NPN transistor. It functions like a normal NPN
transistor, but since it has a Darlington pair inside it has a good collector current rating of
about 5A and a gain of about 1000. It can also withstand about 100V across its collector-
Emitter hence can be used to drive heavy loads. This transistor is known for its high
current gain (hfe = 1000) and high collector current (IC =5A) hence it is normally used to
control loads with high current or in applications where high amplification is required. This
transistor has a low Base-Emitter Voltage of the only 5V hence can be easily controlled by
a Logic device like microcontrollers. Although care has to be taken to check if the logic
device can source up to 120mA.So, if you looking for a transistor that could be easily
controlled by a Logic device to switch high power loads or to amplify high current then
this Transistor might be an ideal choice for your application.
This transistor can be used as a switch within different electronic circuits to drive
different loads below 5A based on its features. The application circuits of this transistor
mainly include a battery charger, power supply, motors driving, etc. This transistor can
also be used as an amplifier & audio pre-amplifier. This transistor can be used as a switch
within different electronic circuits to drive different loads below 5A based on its features.
The application circuits of this transistor mainly include a battery charger, power supply,
motors driving etc. This transistor can also be used as an amplifier & audio pre-amplifier.
This transistor EB voltage is 5V DC. This transistor can be connected to the
microcontroller’s o/p & logic devices for controlling below 5A loads. So this transistor is a
perfect choice for your requirement. To get good performance through this Darlington
transistor, maximum ratings must maintain to below. This transistor shouldn’t use when
the circuit is operated above 100V and the load shouldn’t provide above 5A. A base
resistor must use for providing the required current on the base terminal. From the
overheating, this transistor can be protected by using a heat sink. Maintain the temperature
from 65C to +150 C.

Fig 2.3: TIP122 NPN Transistor


2.4 7805 5V Regulator

Voltage regulator, any electrical or electronic device that maintains the voltage of
a power source within acceptable limits. The voltage regulator is needed to keep voltages
within the prescribed range that can be tolerated by the electrical equipment using that
voltage. The voltage regulator 7805 is a member of 78xx series, where the "78" represents
a positive voltage regulator and "xx" represents the regulated output voltage. Hence, the IC
7805 is a positive voltage regulator having +5 volts regulated output voltage. A voltage
regulator is an essential element of power supplies used in several electrical and electronic
devices such as computers, amplifier, automobile alternator, mobile chargers, etc.
A voltage regulator is basically an electronic circuit that generates a regulated voltage of
fixed value from an unregulated fluctuating voltage.
A voltage regulator is required in a circuit because all voltage sources cannot
provide a steady voltage due to change in the load current and other circuit parameters like
temperature. Therefore, the primary function of a voltage regulator is to convert the
fluctuating voltage of a voltage source into a constant and steady output voltage. Today,
we use voltage regulators in the form of integrated circuits (ICs). The voltage regulator IC
7805 is a member of the 78xx series of voltage regulator ICs. The voltage regulator 7805 is
a linear voltage regulator. In the 78xx series of voltage regulators, the “xx” represents the
steady output voltage produced by the voltage regulator. Therefore, for the voltage
regulator IC 7805, the steady output voltage is +5 V DC. It is to be noted that the
maximum input voltage of the voltage regulator IC 7805 is 35 V.
Therefore, the voltage regulator 7805 can produce a steady output voltage of 5 V
for any value of input voltage less than or equal to 35 V. Hence, the 34 V is the threshold
limit of the input voltage for a voltage regulator 7805 IC. In voltage regulator 7805 IC, a
large amount of energy is exhausted in the form of heat. This is because there is a high
difference between the input and output voltage which is converted in heat within the
regulator IC. Therefore, to dissipate this heat, a heat sink is provided with the voltage
regulator IC 7805. If we do not use the heat sink, the excessive heating of the regulator IC
may cause malfunctioning of the device. Voltage regulator 7805 IC is one of the most
widely used voltage regulator IC in different electrical and electronic circuits. It takes an
unregulated voltage of 7 V to 35 V and produces a fixed regulated output voltage of 5 V
DC.7805 is a three terminal linear voltage regulator IC with a fixed output voltage of 5V
which is useful in a wide range of applications. Currently, the 7805 Voltage Regulator IC
is manufactured by Texas Instruments, ON Semiconductor, STMicroelectronics, Diodes
incorporated, Infineon Technologies, etc. They are available in several IC Packages like
TO-220, SOT-223, TO-263 and TO-3. Out of these, the TO-220 Package is the most
commonly used one (it is the one shown in the above image). The name 7805 signifies two
meaning, “78” means that it is a positive voltage regulator and “05” means that it provides
5V as output. So our 7805 will provide a +5V output voltage.
The output current of this IC can go up to 1.5A.The 7805 is a fixed voltage linear
regulator that outputs 5V at up to 1A current with an input voltage range of 7 – 35V.7805
is a three terminal linear voltage regulator IC with a fixed output voltage of 5V which is
useful in a wide range of applications. Currently, the 7805 Voltage Regulator IC is
manufactured by Texas Instruments, ON Semiconductor, STMicroelectronics, Diodes
incorporated, Infineon Technologies, etc. Voltage regulator 7805 uses less number of
component to work properly. Its minimum and maximum input voltage is 7 V and 35 V
respectively. Voltage regulator 7805 can deliver an output current of up to 1.5 A. The
operating current of the voltage regulator 7805 IC is 5 mA. Voltage regulator 7805
provides all the necessary protections such as protection against the short circuit and
thermal overload.
In electrical and electronic circuits, the voltage regulator 7805 IC has a wide
range of applications. Voltage regulator 7805 IC is used in mobile changers, UPS power
supplies, portable CD players, current regulators and fixed output regulators, and
adjustable output voltage regulators. It is also used as a +5V voltage regulator.

Fig 2.4:7805 5V Regulator


2.5 1N4007 Diode

1N means Single Junction semiconductor. 2N means Double Junction


semiconductor. 1 stands for 1 junction. Since the diode is made by two dissimilar P and N
semiconductor. A junction is formed between them. N stands for semiconductor diode and
4007 is the identification number of that particular diode.1N4007 is general silicon rectifier
diode with the plastic package form of DO-41. It is widely used in various AC-to-DC
rectifier circuits, and also used in bridge rectifier circuits.1N4007 is a rectifier diode,
designed specifically for circuits that need to convert alternating current to direct current. It
can pass currents of up to 1 A, and have peak inverse voltage (PIV) rating of 1,000V.The
1N4007 diode has a continuous reverse voltage rating of 1000V and is suitable for forward
currents of up to 1A. The diode has a forward voltage drop of 1.1V. The 1N4007 diode
is designed to operate with high voltages and can easily withstand voltages below 1000V.
The average direct current of 1000mA or 1A, the 3W power dissipation, its small size, and
low cost make it an ideal diode for a wide variety of applications.1N4007 1000V 1A
Standard Recovery Diode is a Fast Recovery Diode semiconductor device with a short
reverse recovery time for rectification purposes at high frequency.
A diode is a basic PN junction semiconductor device well-known in the
microelectronics world. Because it is constructed with P and N-type materials. It acts as a
one-way switch that allows the current to flow in one direction and halts in the other
direction.1N4007 belongs to the silicon family of1N400X series. It is a general-purpose
rectifying diode that serves its purpose of converting alternating current signals (AC) to
direct current signals (DC) in electronic products. This tutorial will discuss its pin out,
features, specifications, example circuits, and applications. It has two terminals, i.e., Anode
(positively-charged) and Cathode (negatively-charged). The diode has two states based on
the connection of anode and cathode. For the current to flow from anode to cathode, the
anode should be connected to a higher potential than the cathode (forward biasing). The
current which flows from anode to a cathode terminal is known as a forward current.
Reverse biasing will restrict the flow of current and can damage the device if voltage
applied is greater than reverse breakdown voltage. During reverse biasing leakage current
flows through a diode which is negligible compared to forward current.
1N4007 also requires a reverse recovery time to recover during switching from
forward to reverse biased mode. During reverse recovery, diode produces a high reverse
current which produces heat. When the input voltage applied to the anode terminal is +ve
as compared to the cathode terminal, the diode is said to be forward-biased. When this
applied input voltage becomes greater than 0.6 volts, IN4007 diode acts as a short circuit.
0.6V is a forward drop voltage of 1N4007.The higher is a frequency of input signal, the
higher time diode takes to recover its state. 1N4007 is a low-frequency diode due to high
recovery time. Therefore, you should use it for low frequency applications only.
The 1N4007 belongs to a sort of 1 A general-purpose silicon rectifier diode,
commonly used in AC adapters for common household appliances. It is fairly low-speed
rectifier diode, being inefficient for square waves of more than 15 kHz. The 1N4007 diode
is a standard recovery rectifier with a molded plastic case.1N4007 1000V 1A Standard
Recovery Diode is a Fast Recovery Diode semiconductor device with a short reverse
recovery time for rectification purposes at high frequency. The 1N4007 is the most
commonly used rectifier diode. It is commonly used in rectifier circuits, protection circuits
and regulator circuits. The lead near to the silver line is the cathode and the other lead is
anode, current is allowed to flow only form anode to cathode.
The specifications of the 1N4007 diode are:

 Reverse Voltage: 1000V (peak)


 Forward Current: 1A
 Peak Forward Current: 30A
 Reverse leakage current: 5uA

Applications of 1N4007 Diode:

 Prevent reverse polarity problem


 Current flow regulators
 Half Wave and Full Wave rectifiers
 Used as a protection device

Fig 2.5:1N4007 Diode


2.6 1k 0.25-watt Resistor

1K Ohm Resistor Color Code: Brown, Black, Red, Golden. Resistance: 1K Ohm,
Power Rating: 0.25-Watt, Approximate Maximum Current: 15.81mA. A 1K Ohm resistor
can be identified via resistor color codes of Brown-Black-Red-Gold or Brown-Black-
Black-Brown-Gold. The current running through the 1k-ohm resistor is 6.72 milliamperes.
For the 0.25W part with a maximum voltage of 250V, the critical resistance is 250 kΩ. At
resistances higher than the critical resistance, the maximum continuous rated voltage is
250V. Resistors restrict the flow of electric current, for example a resistor is placed in
series with a light-emitting diode (LED) to limit the current passing through the LED.
Resistors may be connected either way round and they are not damaged by heat when
soldering. Resistance is measured in ohms, symbol (omega).
The tolerance of a resistor is shown by the fourth band of the color code. Tolerance
is the precision of the resistor and it is given as a percentage. Resistors are rated according
to their maximum power dissipation. Discrete resistors in solid-state electronic systems are
typically rated as 1⁄10, 1⁄8, or 1⁄4 watt. They usually absorb much less than a watt of electrical
power and require little attention to their power rating. Power resistors are required to
dissipate substantial amounts of power and are typically used in power supplies, power
conversion circuits, and power amplifiers; this designation is loosely applied to resistors
with power ratings of 1 watt or greater.
Power resistors are physically larger and may not use the preferred values, color
codes, and external packages described below the average power dissipated by a resistor is
more than its power rating, damage to the resistor may occur, permanently altering its
resistance; this is distinct from the reversible change in resistance due to its temperature
coefficient when it warms. Excessive power dissipation may raise the temperature of the
resistor to a point where it can burn the circuit board or adjacent components, or even
cause a fire. There are flameproof resistors that will not produce flames with any overload
of any duration.
Resistors may be specified with higher rated dissipation than is experienced in
service to account for poor air circulation, high altitude, or high temperature. All resistors
have a maximum voltage rating; this may limit the power dissipation for higher resistance
values. For instance, among 1⁄4 watt resistors (a very common sort of leaded resistor) one is
listed with a resistance of 100 MΩand a maximum rated voltage of 750 V. However even
placing 750 V across a 100 MΩ resistor continuously would only result in a power
dissipation of less than 6 mW, making the nominal 1⁄4 watt rating meaningless.
A resistor may have one or more fixed tapping points so that the resistance can be
changed by moving the connecting wires to different terminals. Some wire wound power
resistors have a tapping point that can slide along the resistance element, allowing a larger
or smaller part of the resistance to be used. Where continuous adjustment of the resistance
value during operation of equipment is required, the sliding resistance tap can be connected
to a knob accessible to an operator. Such a device is called a rheostat and has two
terminals. The 1K Ohm resistor is a passive electronic component used to control the flow
of electric current in a circuit.
It has a resistance value of 1,000 ohms and is used to limit the current flow in a
circuit to a specific level. If the 1k resistor is the only component in the completed
circuit, it will drop all of the voltage. That means if the source is 9V, the resistor will drop
9V. If the source is 18V, the resistor will drop 18V, and so on. It is Commonly used in
breadboards and other prototyping applications, these 1K ohm resistors make excellent
pull-ups, pull-downs and current limiters. These thick-lead versions of the resistors fit
snugly into a breadboard with very little movement. In electronic circuits, resistors are
predominantly used to lower the flow of current, divide voltages, block transmission
signals, and bias active elements.

Fig 2.6:1k 0.25-watt Resistor


2.7 10k 0.25-watt Resistor

The 10K Ohm resistor is a passive electronic component used to control the flow
of electric current in a circuit. It has a resistance value of 10,000 Ohms and is used to limit
the current flow in a circuit to a specific level. Commonly used in breadboards and other
prototyping applications, these 10K ohm resistors make excellent pull-ups, pull-downs and
current limiters. These thick-lead versions of the resistors fit snugly into a breadboard with
very little movement.10K Ohm 0.25W High Quality Metal Film Resistor (MFR) with ±1%
Tolerance and Tin-plated Copper Leads. 10K Ohm Resistor Color Code: Brown, Black,
Black, Red, Brown. Resistance: 10K Ohm, Power Rating: 0.25 Watt, Approximate
Maximum Current: 5mA.A resistor is a passive two-terminal electrical component that
implements electrical resistance as a circuit element. In electronic circuits, resistors are
used to reduce current flow, adjust signal levels, to divide voltages, bias active elements,
and terminate transmission lines, among other uses. High-power resistors that can dissipate
many watts of electrical power as heat may be used as part of motor controls, in power
distribution systems, or as test loads for generators.

When an electrical current passes through a resistor due to the presence of a


voltage across it, electrical energy is lost by the resistor in the form of heat and the greater
this current flow the hotter the resistor will get. This is known as the Resistor Power
Rating. Resistors are rated by the value of their resistance and the electrical power given in
watts, (W) that they can safely dissipate based mainly upon their size. Every resistor has a
maximum power rating which is determined by its physical size as generally, the greater its
surface area the more power it can dissipate safely into the ambient air or into a heat sink.
A resistor can be used at any combination of voltage (within reason) and current so long as
its “Dissipating Power Rating” is not exceeded with the resistor power rating indicating
how much power the resistor can convert into heat or absorb without any damage to itself.
The Resistor Power Rating is sometimes called the Resistors WattageRating and is defined
as the amount of heat that a resistive element can dissipate for an indefinite period of time
without degrading its performance. The power rating of resistors can vary a lot from less
than one tenth of a watt to many hundreds of watts depending upon its size, construction
and ambient operating temperature. Most resistors have their maximum resistive power
rating given for an ambient temperature of +70 oC or below. Electrical power is the rate in
time at which energy is used or consumed (converted into heat). The standard unit of
electrical power is the Watt, symbol W and a resistors power rating is also given in Watts.
As with other electrical quantities, prefixes are attached to the word “Watt” when
expressing very large or very small amounts of resistor power. We know from Ohm’s Law
that when a current flows through a resistance, a voltage is dropped across it producing a
product which relates to power.
In other words, if a resistance is subjected to a voltage, or if it conducts a current,
then it will always consume electrical power and we can superimpose these three quantities
of power, voltage and current into a triangle called a Power Triangle with the power,
whichwould be dissipated as heat in the resistor at the top, with the current consumed and
the voltage across it at the bottom as shown. Ohms law allows us to calculate the power
dissipation given the resistance value of the resistor. Generally speaking the larger their
physical size the higher its wattage rating. However, it is always better to select a particular
size resistor that is capable of dissipating two or more times the calculated power. When
resistors with higher wattage ratings are required, wire wound resistors are generally used
to dissipate the excessive heat.

Fixed resistors have resistances that only change slightly with temperature, time
or operating voltage. Variable resistors can be used to adjust circuit elements (such as a
volume control or a lamp dimmer), or as sensing devices for heat, light, humidity, force, or
chemical activity. Resistors are common elements of electrical networks and electronic
circuits and are ubiquitous in electronic equipment. Practical resistors as discrete
components can be composed of various compounds and forms. Resistors are also
implemented within circuits. The electrical function of a resistor is specified by its
resistance: common commercial resistors are manufactured over a range of more than
nine orders of magnitude. The nominal value of the resistance falls within
the manufacturing tolerance, indicated on the component. It is a Low cost miniature carbon
resistors with a high stability suitable for industrial and consumer electronics applications.

Fig 2.7:10k 0.25-watt Resistor


2.8 100uF 25V DC Capacitor

The 100uF cap (the bulk capacitor) is primarily to support the supply during
temporary battery (e.g., banging or dropping). The 100uF should be close to the battery
terminals. Disconnection during physical shock.100μF 25V Electrolytic Capacitor for
smoothing out, filtering and performance tuning low frequency circuits and signals up to
around1KHzorless.Electrolytic capacitors are widely used in switched-mode power
supplies, DC-DC converters and power supplies. These capacitors are available in high
capacitance and voltage rating than ceramic capacitors. High quality 100 uF/25V radial
electrolytic capacitors. Work great as voltage noise suppressors for voltage regulators and
for power supply. Putting one of these across power and ground in each of your projects
ensures a smooth noise resistant power supply and greater reliability. This 100uf 25V Caps
DC Electrolytic Capacitor is designed with high reliability and long life (2000 hrs). It also
features a high ripple current at high frequency and excellent smoothing ability. These
electrolytic capacitors offer a wide range of applications in the field of Power Supply,
Audio Amplifiers, Hobby projects, etc.

An electrolytic capacitor is defined as a type of capacitor that functions using an


electrolyte. This achieves a larger capacitance than other capacitor types. These capacitors
are generally used in DC power supply circuits due to their large capacitance. And small
size to help reduce the ripple voltage or for coupling and decoupling applications. An
electrolyte is essentially a liquid or gel containing a high concentration of ions. Most of the
electrolytic capacitors are polarized, hence used only in DC circuits. This indicates that the
voltage on the positive terminal should be greater than the voltage on the negative terminal.
These electrolytic capacitors exist as either wet-electrolyte or solid polymer commonly
made from tantalum or aluminum, although other materials could also be used. There are a
bewildering array of capacitor characteristics and specifications associated with the humble
capacitor and reading the information printed onto the body of a capacitor can sometimes
be difficult to understand especially when colors or numeric codes are used.

Each family or type of capacitor uses its own unique set of capacitor
characteristics and identification system with some systems being easy to understand, and
others that use misleading letters, colors or symbols. The best way to figure out which
capacitor characteristics the label means is to first figure out what type of family the
capacitor belongs to whether it is ceramic, film, plastic or electrolytic and from that it may
be easier to identify the particular capacitor characteristics. Even though two capacitors
may have exactly the same capacitance value, they may have different voltage ratings. If a
smaller rated voltage capacitor is substituted in place of a higher rated voltage capacitor,
the increased voltage may damage the smaller capacitor.
This 100uf 25V Caps DC electrolytic is made from Aluminum electrolytic
capacitors, found in many applications like power supplies, computer motherboards and
lots of domestic appliances. When working with Electronics circuits, there are many times
in which you may need a capacitor to help smooth out, filter or store electrical charge. In
such times, a 100μF 25V Electrolytic Capacitor is ideal for low frequency signals, to
reduce the effects of ripples, surges as well as sudden drops in current. The 100uF cap (the
bulk capacitor) is primarily to support the supply during temporary battery disconnection
during physical shock (e.g. banging or dropping). The 100uF should be close to the battery
terminals. High quality 1000uF/25V radial electrolytic capacitors. Work great as voltage
noise suppressors for voltage regulators and for power supply. Putting one of these across
power and ground in each of your projects ensures a smooth noise resistant power supply
and greater reliability. 100μF 25V Electrolytic Capacitor for smoothing out, filtering and
performance tuning low frequency circuits and signals up to around 1 KHz or less.

Fig 2.8:100uF 25V DC Capacitor


2.9 Push Switch

A push switch (button) is a momentary or non-latching switch which causes a


temporary change in the state of an electrical circuit only while the switch is physically
actuated. Most push button switches function in the same way. Pressure is placed on the
button or actuator, resulting in the depression of the internal spring and contacts and the
touching of stable contacts at the bottom of the switch. This process will either close or
open the electrical circuit. There are two different types of Pushbutton Switches:
Momentary Operation (self-resetting) Switches that are ON only while they are being
pressed, and Alternate Operation (self-holding) Switches that stay ON when pressed and
released and only turn OFF when they are pressed again.
A 'push to make' switch allows electricity to flow between its two contacts when
held in. When the button is released, the circuit is broken. This type of switch is also
known as a Normally Open (NO) Switch. (Examples: doorbell, computer case power
switch, calculator buttons, individual keys on a keyboard). A 'push to break' switch does
the opposite, i.e. when the button is not pressed, electricity can flow, but when it is pressed
the circuit is broken. This type of switch is also known as a Normally Closed (NC) Switch.
(Examples: Fridge Light Switch, Alarm Switches in Fail-Safe circuits)Many Push switches
are designed to function as both 'push to make' and 'push to break' switches. For these
switches, the wiring of the switch determines whether the switch functions as a 'push to
make' or as a 'push to break' switch.
A push button switch is a mechanical device used to control an electrical circuit in
which the operator manually presses a button to actuate an internal switching mechanism.
They come in a variety of shapes, sizes, and configurations, depending on the design
requirements. Push button switches rely on a simple in-out actuation mechanism. They can
be employed to break (off) or initiate (on) a circuit. Alternatively, they can provide an
input for the user interface of a piece of equipment or start/stop a particular function. Push
button switches may be categorized as being either momentary (where the switch function
only continues for as long as the operator is pushing the button) or maintained (where the
switch function stays latched in that status after it has been actuated).Push button switches
can be classified as being normally open (NO) or normally closed (NC). Normally open
(“OFF” position) switches complete the circuit when actuated, while normally closed
(“ON” position) switches break the circuit when actuated.
Within this classification, the functionality of push button switches can further be defined
in terms of the switching circuit they utilize. These are commonly single pole, single throw
(SPST), single pole, double throw (SPDT), double pole, single throw (DPST), or double
pole, double throw (DPDT).
An SPST has just two terminals, so it can only open and close a single circuit. For
example, it might be used to turn a motor on and off. An SPDT has three terminals and can
thus control two different circuits. Therefore, it may be used to flip between the powering
of two separate LEDs or for moving an item of equipment from a sleepmode to an active
state. DPST and DPDT switch arrangements allow for the simultaneous control of two
isolated circuits. For instance, where one is high voltage and the other is low voltage. For
maintained push button switches, an LED indicator may be worth incorporating. This will
allow the user to quickly determine whether the switch is actuated at that time or not.
However, this feature is unnecessary for momentary switches.
The materials used in the switches can also be enhanced to upgrade their
robustness, but this will also raise the associated unit costs. It will therefore depend on the
nature of the application to determine what is required. Push button switches have been
around for quite some time and might be most well-recognized for their use in classic
arcade machines. However, their use is widespread in various applications, such as vending
machines, portable equipment, household appliances, power tools, and countless other
consumer electronics and industrial controls.

Fig 2.9: Push Switch


2.10 12V DC Supply

12V power supplies (or 12VDC power supplies) are one of the most common
power supplies in use today. In general, a 12VDC output is obtained from a 120VAC or
240VAC input using a combination of transformers, diodes and transistors. The most
essential role of the 12V battery has been to provide a reservoir of power for loads that
require a lot of power. A DC power supply is a type of power supply that gives direct
current (DC) voltage to power a device. Because DC power supply is commonly used on
an engineer ‘s or technician ‘s bench for a ton of power tests, they are also often called a
"bench power supply." a DC power supply can be generated from an AC line. Most
electrical and electronic circuits require a DC voltage source that is constant regardless of
the change in the input.
Although DC batteries can be used as an input, this option is expensive and
requires replacement from time to time. So, it is necessary to first convert an AC input into
a DC voltage source and regulate it to serve this purpose. These power supplies work
by regulating the output voltage with a high-frequency switching process utilizing
feedback with pulse width modulation. Moreover, switching regulated power supplies run
substantial EMI filtering to reduce the load and line's regular and differential noise. 12V
batteries are used in most vehicles because the electrical components such as the starter,
lighting, and ignition systems are designed to operate on 12 volts. The 12-volt rating of a
battery is the nominal voltage and it may be slightly higher or lower depending on the state
of charge and loads. Therefore, a 12-volt system, even one with a higher amperage rating,
is seen as generally lower risk because the 12 volts is usually insufficient to penetrate skin
and other objects. Low voltage systems do have a lower risk, but that is not to say they are
risk-free.
The 12V DC power supply is among the leading power supplies in today's
technological world. Mainly because of its affordability, reliability, and ease of use. A
12VDC power supply is a device that supplies electrical energy to a load. In other words, a
power supply's primary purpose is converting electric current from the source into the
required voltage, frequency, and current, which powers the load. At our lowest voltage
offering, the 12 VDC motor is ideal for applications with a DC power supply requiring
high starting and running torque. Our 12 VDC motors are capable of operating at much
lower speeds than our other DC motor voltages. During normal operation, the 12 Volt
battery is charged via a DC / DC converter from the HV battery but the power demand
from various components is highly fluctuating. Thus, the 12 Volt battery is needed to
buffer the electrical system, enabling to supply components like: Electronic power steering
actuators.
The 12V DC power supplies fall into following categories: 12V regulated power
supplies, 12V unregulated power supplies. The 12 Volt batteries plays a key role for the
functioning of nearly all electrical components within an EV, and is especially needed to
ensure the availability of critical safety systems. In addition, the 12V regulated power
supply has three subgroups: Switching regulator AC to DC, Linear regulator AC to DC,
switching regulator DC to DC.12V power supplies (or 12VDC power supplies) are one of
the most common power supplies in use today. In general, a 12VDC output is obtained
from a 120VAC or 240VAC input using a combination of transformers, diodes and
transistors. At 12.0 volts your battery is considered to be fully discharged or 'flat' and
should be recharged as soon as possible. The lifespan of your battery will be severely
affected if it remains within this voltage range for extended periods of time.

Fig 2.10: 12V DC Supply


 SOFTWARE

ARDUINO UNO

The Arduino Uno is an open-source microcontroller board based on the Microchip


ATmega328P microcontroller and developed by Arduino.cc and in itially released in 2010.
The board is equipped with sets of digital and analog input/output (I/O) pins that may be
interfaced to various expansion boards (shields) and other circuits. The board has 14 digital
I/O pins (six capable of PWM output), 6 analog I/O pins, and is programmable with the
Arduino IDE (Integrated Development Environment), via a type B USB cable. It can be
powered by a USB cable or a barrel connector that accepts voltages between 7 and 20
volts, such as a rectangular 9-volt battery.
It is similar to the Arduino Nano and Leonardo. The hardware reference design is
distributed under a Creative Commons Attribution Share-Alike 2.5 license and is
available on the Arduino website. Layout and production files for some versions of the
hardware are also available. The word "Uno" means "one" in Italian and was chosen to mark a
major redesign of the Arduino hardware and software. The Uno board was the successor of the
Duemilanove release and was the 9th version in a series of USB-based Arduino boards. Version
1.0 of the Arduino IDE for the Arduino Uno board has now evolved to newer releases.
The Arduino Uno is one kind of microcontroller board based on ATmega328, and Uno is
an Italian term which means one. Arduino Uno is named for marking the upcoming
release of microcontroller board namely Arduino Uno Board 1.0.
This board includes digital I/O pins-14, a power jack, analog i/ps-6, ceramic resonator-
A16 MHz, a USB connection, an RST button, and an ICSP header. All these can
support the microcontroller for further operation by connecting this board to the
computer. The power supply of this board can be done with the help of an AC to DC
adapter, a USB cable, otherwise a battery. This article discusses what is an Arduino Uno
microcontroller, pin configuration, Arduino Uno specifications or features, and
applications. The ATmega328 on the board comes preprogrammed with a boot loader that
allows uploading new code to it without the use of an external hardware programmer. While the
Uno communicates using the original STK500 protocol, it differs from all preceding boards in
that it does not use a FTDI USB-to-UART serial chip. Instead, it uses the Atmega16U2
(Atmega8U2 up to version R2) programmed as a USB-to-serial converter. The Arduino project
started at the Interaction Design Institute Ivrea (IDII) in Ivrea, Italy. At that time, the
students used a BASIC Stamp microcontroller, at a cost that was a considerable expense
for many students. In 2003, Hernando Barragán created the development platform wiring
as a Master's thesis project at IDII, under the supervision of Massimo Banzi and Casey
Reas, who are known for work on the Processing language.
The project goal was to create simple, low-cost tools for creating digital projects by non-
engineers. The Wiring platform consisted of a printed circuit board (PCB) with an
ATmega168 microcontroller, an IDE based on Processing, and library functions to easily
program the microcontroller. In 2003, Massimo Banzi, with David Mellis, another IDII
student, and David Cuartielles, added support for the cheaper ATmega8 microcontroller
to Wiring. But instead of continuing the work on Wiring, they forked the project and
renamed it Arduino. Early arduino boards used the FTDI USB-to-UART serial chip and
an ATmega168.[10] The Uno differed from all preceding boards by featuring the
ATmega328P microcontroller and an ATmega16U2 (Atmega8U2 up to version R2)
programmed as a USB-to-serial converter.

Technical specifications

 Microcontroller
 Digital I/O Pins: 14
 PWM Pins: 6 (Pin # 3, 5, 6, 9, 10 and 11)
 Analog Input Pins: 6
 DC Current per I/O Pin: 20 mA
 DC Current for 3.3V Pin: 50 mA
 Size: 68.6 mm x 53.4 mm
 Weight: 25 g
 ICSP Header: Yes
 Power Sources:

 USB connector. USB bus specification has a voltage range of 4.75 to 5.25 volts. The
official Uno boards have a USB-B connector, but 3rd party boards may have a mini
USB / micro USB / USB-C connector.
 5.5mm/2.1mm barrel jack connector. Official Uno boards support 6 to 20 volts, though 7
to 12 volts is recommended. The maximum voltage for 3rd party Uno boards varies
between board manufactures because various voltage regulators are used, each having a
different maximum input rating. Power into this connector is routed through a series
diode before connecting to VIN to protect against accidental reverse voltage situations.
 VIN pin on shield header. It has a similar voltage range of the barrel jack. Since this pin
doesn't have reverse voltage protection, power can be injected or pulled from this pin.
When supplying power into VIN pin, an external series diode is required in case barrel
jack is used. When board is powered by barrel jack, power can be pulled out of this pin.
General pin functions

 LED: There is a built-in LED driven by digital pin 13. When the pin is high value, the
LED is on, when the pin is low, it is off.
 VIN: The input voltage to the Arduino/Genuino board when it is using an external power
source (as opposed to 5 volts from the USB connection or other regulated power source).
You can supply voltage through this pin, or, if supplying voltage via the power jack,
access it through this pin.
 5V: This pin outputs a regulated 5V from the regulator on the board. The board can be
supplied with power either from the DC power jack (7 - 20V), the USB connector (5V),
or the VIN pin of the board (7-20V). Supplying voltage via the 5V or 3.3V pins bypasses
the regulator, and can damage the board.
 3V3: A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50
mA.
 GND: Ground pins.
 IOREF: This pin on the Arduino board provides the voltage reference with which the
microcontroller operates. A properly configured shield can read the IOREF pin voltage
and select the appropriate power source, or enable voltage translators on the outputs to
work with the 5V or 3.3V.
 Reset: Typically used to add a reset button to shields that block the one on the board.
Special pin functions
 Serial / UART: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL
serial data.
 External interrupts: pins 2 and 3. These pins can be configured to trigger an interrupt
on a low value, a rising or falling edge, or a change in value.
 PWM (pulse-width modulation): pins 3, 5, 6, 9, 10, and 11. Can provide 8-bit PWM
output with the analogWrite () function.
 SPI (Serial Peripheral Interface): pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK).
These pins support SPI communication using the SPI library.
 TWI (two-wire interface) / I²C: pin SDA (A4) and pin SCL (A5). Support TWI
communication using the Wire library.
 AREF (analog reference): Reference voltage for the analog inputs.
CHAPTER 3
TESTING AND IMPLEMENTATION

3.1 Working

In this ESP32 CAM project, we have explained how to make Wi-Fi door lock with
photo capture using ESP32 CAM and Telegram app. With this IOT project you can take
multiple photos, unlock and lock the door from anywhere in the world with the Telegram
app. This part covered the essential settings including the ESP32 Camera board manager
installation. The system is powered by ESP 32 CAM circuit. The Circuit Diagram for IOT
operated door lock using ESP32 CAM and is combined with an USB to TTL for operating
the Solenoid Lock we can use TIP NPN 122 transistors. The USB to TTL board is
employed to flash the code into ESP32 CAM because ESP 32 cam does not have the self-
programming IC, for that we can use USB to TTL convertor. When anyone presses the
doorbell, you will get a notification in the telegram app with a photo of that person. After
that, you can easily unlock and lock the door from the telegram app. When someone press
the doorbell we get notification on our telegram app, and also get the photo of the person
entered at the door.
After getting the notification with the telegram app we can take the multiple photos by just
click on /photo. We can lock and unlock the door with telegram app by click on the /lock
and /unlock. Here Arduino IDE is employed to program ESP32 CAM. The entire code is
split into four parts. One is that the main code for the camera and relay module where the
ESP32 locks or unlocks the door consistent with face recognition, and therefore the other
three codes are for website, camera index, and camera pins. After completing the code,
insert the network credentials, SSID, password.
After configure the SSID and password we can open the telegram app because in the
programming section we can configure the telegram bot token that have generated by the
telegram app and the BOT ID. BOT ID also generated by the telegram app. After
generating the BOT ID and token open the telegram app and click on the link generated by
the BOT Token after that you can see your new channel ID.
In the channel id we can tap on the /start button then we will get a interface:
“Welcome to the ESP32CAM Telegram Smart Lock.
/Photo: Takes a new photo;
/Unlock: Unlock the door
/Lock: Lock the door
To get the photo please tap on /photo
3.2 Circuit of ESP32 CAM Wi-Fi Door Lock

This circuit is very simple. Here we use ESP 32 CAM board with these
components such as, 12-volt DC, electronic lock, NPN Transistor, Regulator IC, capacitor,
registers, push buttons. The input voltage is 12V DC. We have used 7805 5V regulator to
feed 5V to ESP32 camera module. We have used a TIP122 NPN transistor to control the
12V electronic lock from the GPIO12 pin and the push button is connected with
the GPIO13 of ESP32 CAM. As we have used the INPUT_PULLUP function in code, so
we have not used any pulled-up resistor. The circuit diagram of ESP 32 CAM Wi-Fi door
lock is given below:

Fig 3.1: Circuit diagram of ESP32 CAM


3.3 Configure the Telegram App for Wi-Fi Lock

First, you have to configure the Telegram App for this ESP32 CAM project. Please follow
the steps to create a new BOT in the Telegram app for this project.

Following are the steps of the project with telegram app:

 Download and Install the Telegram App


First, download and install the Telegram app from Google Play Store or App Store. Then
create an account.

 Create a New BOT in Telegram App


1) Search for BotFather in Telegram.
2) Tap on START.
3) Type /newbot and press enter.
4) Now, give a name for the BOT. The Name should be unique.
5) Then, enter a unique username. It should end with BOT.
6) Now, note the bot token marked in the red box. It will be required inthe code.

 Get the User Id in Telegram App


1) Search for IDBot in Telegram
2) Tap on START.
3) Tap on the /getid in IDBot.
4) You will get the UserID.
5) NotetheUserID. It will be required in the code.

Thus, you can create the Bot for this ESP32 project.
3.4 Program ESP32 CAM with USB to TTL Convertor

To program ESP32CAM using Arduino UNO. We will use USB to TTL converter to
program the esp32 camera module.We can easily connect the ESP32CAM module with
USB to TTL convertor to upload code from Arduino IDE.The Circuit Diagram for IOT
operated door lock using ESP32CAM and is combined with an USB to TTL for operating
the Solenoid Lock we can use TIP NPN 122 transistors. The USB to TTL board is
employed to flash the code into ESP32CAM because ESP32 CAM does not have the self-
programming IC, for that we can use USB to TTL convertor. When anyone presses the
doorbell, you will get a notification in the telegram app with a photo of that person. After
that, you can easily unlock and lock the door from the telegram app. When someone press
the doorbell we get notification on our telegram app, and also get the photo of the person
entered at the door. After getting the notification with the telegram app we can take the
multiple photos by just click on /photo.

Fig 3.2: ESP32 CAM programming with USB to TTL convertor


3.5 Arduino IDE setup for ESP32 CAM

The simplest way to start programming this little board is to use the Arduino ESP32 tool
chain in the Arduino IDE (Integrated Development Environment), an application
developed by Espressif that’s used to write and upload code (programs) to Arduino-
compatible boards. With Arduino, your program is called a “sketch”, and when you
compile it, it’s “magically” debugged, translated into proper C++, and sent to your board in
binary form (machine language).

 Here Arduino IDE is used to program ESP32CAM. For that, first, install the ESP32 add-on
on Arduino IDE.
 To install the ESP32 board in your Arduino IDE, go to File>Preference
 Now copy the below link and paste it into the “Additional Board Manager URLs” field.
Then click the “ok” button.
 Now go to select the tools for the ESP 32 CAM board.
 In Arduino IDE go to the tools option and select wifi101 firmware updater.
 Now select the port for the board.
Before uploading the code to ESP32CAM module, please check the following setting:

 Update the Preferences –> Additional boards Manager URLs:


 https://dl.espressif.com/dl/package_esp32_index.json,
 http://arduino.esp8266.com/stable/package_esp8266com_index.json

Board Settings:

 Board: “ESP32 Wrover Module”


 Flash Mode: “QIO”
 Partition Scheme: “Hue APP (3MB No OTA/1MB SPIFFS)”
 Flash Frequency: “40MHz”
 Upload Speed: “115200”
 Core Debug Level: “None”
 Programmer: “AVR ISP”
 COM Port: Depends On Your System
 GPIO 0 must be connected to GND pin while uploading the sketch
 After connecting GPIO 0 to GND pin, press ESP32 CAM on-board RESET button to put
the board in the flashing mode
 After uploading the code disconnect the GPIO-0 pin from GND pin.

Now to get the IP address of ESP32 camera module:


 Open Serial Monitor
 Set the Baud rate to 115200
 Press the ESP32 CAM on-board RESET button
3.6 Program ESP32 CAM with Arduino IDE

During uploading the code, the GPIO-0 and GND pin of ESP32 CAM should be
connected. Here, we have used USB to TTL convertor to program the ESP32 camera
module. During uploading the code, the GPIO-0 and GND pin of ESP32CAM should be
connected. For this ESP32 CAM project, we have used the Universal Telegram Bot library.
So first we have to download and install it.
Following are the steps to program ESP32 CAM with Arduino IDE:

STEP 1: Connect your ESP32 board to your computer through the micro-USB cable.
Make sure the red LED goes high on the module to ensure power supply.

STEP 2: Start the Arduino IDE and navigate to Tools -> Boards and select
ESP32Dev board as shown below:
STEP 3: Open device manager and check to which com port your ESP32 is connected to.
Mine is connected to COM 8 as shown below:
STEP 4: Go back to Arduino IDE and under Tools -> Port select the Port to which your
ESP is connected to. Once selected you should see something like this on the bottom left
corner of the IDE.
STEP 5: Let’s upload the Blink Program, to check if we are able to program our ESP32
module. This program should blink the LED at an interval of 1 second.

int LED_BUILTIN = 2;

void setup() {

pinMode (LED_BUILTIN, OUTPUT);

void loop() {

digitalWrite(LED_BUILTIN, HIGH);

delay(1000);

digitalWrite(LED_BUILTIN, LOW);

delay(1000);

}
STEP 6: To upload the code, just click on upload and you should see the Arduino console
displaying the following if everything works as expected.
Note: For some modules, you might have to hold the Boot button during uploading to
avoid error.

That is it we have successfully uploaded out first code to our ESP32 board. My module
with its LED blinking is shown below:

This is how Programming ESP32 using Arduino IDE can be implemented. You can go
ahead and try the other example programs which are available at File -> Example ->
ESP32 to work with other functionalities of the ESP32. If you have had any problem in
getting this work, feel free to post the query on the comment sections below. You can also
use the Forum for getting technical help.
3.7 Code for this ESP32 CAM project

Here is the code for IoT operated door lock using ESP-32 CAM. The complete code is
divided into several parts including one is main code for camera, ESP 32 lock/ unlock, wifi
ssid, password, and camera pins, camera index. The complete code is given below:

TITLE: ESP32CAM Telegram WiFi Door Lock with photo capture


*********************************************************************
*************/

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

// Replace with your network credentials


constchar*ssid="Nannujii";//WiFi Name
constchar* password ="23456789";//WiFi Password

// Use @myidbot to find out the chat ID of an individual or a group


// You need to click "start" on a bot before it can message you
// Initialize Telegram BOT
String chatId="6030229685";
String
BOTtoken="XXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXX";

bool sendPhoto= false;

WiFiClientSecureclientTCP;

UniversalTelegramBotbot(BOTtoken,clientTCP);
// Define GPIOs
#define BUTTON 13
#define LOCK 12
#define FLASH_LED 4

//CAMERA_MODEL_AI_THINKER
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27

#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22

intlockState=0;
String r_msg="";

constunsignedlong BOT_MTBS =1000;// mean time between scan messages


unsignedlongbot_lasttime;// last time messages' scan has been done

voidhandleNewMessages(intnumNewMessages);
String sendPhotoTelegram();

String unlockDoor(){
if(lockState==0){
digitalWrite(LOCK, HIGH);
lockState=1;
delay(100);
return"Door Unlocked. /lock";
}
else{
return"Door Already Unlocked. /lock";
}
}
String lockDoor(){
if(lockState==1){
digitalWrite(LOCK, LOW);
lockState=0;
delay(100);
return"Door Locked. /unlock";
}
else{
return"Door Already Locked. /unlock";
}
}

String sendPhotoTelegram(){
constchar*myDomain="api.telegram.org";
String getAll="";
String getBody="";

camera_fb_t* fb =NULL;
fb =esp_camera_fb_get();
if(!fb){
Serial.println("Camera capture failed");
delay(1000);
ESP.restart();
return"Camera capture failed";
}

Serial.println("Connect to "+String(myDomain));

if(clientTCP.connect(myDomain,443)){
Serial.println("Connection successful");

Serial.println("Connected to "+String(myDomain));

String head ="--IotCircuitHub\r\nContent-Disposition: form-data;


name=\"chat_id\"; \r\n\r\n"+chatId+"\r\n--IotCircuitHub\r\nContent-Disposition:
form-data; name=\"photo\"; filename=\"esp32-cam.jpg\"\r\nContent-Type:
image/jpeg\r\n\r\n";
String tail ="\r\n--IotCircuitHub--\r\n";

uint16_t imageLen= fb->len;


uint16_t extraLen=head.length()+tail.length();
uint16_t totalLen=imageLen+extraLen;
clientTCP.println("POST /bot"+BOTtoken+"/sendPhoto HTTP/1.1");
clientTCP.println("Host: "+String(myDomain));
clientTCP.println("Content-Length: "+String(totalLen));
clientTCP.println("Content-Type: multipart/form-data; boundary=IotCircuitHub");
clientTCP.println();
clientTCP.print(head);

uint8_t *fbBuf= fb->buf;


size_tfbLen= fb->len;
for(size_t n=0;n<fbLen;n=n+1024){
if(n+1024<fbLen){
clientTCP.write(fbBuf,1024);
fbBuf+=1024;
}
elseif(fbLen%1024>0){
size_t remainder = fbLen%1024;
clientTCP.write(fbBuf, remainder);
}
}

clientTCP.print(tail);

esp_camera_fb_return(fb);

intwaitTime=10000;// timeout 10 seconds


longstartTimer=millis();
boolean state = false;

while((startTimer+waitTime)>millis()){
Serial.print(".");
delay(100);
while(clientTCP.available()){
char c =clientTCP.read();
if(c =='\n'){
if(getAll.length()==0) state=true;
getAll="";
}
elseif(c !='\r'){
getAll+=String(c);
}
if(state==true){
getBody+=String(c);
}
startTimer=millis();
}
if(getBody.length()>0)break;
}
clientTCP.stop();
Serial.println(getBody);
}
else{
getBody="Connected to api.telegram.org failed.";
Serial.println("Connected to api.telegram.org failed.");
}
returngetBody;
}

voidhandleNewMessages(intnumNewMessages){
Serial.print("Handle New Messages: ");
Serial.println(numNewMessages);

for(inti=0;i<numNewMessages;i++){
// Chat id of the requester
String chat_id=String(bot.messages[i].chat_id);
if(chat_id!=chatId){
bot.sendMessage(chat_id,"Unauthorized user","");
continue;
}

// Print the received message


String text =bot.messages[i].text;
Serial.println(text);

String fromName=bot.messages[i].from_name;
if(text =="/photo"){
sendPhoto= true;
Serial.println("New photo request");
}
if(text =="/lock"){
String r_msg=lockDoor();
bot.sendMessage(chatId,r_msg,"");
}
if(text =="/unlock"){
String r_msg=unlockDoor();
bot.sendMessage(chatId,r_msg,"");
}
if(text =="/start"){
String welcome ="Welcome to the ESP32-CAM Telegram Smart Lock.\n";
welcome +="/photo : Takes a new photo\n";
welcome +="/unlock : Unlock the Door\n\n";
welcome +="/lock : Lock the Door\n";
welcome +="To get the photo please tap on /photo.\n";
bot.sendMessage(chatId, welcome,"Markdown");
}
}
}

voidsetup(){
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG,0);
Serial.begin(115200);
delay(1000);

pinMode(LOCK,OUTPUT);
pinMode(FLASH_LED,OUTPUT);
pinMode(BUTTON,INPUT_PULLUP);

digitalWrite(LOCK, LOW);

WiFi.mode(WIFI_STA);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
clientTCP.setCACert(TELEGRAM_CERTIFICATE_ROOT);
while(WiFi.status()!= WL_CONNECTED){
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("ESP32-CAM IP Address: ");
Serial.println(WiFi.localIP());

camera_config_t config;
config.ledc_channel= LEDC_CHANNEL_0;
config.ledc_timer= LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk= XCLK_GPIO_NUM;
config.pin_pclk= PCLK_GPIO_NUM;
config.pin_vsync= VSYNC_GPIO_NUM;
config.pin_href= HREF_GPIO_NUM;
config.pin_sscb_sda= SIOD_GPIO_NUM;
config.pin_sscb_scl= SIOC_GPIO_NUM;
config.pin_pwdn= PWDN_GPIO_NUM;
config.pin_reset= RESET_GPIO_NUM;
config.xclk_freq_hz=20000000;
config.pixel_format= PIXFORMAT_JPEG;

//init with high specs to pre-allocate larger buffers


if(psramFound()){
config.frame_size= FRAMESIZE_UXGA;
config.jpeg_quality=10;//0-63 lower number means higher quality
config.fb_count=2;
}else{
config.frame_size= FRAMESIZE_SVGA;
config.jpeg_quality=12;//0-63 lower number means higher quality
config.fb_count=1;
}

// camera init
esp_err_terr=esp_camera_init(&config);
if(err != ESP_OK){
Serial.printf("Camera init failed with error 0x%x", err);
delay(1000);
ESP.restart();
}

// Drop down frame size for higher initial frame rate


sensor_t* s =esp_camera_sensor_get();
s->set_framesize(s, FRAMESIZE_CIF);// UXGA|SXGA|XGA|SVGA|VGA|CIF|
QVGA|HQVGA|QQVGA
}

voidloop(){

if(sendPhoto){
Serial.println("Preparing photo");
digitalWrite(FLASH_LED, HIGH);
delay(200);
sendPhotoTelegram();
digitalWrite(FLASH_LED, LOW);
sendPhoto= false;
}

if(digitalRead(BUTTON)== LOW){
Serial.println("Preparing photo");
digitalWrite(FLASH_LED, HIGH);
delay(200);
sendPhotoTelegram();
digitalWrite(FLASH_LED, LOW);
sendPhoto= false;
}

if(millis()-bot_lasttime> BOT_MTBS)
{
intnumNewMessages=bot.getUpdates(bot.last_message_received+1);

while(numNewMessages)
{
Serial.println("got response");
handleNewMessages(numNewMessages);
numNewMessages=bot.getUpdates(bot.last_message_received+1);
}
bot_lasttime=millis();
}
}
Before uploading the code, you have to enter the following details.

// Replace with your network credentials


const char* ssid = "WiFi Name";
const char* password = "WiFi Password";
Enter the WiFi name and password.

// Initialize Telegram BOT


String chatId = "XXXXXXXXXX"; //User ID
String BOT token =
"XXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

Enter the User Id and Bot token you have received from the IDBot and BotFather in
Telegram App.

If you refer to the same circuit, then after doing this changes, you can directly upload
the code to ESP32-CAM.
During uploading the code, if you see the “Connecting…..______” text, then press the
RESET button. Then the code will start uploading.

After uploading the code, disconnect the GPIO-0 from GND pin.

Then open the serial monitor and set the Baud Rate at 115220. Now, press the reset
button of ESP32CAM. If the WiFi is connected successfully then it will print the local
IP address.
CHAPTER 4

RESULT ANALYSIS

The picture below is to representthe results of this work. During this model, once
somebody presses the doorbell, the house owner can get a notification on the mobile with a
photograph of the visitor. When checking the photo, owner will unlock or lock the door
from a mobile phone and can see the picture of the person in his telegram app. The final
result of this project is shown in the following figure:

Fig4.1: IOT operated door lock with ESP32 CAM module


There are the steps to complete this project, as given below:

The figure below shows the testing ESP32 CAM wifi lock and how ESP32 CAM is
capturing the picture:

Fig4.2: Testing the ESP32 CAM WiFi Lock


Now, press the pushbutton, the ESP32 CAM will capture the photo and send it to
telegram app. We can click multiple photos by just click on the click option. And also save
the picture from the telegram app and from anywhere.

The figure below shows how the ESP32 CAM is capturing multiple pictures:

Fig4.3: ESP32 CAM is capturing multiple pictures


If you tap on the /photo, then ESP32 CAM will again take the photo and send it to
telegram app.After that tap on the /unlock to unlock the door then tap on /lock to lock the
door again.

This is a very useful IOT project for home security systems. As you can control the door
lock and capture the photo from anywhere in the world through the internet.

The figure below shows that how the ESP32 CAM is sending photo to the telegram
application:

Fig4.4: ESP32 CAM is sending photos to telegram app and lock/unlock the door
CHAPTER 5

APPLICATIONS

IOT based door locks are the door locks that connect to your home's Wi-Fi
network to allow you to lock and unlock the doors through a unique access code or your
smart phone. With a smart lock, you can remotely control your home entrances from near
or far. It is used for security purpose, and it is very useful to provide high security in homes
and other residents. Following are some applications of this door lock system-

5.1 QR Code Scanner with ESP32 CAM Module

This project is about QR Code Scanner or Reader designed using ESP32 CAM
Module. We will develop a program and device using ESP32 Camera module and python
libraries with which we can scan QR codes. Earlier we used QR Code Scanning
Module with Arduino to read QR or barcode but the module is very expensive. Using
ESP32 CAM the project becomes little cheaper. QR Codes have now become a part of our
everyday lives as we use them almost everywhere say it for payments or reaching a website
or a link. Also, people add them to their resumes to share the link to their social profiles.
The ESP32 from sprees if Systems is a powerful dual-core microcontroller with
built-in wireless that makes it a perfect fit for many creative Internet of Things projects.
The ESP32 CAM development board takes it one step further by combining that speedy
microcontroller with a camera module! One project that takes advantage of this powerful
combination is Alvaro Vibrato’s library for reading QR codes. The library is self-contained
and runs entirely on the ESP32 CAM, making it a good choice for IoT projects and robots.
Let's take this library for a test drive and see what we can do with it! For this project, you
will need a way to program the ESP32 CAM board from your computer and to power it
once it has been programmed. You should buy either an ESP32 CAM with an ESP32 CAM
MB daughterboard or a newer ESP32 CAM-CH340. Either one will give you the USB port
needed for programming and power. Not just personally but large tracking and shipping
companies use them to differentiate their products.
5.2 MOTION DETECTION SQUID GAME USING ESP32 CAM

In this project, we will develop a Motion Detection project based on Squid


Game using ESP32 CAM. Motion Detector is a feature of a video camera or a video
surveillance system that generates an alarm signal when motion is detected in the
camera's field of view.With the help of the Python program and ESP32 Camera Module,
we will develop a Red Light – Green Light Game. This game is inspired from a famous
Netflix TV Series “Squid Game”. Here, we will capture the frames of the person
moving using ESP32-Cam. If there is any motion detected in the live video stream when
the red light is turned on then the person is dead or game over else greenlight is shown
in which the person needs to move.

Red Light = No motion & Green Light = Motion

To get started one must have sound knowledge of Python, Image processing,
Embedded Systems, and IOT. In this project, we will understand how to detect the
motion of a person, and what all requirements are needed to run the python program.
First, we will test the whole python script with a webcam or internal camera of a laptop.
Later motion detection program is implemented with the ESP32 CAM. In this project,
we’re going to make a motion sensor detector with photo capture using an ESP32 CAM.
When your PIR sensor detects motion, it wakes up, takes a photo and saves it in the
microSD card. The ESP32 CAM is in deep sleep mode with external wake up
enabled. When motion is detected, the PIR motion sensor sends a signal to wake up the
ESP32. The ESP32 CAM takes a photo and saves it on the microSD card. It goes back
to deep sleep mode until a new signal from the PIR motion sensor is received.

This project is very similar with a previous one, but after so many requests, we
added a PIR motion sensor to the circuit. So, when motion is detected, a picture is taken
and saved on the microSD card. An active ultrasonic motion detector emits ultrasonic
sound waves that reflect off objects and bounce back to the original emission point.
When a moving object disrupts the waves, the sensor triggers and completes the desired
action, whether this is switching on a light or sounding an alarm.
5.3 Gesture Controlled Virtual Mouse with ESP32 CAM

In this project we will develop a virtual Mouse with ESP32CAM. The ESP32
Camera Module along with a Python program can be used to control the mouse
tracking and clicking operations wirelessly. To get started one must have sound
knowledge of Python, Image processing, Embedded Systems as well as the Internet of
Things. First, we will understand how to control the mouse tracking and clicking, and
what all requirements are needed to run the python program. We will first test the
whole python script with a webcam or internal camera of a laptop.

In the second part, we will use an ESP32CAM Module and run the Python code.
So, the ESP32CAM will be used as an input device instead of a PC camera or any other
external camera. Earlier we learned about Gesture Recognition & its application in
Machine-Learning. And we also developed Gesture Controlled Robot using
Accelerometer. Gesture Controlled Virtual Mouse makes human computer interaction
simple by making use of Hand Gestures and Voice Commands. The computer requires
almost no direct contact. All i/o operations can be virtually controlled by using static
and dynamic hand gestures along with a voice assistant. This AI based project controls
the mouse movement using Python, Open CV with a real-time camera that detects hand
landmarks, tracks gesture patterns instead of a physical mouse.

The gesture is controlled by an accelerometer and a microprocessor in this


robotic arm. In the field, where there are higher radiation concerns, this arm will assist
in activities such as gripping things and wirelessly remote-controlled working of
gadgets. Its having future scope of advanced robotic arms that are designed like the
human hand itself can easily controlled using hand gesture only. It also is having
proposed utility in field of construction, medical science, hazardous waste disposal etc.
Gesture-based UI refers to using specific physical gestures in order to operate an
interface. Take your smart phone for instance. You can already interact with your phone
without using the keypad by swiping, tapping, pinching, and scrolling.
5.4 DIY AI Camera with Google Vision & ESP32 CAM Module

In this project we will develop an AI Camera using Google Vision


API & ESP32CAMModule. This is basically detailed testing of Google Vision API with
ESP32 Camera for the applications of Artificial Intelligence and Machine Learning. The
developed AI camera can detect objects in the frame captured and displays the frame as
well as detected labels on the TFT LCD Screen. The Google Vision API allows
developers to easily integrate vision detection features within applications, including
image labeling, face, and landmark detection, optical character recognition (OCR), and
tagging of explicit content. We will be implementing the same Google Vision
functionalities with the ESP32 Camera Module. We selected ESP32 CAM module
because it is an ideal solution for image processing IOT applications.

ESP32CAM is a low power consuming and low latency video streaming


module, it also provides GPIOs and serial communication, but it seems not strong
enough to run some heavy computer vision tasks in real time. In the other hand, the
smart phone hardware development has a rocket improvement recently, it lets the smart
phone is cheaper but has more power in computing.

Therefore, I thought about the combination of a smart phone and ESP32CAM


module and made a simple robot which controlled by the ESP module and streaming
video to Android for computer vision processing such as object detection, object
tracking, lane detection, then send control the robot to run autonomously in some
condition such as lane tracking or object tracking. The project requires some time and
patience as a lot of steps are involved in it. We will write the Arduino Code for ESP32
CAM Module and add some libraries like TFT Library, JSON Library & Decoder
Library. The next process involves setting up Google Vision API & NodeJS
installation with some settings required for GCP. All the hardware setup along
with Arduino & NodeJS code is fully explained in this article. Thus, developing a
homemade AI Camera using Google Vision & ESP32 CAM Module would be easy.
5.5 Face Recognition Attendance System using ESP32 CAM

In this project we will learn, how to create a Face Recognition Based Attendance
system using ESP32 CAM and Python. The main heavy program will be at the server-side
that is our computer, or one can even use raspberry-pi as a server. In this attendance
system, we will not just detect the person but also store the information of the person
detected in a Microsoft Excel File. Moreover, the duration of time they have stayed in the
frame is also recorded into an excel sheet. Unlike other forms of biometric technology,
such as fingerprint recognition, which captures identity by touching, a facial identification
system manages employees without the approach of direct contact.

Face recognition records the field employee's attendance marking time and geo
location. Face detection software detects faces by identifying facial features in a photo or
video using machine learning algorithms. It first looks for an eye, and from there it
identifies other facial features. It then compares these features to training data to confirm it
has detected a face.

The tutorial also contains information about features, pins description, and the
method to program ESP32 Camera Module using FTDI Module. We will also set up
the Arduino IDE for the ESP32 Camera Module. We will also upload the firmware and
then work on the Face Recognition part. The script for Face Recognition is written in the
python programming language, thus we will also have to install Python and its
required Libraries. Face detection software detects faces by identifying facial features in a
photo or video using machine learning algorithms. It first looks for an eye, and from there
it identifies other facial features. It then compares these features to training data to confirm
it has detected a face. Earlier we made Fingerprint Attendance System as well as RFID
Attendance System. But this is a different project that doesn’t need any biometric contact
or any use of the card. The ESP32 Camera will capture image & store the information in
Excel file. It automatically scans your face so you don't need to touch anything to mark
your attendance. A face recognition attendance system provides you with real-time data
and syncs the data with no time lag. It helps organizations in efficient workforce
management.
CHAPTER 6

ADVANTAGES AND DISADVANTGES

6.1 ADVANTAGES
The IoT based door locks have many advantages. As it provides very high security and
work wirelessly. Only with the help of internet we can monitor our home and also lock and
unlock the door of the house. Following are some advantages of this system:

6.1.1 EASY WORK WITH SMARTPHONES

As we know that in today’s lifestyle everyone has smart phones. In the smart phone we can
access multiple applications with the help of a particular application (app). In this project
we have used the TELEGRAM app for operating our door lock smartly. When someone
press the door button then we can get the notification on our smart phone in the telegram
app. After getting the notification we can lock and unlock the door lock easily also take
multiple pictures of that person. Thus, it can easily work with smart phones.

6.1.2 DOOR LOCK CAN BE CONTROL FROM ANYWHERE


As we know that the whole world is connected with the internet. With the help of internet
ESP32 CAM connect with the Wi-Fi because ESP32 CAM have inbuilt Wi-Fi and
Bluetooth for that specification we can easily control our door lock from anywhere in the
world with simply our mobile phones. With this we can control the door from anywhere in
the world. We can lock and unlock the door wirelessly. Also get the information about the
person entered inside.

6.1.3 NO NEED TO TAKE KEYS INSIDE YOUR POCKET

This is the main advantage of this project that we do not need to take keys inside our
pocket, because the solenoid lock connected with ESP 32 CAM board, and the circuit is
connected with Wi-Fi to control the lock with the telegram app. We can control the lock by
telegram app and no need to carry the keys with us.
6.1.4 COST EFFICIENT

It is cost efficient compare to the other smart locks because we can make it by self. In the
market the door locks have their self-customized apps, but in this project, we used telegram
app to control the door lock. So, this system is very cost efficient.

6.1.5 THE AUTOMATIC OPENING AND LOCKING SYSTEM, ACTIVATED


THROUGH SMART PHONES

The automatic opening and locking system, activated through smart phones and biometric
readers, eliminates this dilemma. This system is especially convenient for those families
where parents very often have to rush to the rescue of their children, who have forgotten
the keys and cannot enter into the house.

6.1.6 IMPLIMENTATION OF SECURITY STANDARDS

Another disputable advantage of this system is the implementation of security standards. A


part from possible malfunctions, which will be analyzed later on, we can say that without a
mechanical system such as the key, the home is definitely safer

6.1.7 ALLOW EXCLUSIVE ACCESS ONLY TO AUTHORIZED PEOPLE

This system provides the access only to authorized people. The authorized person can
lock or unlock the door and can check the person who entered in the home. And can
also get multiple pictures of the person. And everything is handled via smart phones.

6.1.8 FULL ACCESS CONTROL

With the installing of a smart lock system, you will have full access control. In fact, the
door lock is an electronic device that allows you to record at any time, who goes in and
out, with dates and time. This is possible because the recognition device used for
authentication is active.

6.1.9 ACCESS CONTROL TO A SPECIFIC AREA

The smart door lock memory is an ideal tool especially for work environments, as it
allows having a total access control to a specific area. The system is particularly useful
for domestic contexts as well, especially when you want to control your children and
keep an eye on their movements.
6.2 DISADVANTAGES

A part from all the advantages mentioned above, the Wi-Fi based smart door locks also has
some disadvantages. Following are some disadvantages of this system:

6.2.1 BLACKOUT OF THE CONTROL UNIT OR A FAULT OF RECOGNITION


DEVICE

Another matter related to these smart locks regards a sudden blackout of the control unit or
a fault of the recognition device. In both cases, the risk is that you cannot enter into your
house because the system is unable to authenticate you for accessing the premises.

6.2.2 OPERATING WITH SMART PHONES

The most striking problem for those models operating with smart phones, is linked to the
possibility of not being able to open the door when the battery of your smart phone on
down. How often the battery of your smart phone is down at the end of the day?
Unfortunately, the autonomy of these devices is limited and whenever you cannot recharge
your smart phone, the risk of being unable to open the door is possible.

6.2.3 IT CAN USE MORE POWER

It can use more power,usually when starting up a Wi-Fi connection. The Wi-Fi can be
turned off, though and overall consumption is low.It will be difficult to enter the house if
the smart lock is connected to the electricity of the house if there is a blackout.

6.2.4 INTERNET CONNECTION

When the internet connection is power off then the ESP32 module cannot work with the
telegram App because of that interconnection cannot operated the solenoid lock. So, it is
necessary to have a proper internet connection to access this system.
CHAPTER 7

FUTURE ENHANCEMENT

In the future, this system can be switched to dual verification mechanisms, such as
retina scanner, fingerprint scanner, OTP, PIN code, etc. This system will first recognize the
face. If a face is found in the database, will require the second verification mechanism to
be any of the above one. If the person passes the verification test, only the door will open.
If face is not found in the database, the image will be sent to the website. The system will
provide excellent security. The face recognition mechanism can be used in combination
with any other mechanism. New emergency call feature to directly call the police.

New feature for two-way communication between the owner of the door and the
guess. The android application should be able to manage more doors, windows, and basic
home electronic equipment in the future. To assure the system's completeness, a battery
backup system should be considered. By using AI we can control door locks using face
detection and for registered faces. In the future, this system can be switched to dual
verification mechanisms, such as retina scanner, fingerprint scanner, OTP, PIN code, etc.
The system will provide excellent security.
CHAPTER 8

CONCLUSION AND REFERENCE

8.1 CONCLUSION
We successfully designed an IoT-based Wi-Fi door lock security system using the
ESP32Cam to monitor the status of the door and boost the home security. The major goal
of this project is to develop a system that provides a robust security system to the user that
the user can trust easily. This system is inexpensive and simple to set up. It is a durable and
multiple mode device that can be operated by a single tap on the app. It has many features
like notification alert, multiuser function, activity monitor, only admin access, etc. It is
designed keeping in mind the safety of the user. The communication protocol telegram is
used between the smart phone and the door lock system. In this circumstance, due to the
current COVID scenario, the smart locking door system is quite important and applying
this Wi-Fi-based door lock system without using our hands is essential.

Also, our proposed model in this paper can be extended by integrating


temperature sensors, which can be used to trigger the system to automatically open and
close the doors as per the variations of the room temperature. The setup and configuration
of Arduino UNO and other relevant modules, as proposed for the automatic detection,
controlling and monitoring of temperature forms the base for the idea of this extended
model. Also, the android application should be able to manage more doors, windows, and
basic home electronic equipment in the future. To assure the system's completeness, a
battery backup system should be considered.
8.2 REFERENCES

[1] Norarzemi, UmmiAnnisa, et al. "Development of Prototype Smart Door System with IoT
Application." Progress in Engineering Application and Technology 1.1 (2020): 245-256.

[2] Aldawira, Cornelio Revelivan, et al. "Door security system for home monitoring based on
ESp32." Procedia Computer Science 157 (2019): 673-682.

[3] Babiuch, Marek, and Jiri Postulka. "Smart Home Monitoring System Using ESP32
Microcontrollers." Internet of Things. IntechOpen, 2020.

[4] Eethamakula, Kosalendra, et al. "Automatic Detection, Controlling and Monitoring of


Temperature in Sericulture Using IOT," IJAEMA 12.8 (2020): 1099- 1103.

[5] Pavelić, Marko, et al. "Internet of things cyber security: Smart door lock system." 2018
international conference on smart systems and technologies (SST). IEEE, 2018.

[6] Guduru, Tabu Sravani, and SURYA NARAYANA MURTHY THATAVARTHY. "IoT
Based Home Monitoring System." (2019).

[7] Nascimento, David Barbosa de Alencar, and Jorge de Almeida Brito Júnior. "Application
of the Internet of Things in the Development of a “Smart” Door."

[8] J Gal Bally, S Marcel, J Ferez. Image quality assessment for face recognition. IEEE
transactions on image processing. 2014; 23: 710-724.

[9] MA Turk, AP Pentland. Facial recognition using eigen-faces in Computer Vision and
Pattern Recognition. CVPR'91. IEEE Computer Society Conference on. 1991; 586-591

[10] GJ Edwards, TF Cootes, CJ Taylor. Facial recognition by use of active appearance


models in European conference on computer vision. 1998; 581-595.

[11] G Guo, SZ Li, K Chan. Face detection by support vector machines in automatic facial
and gesture recognition. Fourth Proceedings of IEEE International C Conference on 2000;
196-201.

[12] B Moghaddam, T Jabara, A Pentland. Bayesian face recognition, Pattern Recognition.


2000; 33: 1771- 1782.

You might also like