IoT based Smart Motion Sensing Camera

We are going to create an Internet of Things (IoT) based Smart Motion Sensing Camera using ESP32-CAM after constructing the Motion Sensing Photo Capturing Device using ESP32-CAM on the most recent project. This project allows us to use the Telegram application to control the ESP32-CAM from anywhere in the world. In addition to turning on and off lights, you can take pictures and check the temperature in real time. The camera will take a picture and send it to your Telegram app if it detects any moves.

One of the greatest things about this project is that you can receive the photographs even if the ESP32-CAM is not connected to the same WiFi network. You will be able to complete this project with ease after reading this article because I have already included the circuit, source code, and other requirements below.

Project

Circuit Schematic

Components

ESP32-CAM Camera Module
FTDI232 TTL Converter
PIR Motion Sensor
DHT11 Temperature & Humidity Sensor
220Ω Resistor (x2)
1KΩ Resistor (x2)
1N4007 PN Diode
BC547 NPN Transistor (x2)
LED (Green, Red)
5V SPDT Relay
2-Pin Terminal (x2)
SPDT Slide Switch
5V Hi-Link AC to DC Converter
Double-Sided PCB Board

Features of Smart Motion Sensing Camera

Let’s talk about a few of this project’s aspects before getting into the specifics. Using a 5-volt Hi-Link AC to DC converter, we have provided the DC circuit in this circuit with an AC supply. You must tap the start button after launching the bot on your Telegram client. The menu that appears is shown below.

/photo

Upon selecting the “/photo” option, the message is received by the ESP32-CAM board via Telegram, at which point it takes a picture and forwards it to the Telegram bot.

/photowithFlash

To utilise the flash capability, press “/photoWithFlash” to activate the ESP32-CAM’s LED flash while taking a picture.

/off and /on lights

Moreover, we may use the “/lightOn & /lightOff” functionality to turn on the ESP32-CAM module’s light.

motionOff and /motionOn

By sending the message “/motionOn or /motionOff,” we may turn the PIR motion sensor on or off. When the motion sensor is active, it will keep delivering pictures to the Telegram bot.

/weather

Additionally, by sending the signal “/weather” over the internet, you may control the PIR motion sensor and keep an eye on the temperature using the DHT11 sensor.

/lightOff &/lightOn

An AC appliance can be turned on or off by transmitting the signal “/lightOn or /lightOff.”

Setup Telegram Bot for Smart Motion Sensing Camera

You need to make a Telegram bot before you can programme. To begin with, download the Telegram app from the Google Playstore and sign in with your ID.

Now go to Telegram, search for “botfather,” and hit restart. You must now touch or write “/newbot” and provide the bot a unique name in order to create a new one.

Following that, it will ask for the username of that bot; hence, you must enter a username that ends in “_bot.”

You will then notice that it has issued you with an HTTP API bot token, which is needed in order to add to the code part.

Simply click “exit” from Botfather now and look for “myidbot.” After selecting “Start or Restart,” press “/getid” to obtain the id needed for coding.

Now you can move to the coding part of the project.

Installing ESP32 Board Manager on Arduino IDE

Select Preferences > Additional boards Manager URLs first.

In the blank field, paste “https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json,” hit OK, and save the file.

The ESP32 board (2.0.5) can then be installed from the board manager area.

Programming ESP32-CAM Module Using FTDI Converter

Using the sliding switch, connect the ESP32-CAM and turn it on in programming mode. The ESP32-CAM module must then be programmed using the FTDI TTL converter, and the laptop must be connected in order to upload the code to the ESP32-CAM WiFi board.

ESP32-CAM Code for Smart Motion Sensing Camera

After programming, take out the FTDI converter and disable programme mode on the switch.

Obtain the necessary libraries and upload the code to the ESP32-CAM first.

UniversalTelegramBot Library
ArduinoJson Library
DHT Library

Attach both the DHT11 and PIR motion sensors to it now. Attach the AC appliance and the AC supply.

You will now see a link for your bot when you navigate to the “botfather” window. Once you tap on it and select “Start,” a menu for managing your devices will appear.

Leave a Comment