Recommended Free Tools
Yes, you can build a compact DIY security-monitoring prototype with an AI Thinker ESP32-CAM, motion and door sensors, and a Telegram bot. It can capture JPEG photographs, send near-real-time notifications, and accept commands such as /photo and alert enable/disable commands.
It is suitable for a construction-site workshop, garage, shed, or electronics project—but it is not a certified burglar, smoke, gas, or fire alarm. Telegram alerts depend on power, Wi-Fi, Internet access, and Telegram availability. Install certified smoke, carbon-monoxide, gas, and fire alarms separately wherever life safety is involved.
As an Amazon Associate I earn from qualifying purchases.
How the ESP32-CAM Telegram security system works
The project places local sensors and a camera on an AI Thinker ESP32-CAM. The board reads sensor inputs, connects to a 2.4 GHz Wi-Fi network, captures a JPEG image when requested or triggered, and uploads the image through Telegram’s Bot API.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesPIR / door / flame / gas sensors
│
▼
AI Thinker ESP32-CAM
│
Wi-Fi router
│
▼
Telegram Bot API
│
▼
Telegram notification
The system does not need a separate web server, but it does require local power, usable Wi-Fi coverage, Internet access, a Telegram account, a bot token, and an authorized chat ID. Remote operation works only while those dependencies are available. The original project is documented at Make2Explore and Hackster.
#1 Best Overall
- ESP32CAM is based on ESP32 chip and OV camera module, use low-power dual-core 32-bit CPU, which can be used as an application processor.
- The main frequency is up to 240MHz, and the computing power is up to 600 DMIPS.
- Built-in 520 KB SRAM , external 8MB PSRAM ,support UART/SPI/I2C/PWM/ADC/DAC and other interfaces;Support picture wireless upload, TF card, multiple sleep modes, STA/AP/STA+AP working mode, secondary development.
- It is an ideal solution for IoT applications. The ESP-32CAM comes in a DIP package that plugs directly into the backplane for rapid production.
- ESP-32CAM can be widely used in various IoT applications. Suitable for home smart devices, industrial wireless control, wireless monitoring, QR wireless identification, wireless positioning system signals, etc.
What it can detect
- Motion: an AM312 PIR module.
- Door opening: magnetic reed switches.
- Flame indication: a low-cost flame sensor module.
- Combustible-gas experimentation: an MQ-6 module.
- Visual confirmation: a still photograph from the OV2640 camera.
Safety warning: An MQ-6 is primarily intended for detecting combustible gases associated with LPG and is not a certified smoke detector, carbon-monoxide detector, or universal gas detector. A flame module is not a listed fire alarm. Do not use either as the only protection in a home or construction area.
Hardware required
| Part | Purpose | Important qualification |
|---|---|---|
| AI Thinker ESP32-CAM | Controller, Wi-Fi, and camera interface | Use the matching AI Thinker pin definition |
| OV2640 camera | JPEG image capture | Check the ribbon cable orientation and seating |
| AM312 PIR | Motion detection | Requires warm-up and false-trigger control |
| Reed switch and magnet | Door or gate monitoring | Needs a defined pull-up or pull-down state |
| MQ-6 module | Educational combustible-gas experiment | Not a life-safety detector |
| Flame sensor module | Experimental flame indication | Not a certified fire alarm |
| USB-to-UART adapter or FTDI programmer | Initial firmware upload | Wire TX and RX correctly; power may need to be separate |
| Stable regulated 5 V supply | Normal operation | Weak supplies commonly cause brownouts |
| Jumper wires, breadboard, resistors, and enclosure | Prototyping and installation | Protect against loose wiring, dust, and condensation |
The original bill of materials also lists two 10 kΩ resistors, a logic-level shifter, an MB102 breadboard supply, jumper wires, and a 7.4 V LiPo or power bank. Select the exact sensor modules and supply after checking their output voltage. ESP32 GPIO inputs are not automatically protected from higher-voltage module outputs.
Original AI Thinker pin map
The following assignments reproduce the original implementation. They are project-specific, not universal recommendations for every ESP32-CAM clone.
#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
#define FLASH_LED_PIN 4
const byte motionSensor = 13;
const byte door1 = 12;
const byte door2 = 2;
const byte firePin = 14;
const byte smokePin = 15;
GPIO 4 is associated with the onboard flash LED and can conflict with microSD use. GPIO 2 and GPIO 12 are boot-strapping-sensitive on classic ESP32 hardware, while GPIO 15 may have boot or peripheral implications depending on the board. Camera pins are unavailable for general sensor use. If a sensor holds a strapping pin at the wrong level during reset, the board may fail to boot.
For a more dependable installation, begin with the camera, PIR, and one reed switch. Add other sensors only after confirming reliable booting and checking the voltage levels and logic polarity of each module. Board documentation and hardware details vary; compare the physical board with the AI Thinker ESP32-CAM board profile.
Wiring and power
Programming connections
FTDI TX → ESP32-CAM U0R / RX
FTDI RX → ESP32-CAM U0T / TX
FTDI GND → ESP32-CAM GND
FTDI 5V → ESP32-CAM 5V
GPIO0 → GND while flashing
Disconnect GPIO0 from ground after uploading, then reset or power-cycle the board. The ESP32-CAM has no onboard USB/debug interface, so an external adapter is required for initial programming. A USB-to-UART adapter is not necessarily a suitable permanent power supply.
Power rules
- Use a stable regulated 5 V source with adequate current capacity.
- Keep power and ground wires short and secure.
- Expect current spikes during Wi-Fi transmission, camera capture, and flash-LED use.
- Do not power several sensor modules from an unsuitable 3.3 V pin.
- Power sensors separately if their load or electrical noise affects the camera board.
- Use bulk capacitance only with correct voltage rating and polarity.
- Do not treat disabling the brownout detector as a genuine repair.
For a construction-site or workshop installation, place the electronics in a ventilated, protected enclosure. Keep the camera lens clear, prevent condensation, and protect the supply from dust, moisture, accidental contact, and cable strain.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- Package included:2pcs ESP32-CAM-MB Camera Module and 2pcs USB-TTL Serial Adapter Module.Compared with the old model, it does not require complex wiring and supports manual and automatic downloads
- HK-ESP32-CAM-MB adopts Micro USB interface, convenient and reliable connection method, convenient to apply to various IoT hardware terminal occasions
- HK-ESP32-CAM-MB module can work independently as the smallest system
- A new W-BT dual-mode development board based on ESP32 design, using PCB on-board antenna, with 2 high-performance 32-bit LX6CPU, using 7-level pipeline architecture, main frequency adjustment range 80MHz to 240Mhz
- Ultra-low power consumption, deep sleep current is as low as 6mA. It is an ultra-small 802.11b/g/n W+ BT/BLE SoC module -->>Our technical service team is always ready to answer your questions. please feel free to contact us--)
Arduino IDE setup
The historical project uses WiFi.h, WiFiClientSecure.h, esp_camera.h, UniversalTelegramBot.h, and ArduinoJson.h. Their roles are Wi-Fi, encrypted network communication, camera control, Telegram messaging, and JSON parsing.
- Install Arduino IDE.
- Install the Espressif ESP32 board package from the Board Manager.
- Select the exact AI Thinker ESP32-CAM board profile.
- Install Universal Arduino Telegram Bot and its ArduinoJson dependency.
- Use the camera and Telegram examples as a baseline. The maintained ESP32-CAM example is available here.
The original code dates from 2021, and the demonstration identifies ESP32 core 2.0.1, Universal Telegram Bot 1.3.0, and ArduinoJson 6.15.2 as a historical test environment. Do not assume those are current or that an untested latest release will behave identically. Record the Arduino IDE, ESP32 core, Telegram library, and ArduinoJson versions that compile and run for your build. Save them in a project README, platformio.ini, or equivalent dependency record.
Create and secure the Telegram bot
- Install Telegram and open BotFather.
- Send
/newbotand follow the naming prompts. - Save the token privately.
- Open a conversation with your new bot and press Start.
- Determine the target chat ID using the bot workflow or the Telegram Bot API documentation.
- Place the token and chat ID in a private configuration file or build setting.
- Configure the firmware to reject messages from every other chat ID.
Never publish real credentials in an article, sketch, repository, screenshot, or wiring photograph. If a token is exposed, rotate it through BotFather immediately. Chat-ID filtering prevents unauthorized chats from issuing commands, but it does not make the complete device secure. Use a dedicated IoT Wi-Fi network where practical, avoid unnecessary group chats, and remember that photographs are transmitted through Telegram and may contain personal or site-sensitive information. See Telegram’s bot overview and Bot API.
Upload and verify the firmware
- Enter Wi-Fi credentials, the bot token, and the authorized chat ID using placeholders only in shared code.
- Select the AI Thinker ESP32-CAM board and the appropriate upload settings.
- Connect GPIO0 to GND.
- Upload the sketch through the FTDI adapter.
- Remove the GPIO0 jumper.
- Reset the board.
- Open Serial Monitor, commonly at 115200 baud if that is the sketch’s configured rate.
- Send
/startto the bot.
Representative output may look like this, although IP address and timing vary:
Connecting to WiFi...
WiFi connected
ESP32-CAM IP Address: 192.168.x.x
Test in layers: first serial output, then camera-only capture, Wi-Fi connection, Telegram /photo, PIR input, reed switch input, and finally the optional flame and MQ-6 modules. Disconnect extra sensors during camera troubleshooting.
Camera capture and photo delivery
The camera is initialized in JPEG mode. If PSRAM is available, the firmware can use larger frame settings; without it, smaller frames are safer. Higher resolution may provide better evidence but consumes more RAM and takes longer to upload. For alerts, a reliably delivered smaller image is usually more useful than a large image that causes a reset or timeout.
The upload process obtains a framebuffer with esp_camera_fb_get(), connects securely to api.telegram.org, sends a multipart image request to:
Rank #3
- Dual-core processor: The ESP32 module is based on the powerful ESP32-S3-WROOM N16R8 module and is equipped with a dual-core 32-bit LX7 processor. Its excellent AI computing performance, real-time processing capabilities, and low power consumption make it ideal for image recognition, edge AI, and complex IoT applications
- Integrated 2-megapixel OV3660 camera: Built-in OV3660 camera to capture clear images and stream video in real time. Perfect for smart surveillance, face recognition, and AI-based computer vision projects. It is the preferred solution for DIY makers and professionals to build camera-enabled IoT systems
- Dual Type-C ports for OTG and serial debugging: Designed with two USB Type-C interfaces - one supports USB OTG for host/device functions, and the other provides TTL serial for easy programming and debugging
- Shared antenna: Supports IEEE 802.11b/g/n Wi-Fi (2.4GHz) and Bluetooth 5 (LE and Mesh), using shared antennas to optimize wireless performance. Enhanced 2 Mbps PHY and long-distance communication (Coded PHY) ensure stable multitasking in harsh environments
- Multi-scenario applications: The ESP32 S3 development board maintains high stability even at high temperatures, making it ideal for industrial environments, educational purposes, and AI-driven projects. It is a versatile choice for robots, smart devices, and machine vision in lab or field applications
https://api.telegram.org/bot<BOT_TOKEN>/sendPhoto
and must release the framebuffer with esp_camera_fb_return(fb). The Universal Telegram Bot library provides sendPhotoByBinary; its abstraction is generally easier to maintain than hand-building multipart boundaries, content lengths, and response handling. TLS failures, large-image memory pressure, partial writes, and timeouts should be handled explicitly.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Original Telegram command set
| Command | Original behavior |
|---|---|
/start |
Displays available instructions |
/photo |
Captures and sends a photograph |
/flashOn / /flashOff |
Controls the GPIO 4 flash LED |
/EnableMotionAlert / /DisableMotionAlert |
Enables or disables motion notifications and photo capture |
/EnableDoorAlert / /DisableDoorAlert |
Enables or disables door alerts |
/EnableSmokeAlert / /DisableSmokeAlert |
Enables or disables the MQ-6 input alert |
/EnableFireAlert / /DisableFireAlert |
Enables or disables the flame-input alert |
These spellings and capitalizations describe the original firmware; they are not automatically supported by a rewritten sketch. A maintained version should consider simpler commands such as /arm, /disarm, /status, /motion_on, and /door_on, ideally exposed through Telegram’s command menu.
Sensor behavior and practical improvements
PIR motion sensor
PIR modules can trigger falsely because of warm air, HVAC flow, direct sunlight, pets, electrical noise, or startup behavior. The original firmware allows roughly 40 seconds for PIR and MQ-6 stabilization; treat that as a module-specific warm-up delay, not a universal value. Add a cooldown timer so one movement does not create a flood of photographs. For noisy installations, require a sustained or repeated state before sending an alert.
Reed switches
A reed switch is only a contact. Use a pull-up or pull-down resistor, choose normally-open or normally-closed logic deliberately, debounce the input, and define what a broken wire means. A loose cable or vibrating magnet can otherwise look like a genuine door event.
MQ-6
The MQ-6 needs warm-up and practical calibration. Its response varies with heater temperature, supply voltage, airflow, sensor age, and environment. A module’s digital output is a threshold indication, not a calibrated concentration measurement. Never use it instead of a certified gas or carbon-monoxide alarm.
Flame module
Flame modules respond to infrared or light characteristics and may be affected by sunlight, incandescent lamps, reflections, distance, and sensor angle. Smoke without visible flame may not trigger them. Treat the result as experimental input only.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Recommended firmware improvements
- Maintain explicit states for device online/offline, armed/disarmed, and each alert category.
- Add
/statusto report enabled alerts, sensor states, last event time, and last photo result. - Add per-sensor cooldowns and a maximum notification rate.
- Retry failed Telegram uploads and record unsent events.
- Log locally and optionally save images to microSD where supported.
- Drive a local LED or buzzer when Telegram is unavailable.
- Use NTP time and secure TLS configuration rather than assuming the device clock is correct.
- Consider OTA updates only after implementing authentication and a recovery method.
- For larger installations, separate sensor processing from camera capture with a two-board design or use MQTT/Home Assistant.
Troubleshooting
Camera initialization or capture failure
Messages such as Camera init failed, Camera capture failed, or Camera Setup Failed! usually indicate a wrong board profile, loose or reversed ribbon cable, incorrect pin map, inadequate power, PSRAM mismatch, excessive frame size, or a defective module.
Rank #4
- Dual core: Upgraded ESP32 CAM module equipped with a powerful dual-core processor, 32-bit dual-core CPU with low power consumption. The main frequency is up to 240 MHz, and the computing power is up to 600 DMIPS; integrated 520 KB SRAM, external 4 MB PSRAM.
- Flexible extension: ESP cam supports UART/SPI/I2C/PWM/ADC/DAC and other interfaces. Supports OV7670 and OV2640 cameras, built-in flash.
- Low performance: For ESP32 cam with antennas. Very low power consumption, deep sleep current is as low as 6mA. It is an ultra-small 802.11b/g/n Wi-Fi + BT/BLE module. Supports STA/AP/STA+AP working mode. USB to serial port CH340G
- Easy to use: for ESP32-CAM-MB is a small camera module, with on-board PCB antenna, convenient connection. With the built-in development card and TF card slot, it is easy to set up your project and start working.
- Wide application: OV2640 supports the energy-saving Internet of Things (IoT). The ESP32 module supports image transmission for smart household appliances, wireless monitoring, wireless positioning systems, etc.
- Select the exact AI Thinker profile.
- Reseat the OV2640 cable.
- Test the standard CameraWebServer example.
- Reduce frame size or JPEG quality.
- Use a stronger 5 V supply.
- Confirm PSRAM status.
- Disconnect sensors and the flash LED during testing.
Brownouts and boot loops
Repeated resets, intermittent camera operation, or a brownout message usually point to a weak FTDI adapter, voltage drop through thin wires, an overloaded breadboard supply, Wi-Fi current spikes, or a poor regulator. Use a stable supply, short wiring, and separate sensor power where necessary. Do not solve the symptom by disabling brownout protection.
Wi-Fi works but Telegram fails
Check DNS, Internet access, captive portals, firewall rules, bot token, chat ID, whether the user pressed Start, TLS certificate configuration, and system time. The maintained example demonstrates secure-client setup, NTP time, and Telegram polling with getUpdates.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11The bot receives messages but does not respond
Confirm the exact bot, chat ID, command capitalization, and authorization check. Ensure another running bot instance is not consuming the same updates. Also check for blocking sensor or network code.
False alerts
Use debounce and hysteresis, allow sensor warm-up, shorten noisy wiring, add pull resistors, apply cooldown timers, and expose a status command so the device’s interpretation can be checked without opening the enclosure.
When to use this design
This ESP32-CAM project is a good fit for a low-cost learning build, temporary workshop monitor, garage or shed experiment, Telegram-based photo alerts, and custom Arduino C++ sensor logic. It is a poor fit as the primary system for life-safety fire or gas detection, insurance-compliant burglary protection, 24/7 commercial surveillance, guaranteed uptime, multi-camera recording, or installations where the operator cannot troubleshoot electronics and networks.
For local dashboards, automations, MQTT, and multiple devices, ESP32-CAM with Home Assistant may be more flexible but adds software complexity. Commercial camera and alarm systems are preferable when professional support, certified hardware, cloud recording, or monitored response matters. A two-board design is worth considering when the ESP32-CAM’s GPIO and memory limits become restrictive.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Quick Recap
Final installation checklist
- Confirm the board is an AI Thinker ESP32-CAM or update the pin map for the actual board.
- Record the tested IDE and library versions.
- Keep Wi-Fi credentials, bot token, and chat ID out of public code.
- Test
/photobefore connecting every sensor. - Verify boot behavior with GPIO 2, 12, and 15 connected.
- Use a stable 5 V supply and test for brownouts during photo upload.
- Set PIR warm-up and cooldown periods.
- Debounce reed switches and define wiring-failure behavior.
- Use MQ-6 and flame modules only for experimentation.
- Install certified smoke, CO, gas, and fire alarms separately.
- Protect the enclosure and consider local fallback alerts and backup power.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

