ESP32 S3 Camera - Send Photo to Telegram When Door Opens

This tutorial instructs you how to build a door camera with the ESP32 S3. A magnetic door sensor watches your door. The moment somebody opens it, the ESP32 S3 takes a photo and sends it to your phone with Telegram. You see who opened the door, from anywhere in the world.

ESP32 S3 Camera - Send Photo to Telegram When Door Opens

What you'll build:

  1. Your own Telegram bot that sends you messages
  2. An ESP32 S3 camera with a magnetic door sensor
  3. A photo with the text "The door is open!" on your phone, every time the door opens
  4. Clean detection, so one door movement sends exactly one photo

Hardware Preparation

1×ESP32 S3 N16R8 OV5640 Camera
1×Alternatively, ESP32 S3 N16R8 OV2640 Camera
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Door Sensor
1×Jumper Wires
1×Optionally, ESP32 S3 44-Pin Screw Terminal Block
1×Optionally, ESP32 S3 44-Pin Breakout Board
1×Recommended: Screw Terminal Expansion Board for ESP32 S3
1×Recommended: Breakout Expansion Board for ESP32 S3
1×Recommended: Power Splitter for ESP32 S3

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

※ NOTE THAT:

The ESP32 S3 camera board has 40 pins, but the screw terminal block and the breakout board have 44 pins. They still work together. Put the camera board in the center of the 44-pin board, so 2 pins stay free on the left side and 2 pins stay free on the right side.

The screw terminal block lets you connect wires with a screwdriver, with no soldering. The breakout board gives you easy pin headers for a breadboard.

Overview of Telegram

Telegram is a free chat application for your phone and your computer. Telegram lets you make a bot. A bot is a robot friend in your chat list. Your ESP32 S3 sends the photo to the bot, and the bot shows it to you.

You need two secret texts:

NameWhat it isLooks like
Bot tokenThe password of your bot8012345678AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Chat IDThe number of your chat123456789

※ NOTE THAT:

Never show your bot token to anybody, and never put it on a website or on GitHub. Somebody with your token can control your bot.

Step 1: Make Your Bot

  1. Install Telegram on your phone, and make an account.
  2. In Telegram, search for @BotFather. It has a blue tick.
  3. Open the chat with BotFather and talk to it like this:
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.
BotFather

BotFather

bot
Today
/newbot
10:15 AM ✓✓
Alright, a new bot. How are we going to call it? Please choose a name for your bot.
10:16 AM
My ESP32 Door Camera
10:17 AM ✓✓
Good. Now let's choose a username for your bot. It must end in bot.
10:18 AM
my_esp32_door_bot
10:19 AM ✓✓
Done! Congratulations on your new bot. Use this token to access the HTTP API: 8012345678:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
10:20 AM
  1. Copy the bot token from the last message and keep it safe.

Step 2: Find Your Chat ID

  1. In Telegram, search for the name of your new bot and open the chat.
  2. Send any message to your bot, for example hello. This step is necessary. Telegram does not let a bot write to you before you have written to it.
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.

ArduinoBot

bot
Today
hello
10:15 AM ✓✓
  1. Open this address in your web browser. Put your own bot token in the place of <YOUR_BOT_TOKEN>:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
  1. The browser shows a long text. Look for "chat":{"id":. The number after it is your chat ID:
{ "ok": true, "result": [ { "update_id": 700000001, "message": { "message_id": 1, "from": { "id": 123456789, "first_name": "John" }, "chat": { "id": 123456789, "first_name": "John", "type": "private" }, "date": 1790000000, "text": "hello" } } ] }

※ NOTE THAT:

Does the browser show {"ok":true,"result":[]} with nothing inside? Then you did not send a message to your bot yet. Go back to step 2, send hello to your bot, then load the address again.

※ NOTE THAT:

Many other tutorials tell you to ask the bot @myidbot with the message /getid. That bot belongs to somebody else, and very often it does not answer at all. The web address above always works, because it asks Telegram directly.

※ NOTE THAT:

Forgot step 2? Then the ESP32 S3 shows the answer Forbidden: bot can't initiate conversation with a user in the Serial Monitor. Open the chat with your bot and send it any message, then try again.

Step 3: Put Them in the Code

Open the code and change these four lines:

const char *WIFI_SSID = "YOUR_WIFI_SSID"; const char *WIFI_PASSWORD = "YOUR_WIFI_PASSWORD"; const char *BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN"; const char *CHAT_ID = "YOUR_TELEGRAM_CHAT_ID";

Overview of Door Sensor

A door sensor has two parts:

  1. A small plastic box with two wires. This part holds a reed switch. You put it on the door frame.
  2. A second plastic box with no wires. This part holds a magnet. You put it on the door itself.

When the door is closed, the magnet sits next to the reed switch and closes it. When the door opens, the magnet moves away, and the switch opens again.

Door Sensor

For more detail about the door sensor, see the ESP32 S3 - Door Sensor tutorial.

Key Specifications

ItemValue
TypeMagnetic reed switch (normally open)
Wires2, and they have no direction
Working gapabout 15 mm to 25 mm
PowerNone. It is only a switch.

※ NOTE THAT:

The two wires have no plus and no minus. You can connect them either way round.

How The ESP32 S3 Reads The Door

The door sensor is only a switch, so the ESP32 S3 must give it a voltage itself. We use the internal pull-up resistor:

pinMode(DOOR_PIN, INPUT_PULLUP);

With INPUT_PULLUP, the pin is HIGH when nothing pulls it down. The table shows what happens:

DoorMagnetReed switchPin reads
ClosedNext to the switchClosed (connected to GND)LOW
OpenAway from the switchOpen (nothing connected)HIGH

So in the code:

#define DOOR_CLOSED LOW #define DOOR_OPEN HIGH

Why The Code Waits 50 Milliseconds

A metal switch never changes cleanly. In the first milliseconds it jumps between open and closed many times. This is called bouncing. Without protection, one door movement would send five photos.

The code waits until the value stays the same for 50 milliseconds:

if (reading != lastReadState) { lastReadState = reading; lastChangeTime = millis(); // the value changed, so start counting again } if (millis() - lastChangeTime >= DEBOUNCE_TIME && reading != doorState) { doorState = reading; // the value is stable now, so we believe it }

Motion Sensor or Door Sensor?

Both build a small security camera, but they are not the same:

Door SensorMotion Sensor (PIR)
SeesOnly the door openingAny warm body that moves
False alarmsAlmost neverSometimes (heaters, windows, animals)
Warm-up timeNone30 to 60 seconds
Needs powerNoYes, 5V
Works through glassYesNo

A door sensor is the better choice when you want to know about one exact event. See also the ESP32 S3 Camera - Send Photo to Telegram When Motion Detected tutorial.

Wiring Diagram between Door Sensor and ESP32 S3

Connect the two wires of the door sensor to your ESP32 S3.

The wiring diagram between ESP32 S3 Door Sensor Telegram

This image is created using Fritzing. Click to enlarge image

Door Sensor WireESP32 S3 Pin
First wireGPIO2
Second wireGND

Then put the two parts of the sensor on your door:

  1. Put the part with the wires on the door frame.
  2. Put the part without wires on the door itself.
  3. Move the door until the two parts are next to each other. They must almost touch, with a gap smaller than 15 mm.
  4. Point the camera at the door.

Safety Notes

The door sensor needs no power. Do not connect it to 5V or to 3.3V. One wire goes to GPIO2, the other goes to GND. Nothing can break, because it is only a switch.

The camera uses GPIO4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17 and 18. Do not use these pins for the sensor. GPIO2 is free, so we use it.

Arduino IDE Settings for ESP32 S3 Camera

The camera does not work with the default settings of the Arduino IDE. You must change some items in the Tools menu before you upload the code.

Tools Menu ItemSelect This
BoardESP32S3 Dev Module
Flash Size16MB (128Mb)
PSRAMOPI PSRAM
Partition SchemeHuge APP (3MB No OTA/1MB SPIFFS)
CPU Frequency240MHz (WiFi)
USB ModeHardware CDC and JTAG
Upload ModeUART0 / Hardware CDC
Upload Speed921600
USB CDC On BootEnabled

※ NOTE THAT:

PSRAM must be OPI PSRAM, and Partition Scheme must be Huge APP. Change Flash Size first, because the list of Partition Scheme options changes after that.

How To Send a Photo to Telegram

You do not need to install any library. The code talks to Telegram directly.

  • Telegram uses https, so we need a secure client.
#include <WiFiClientSecure.h> WiFiClientSecure client; client.setInsecure(); // do not check the certificate of the Telegram server client.connect("api.telegram.org", 443);

※ NOTE THAT:

setInsecure() means the ESP32 S3 does not check who the server really is. For a small home project this is fine, and it saves a lot of memory. The photo is still sent through an encrypted connection.

  • To send a photo, we use the Telegram address /bot<TOKEN>/sendPhoto. The photo travels inside a multipart message. A multipart message has parts, and a line of text called a boundary separates the parts. This project uses three parts: the chat ID, the text, and the photo.
String head = "--" BOUNDARY "\r\n"; head += "Content-Disposition: form-data; name=\"chat_id\"\r\n\r\n"; head += String(CHAT_ID) + "\r\n"; head += "--" BOUNDARY "\r\n"; head += "Content-Disposition: form-data; name=\"caption\"\r\n\r\n"; head += "The door is open!\r\n"; head += "--" BOUNDARY "\r\n"; head += "Content-Disposition: form-data; name=\"photo\"; filename=\"photo.jpg\"\r\n"; head += "Content-Type: image/jpeg\r\n\r\n"; String tail = "\r\n--" BOUNDARY "--\r\n";

※ NOTE THAT:

The caption part is the text under the photo in Telegram. Change The door is open! to any message you like.

  • The Content-Length must be the size of everything: the first part, the photo, and the last part.
size_t totalLength = head.length() + fb->len + tail.length();

※ NOTE THAT:

A wrong Content-Length is the most common mistake. Telegram then waits for more data and never answers.

  • Send the photo in small pieces. A big write() often fails on a secure connection.
for (size_t i = 0; i < fb->len; i += 1024) { size_t piece = fb->len - i; if (piece > 1024) piece = 1024; client.write(fb->buf + i, piece); }
  • Read the answer. When everything is fine, the answer of Telegram contains "ok":true.
if (answer.indexOf("\"ok\":true") > 0) { Serial.println("The photo was sent to Telegram"); }

※ NOTE THAT:

This project uses a small image size (FRAMESIZE_SVGA, 800×600), because a small photo is sent much faster. A photo of 50 KB takes about 3 seconds. A photo of 200 KB takes about 10 seconds.

ESP32 S3 Code

The following code sends a photo to your Telegram chat every time the door is opened. Nothing is sent when the door is closed again. The quiet time is 30 seconds, so a person who opens and closes the door many times does not fill your chat. To change it, change the line #define QUIET_TIME 30000.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-camera-send-photo-to-telegram-when-door-opens */ #include <WiFi.h> #include <WiFiClientSecure.h> #include "esp_camera.h" const char *WIFI_SSID = "YOUR_WIFI_SSID"; // CHANGE IT const char *WIFI_PASSWORD = "YOUR_WIFI_PASSWORD"; // CHANGE IT const char *BOT_TOKEN = "1234567890:ABCDefGhIJKlmNoPQRsTUVwXYZ1234567890"; // CHANGE IT const char *CHAT_ID = "1234567890"; // CHANGE IT #define DOOR_PIN 2 // the door sensor is connected to GPIO2 #define DEBOUNCE_TIME 50 // wait 50 milliseconds, because the switch bounces #define QUIET_TIME 30000 // wait 30 seconds before the next message (30000 milliseconds) // Camera pins of the ESP32-S3-N16R8 camera board. // The same pins work for the OV2640, OV3660 and OV5640 versions. #define PWDN_GPIO_NUM -1 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM 15 #define SIOD_GPIO_NUM 4 #define SIOC_GPIO_NUM 5 #define Y9_GPIO_NUM 16 #define Y8_GPIO_NUM 17 #define Y7_GPIO_NUM 18 #define Y6_GPIO_NUM 12 #define Y5_GPIO_NUM 10 #define Y4_GPIO_NUM 8 #define Y3_GPIO_NUM 9 #define Y2_GPIO_NUM 11 #define VSYNC_GPIO_NUM 6 #define HREF_GPIO_NUM 7 #define PCLK_GPIO_NUM 13 #define TELEGRAM_HOST "api.telegram.org" #define BOUNDARY "diyablesphoto" // The door sensor is a switch: // LOW = the switch is closed = the magnet is near = the door is CLOSED // HIGH = the switch is open = the magnet is away = the door is OPEN #define DOOR_CLOSED LOW #define DOOR_OPEN HIGH int doorState = DOOR_CLOSED; int lastReadState = DOOR_CLOSED; unsigned long lastChangeTime = 0; unsigned long lastSendTime = 0; // Returns the name of the camera sensor that is installed on the board const char *getSensorName(int pid) { switch (pid) { case OV2640_PID: return "OV2640 (2 MP, max UXGA 1600x1200)"; case OV3660_PID: return "OV3660 (3 MP, max QXGA 2048x1536)"; case OV5640_PID: return "OV5640 (5 MP, max QSXGA 2592x1944)"; default: return "Unknown sensor"; } } bool initCamera() { 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_sccb_sda = SIOD_GPIO_NUM; config.pin_sccb_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; config.frame_size = FRAMESIZE_SVGA; // 800x600 - small, so it is sent quickly config.jpeg_quality = 12; // 0 to 63, a lower number means a better image config.fb_count = 1; config.fb_location = CAMERA_FB_IN_DRAM; config.grab_mode = CAMERA_GRAB_WHEN_EMPTY; if (psramFound()) { config.fb_location = CAMERA_FB_IN_PSRAM; config.jpeg_quality = 10; config.fb_count = 2; config.grab_mode = CAMERA_GRAB_LATEST; } else { config.frame_size = FRAMESIZE_QVGA; Serial.println("WARNING: PSRAM not found. Please set PSRAM to OPI PSRAM in the Tools menu."); } esp_err_t err = esp_camera_init(&config); if (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x\n", err); return false; } sensor_t *s = esp_camera_sensor_get(); Serial.printf("Camera sensor: %s\n", getSensorName(s->id.PID)); // Each sensor needs slightly different settings switch (s->id.PID) { case OV2640_PID: s->set_vflip(s, 0); s->set_hmirror(s, 0); break; case OV3660_PID: s->set_vflip(s, 1); // the OV3660 image is upside down by default s->set_brightness(s, 1); // make the image a little brighter s->set_saturation(s, -2); // make the colors a little softer break; case OV5640_PID: s->set_vflip(s, 0); s->set_hmirror(s, 0); break; default: break; } return true; } // Sends one photo to your Telegram chat bool sendPhotoToTelegram(camera_fb_t *fb) { WiFiClientSecure client; client.setInsecure(); // do not check the certificate of the Telegram server client.setTimeout(15); Serial.println("Connecting to Telegram..."); if (!client.connect(TELEGRAM_HOST, 443)) { Serial.println("Cannot connect to Telegram"); return false; } // The first part of the message: who receives the photo, and the text String head = "--" BOUNDARY "\r\n"; head += "Content-Disposition: form-data; name=\"chat_id\"\r\n\r\n"; head += String(CHAT_ID) + "\r\n"; head += "--" BOUNDARY "\r\n"; head += "Content-Disposition: form-data; name=\"caption\"\r\n\r\n"; head += "The door is open!\r\n"; head += "--" BOUNDARY "\r\n"; head += "Content-Disposition: form-data; name=\"photo\"; filename=\"photo.jpg\"\r\n"; head += "Content-Type: image/jpeg\r\n\r\n"; // The last part of the message String tail = "\r\n--" BOUNDARY "--\r\n"; size_t totalLength = head.length() + fb->len + tail.length(); // Send the HTTP header client.print("POST /bot" + String(BOT_TOKEN) + "/sendPhoto HTTP/1.1\r\n"); client.print("Host: " TELEGRAM_HOST "\r\n"); client.print("Content-Type: multipart/form-data; boundary=" BOUNDARY "\r\n"); client.print("Content-Length: " + String(totalLength) + "\r\n"); client.print("Connection: close\r\n\r\n"); // Send the message client.print(head); // Send the photo in small pieces of 1024 bytes for (size_t i = 0; i < fb->len; i += 1024) { size_t piece = fb->len - i; if (piece > 1024) piece = 1024; client.write(fb->buf + i, piece); } client.print(tail); // Read the answer of Telegram String answer = ""; unsigned long startTime = millis(); while (client.connected() && millis() - startTime < 15000) { while (client.available()) { answer += (char)client.read(); startTime = millis(); } } client.stop(); if (answer.indexOf("\"ok\":true") > 0) { Serial.println("The photo was sent to Telegram"); return true; } Serial.println("Telegram did not accept the photo. The answer was:"); Serial.println(answer); return false; } void takeAndSendPhoto() { camera_fb_t *fb = esp_camera_fb_get(); if (!fb) { Serial.println("Photo capture failed"); return; } Serial.printf("Photo taken: %u bytes\n", fb->len); sendPhotoToTelegram(fb); esp_camera_fb_return(fb); // give the memory back to the camera } void setup() { Serial.begin(115200); delay(1000); // INPUT_PULLUP: the pin is HIGH when the switch is open pinMode(DOOR_PIN, INPUT_PULLUP); if (!initCamera()) { Serial.println("Stopped"); while (true) delay(1000); } WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Connecting to WiFi"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(); Serial.print("Connected. IP address: "); Serial.println(WiFi.localIP()); doorState = digitalRead(DOOR_PIN); lastReadState = doorState; if (doorState == DOOR_OPEN) Serial.println("Ready. The door is open now."); else Serial.println("Ready. The door is closed now."); } void loop() { int reading = digitalRead(DOOR_PIN); // The switch bounces, so we wait until the value is stable if (reading != lastReadState) { lastReadState = reading; lastChangeTime = millis(); } if (millis() - lastChangeTime >= DEBOUNCE_TIME && reading != doorState) { doorState = reading; if (doorState == DOOR_OPEN) { Serial.println("The door is open!"); if (millis() - lastSendTime >= QUIET_TIME) { takeAndSendPhoto(); lastSendTime = millis(); } else { Serial.println("Too soon after the last photo. Nothing is sent."); } } else { Serial.println("The door is closed."); } } }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Make your Telegram bot and find your chat ID. See the steps above.
  3. Unplug the USB cable, then connect the two wires of the door sensor as in the table above.
  4. Copy the above code and paste it into the Arduino IDE.
  5. Change YOUR_WIFI_SSID, YOUR_WIFI_PASSWORD, YOUR_TELEGRAM_BOT_TOKEN and YOUR_TELEGRAM_CHAT_ID.
  6. Change the settings in the Tools menu. See the table above.
  7. Compile and upload the code to the ESP32 S3 board by clicking the Upload button in Arduino IDE.
Arduino IDE Upload Code
  1. Open the Serial Monitor in Arduino IDE.
How to open serial monitor on Arduino IDE
  1. Press the RESET button one time.
  2. Put the two parts of the sensor next to each other. The Serial Monitor says the door is closed.
  3. Move the two parts away from each other, like an opening door.
  4. Look at your phone. The photo arrives in your Telegram chat, with the text under it:
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.

ArduinoBot

bot
Today
The door is open!
10:15 AM
ESP32 S3 Door Camera Photo in Telegram

Serial Monitor

The following readings were captured in 2026:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-09-23 14:00:01] Camera sensor: OV5640 (5 MP, max QSXGA 2592x1944) [2026-09-23 14:00:01] Connecting to WiFi... [2026-09-23 14:00:04] Connected. IP address: 192.168.0.2 [2026-09-23 14:00:04] Ready. The door is closed now. [2026-09-23 14:01:12] The door is open! [2026-09-23 14:01:12] Photo taken: 51353 bytes [2026-09-23 14:01:12] Connecting to Telegram... [2026-09-23 14:01:15] The photo was sent to Telegram [2026-09-23 14:01:31] The door is closed.
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

When the door is opened again too quickly, the code says so and sends nothing:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-09-23 14:01:38] The door is open! [2026-09-23 14:01:38] Too soon after the last photo. Nothing is sent.
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Troubleshooting

The Serial Monitor always says the door is open, even when it is closed.

  • The two parts are too far apart. They must almost touch, with a gap smaller than 15 mm.
  • Check the wire on GPIO2 and the wire on GND.
  • Some door sensors are "normally closed" instead of "normally open". Then the two lines #define DOOR_CLOSED LOW and #define DOOR_OPEN HIGH must swap their values.

The Serial Monitor always says the door is closed.

The two wires are probably touching each other, or one wire is on the wrong pin. One wire goes to GPIO2, the other to GND.

One door movement sends two or three photos.

Increase DEBOUNCE_TIME from 50 to 150.

The Serial Monitor shows Forbidden: bot can't initiate conversation with a user.

You never wrote to your bot. Open Telegram, find your bot, and send it any message. Then press RESET on the board.

The Serial Monitor shows Unauthorized.

Your bot token is wrong. Copy it again from BotFather. The token has two parts joined by : and you need all of it.

The Serial Monitor shows chat not found.

Your chat ID is wrong. Ask @myidbot again with /getid. Do not put spaces around the number.

The Serial Monitor shows Cannot connect to Telegram.

Check that your WiFi works. The IP address must appear in the Serial Monitor. Some school and company networks block Telegram, so try your phone hotspot.

The photo takes a long time.

Use a smaller image size. FRAMESIZE_VGA (640×480) is about half of SVGA.

The photo is dark.

The camera cannot see in the dark. Add a light near the door, or a lamp that switches on with the door.

Applications

A door sensor gives you one clear event with almost no false alarms, so this project is good everywhere something must stay closed. Here are practical projects you can build with this code:

  1. Front door security camera: See who opens your front door while you are at work or on holiday.
  2. Parcel box camera: Get a photo when the delivery person opens your parcel box or your mailbox.
  3. Medicine cabinet alarm: Know when a child opens a cabinet that must stay closed.
  4. Shop door counter: Keep a picture of every customer who opens the shop door.
  5. Tool box, safe or locker alarm: Get a photo the moment somebody opens it, even when you are far away.
  6. Garage door alert: Know when your garage door or your shed is opened at night.
  7. Window opening alarm: Put the sensor on a window instead of a door, and get a photo when it is opened.
  8. Server rack and control cabinet: Keep a photo record of everybody who opens a cabinet at work.
  9. Fridge or freezer watcher: A fun home project to see who takes the last piece of cake.
  10. Hotel room or rented flat: Know that the door stayed closed while the room was empty.

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

Challenges

  1. Beginner: Change the text under the photo from The door is open! to your own message.
  2. Intermediate: Also send a message when the door is closed again, so you know how long it was open.
  3. Advanced: Send a photo only at night, between 22:00 and 06:00. Use an NTP time server to read the real time.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!