What it shows
An ESP32-CAM board with its small camera takes a photo when the doorbell button is pressed or a PIR sees movement, and sends the picture to a free messaging bot on the owner's phone over Wi-Fi. It shows how a microcontroller can handle images and internet messages.
The science
The ESP32-CAM has a camera interface that captures a JPEG into memory. On a trigger, the sketch connects over HTTPS to the messaging service's bot API and uploads the JPEG as a photo message using a token the student creates for a bot. The PIR gives a 3.3 V-compatible digital trigger; the button uses an internal pull-up. Because the camera and Wi-Fi radio share power, a 2 A supply and a capacitor across the rails stop resets during transmission.
Materials
Cost: under Rs 1,500. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.
- An ESP32-CAM board with its OV2640 camera
- A USB to serial adapter (FTDI or CH340) for programming
- A push button and an HC-SR501 PIR
- A 5 V, 2 A power supply or power bank
- Jumper wires and a cardboard door frame
- A phone with a free messaging app that supports bots
Safety
For this project: Power the ESP32-CAM from a steady 5 V supply only; weak USB ports cause brown-outs. Do not photograph people without telling them; the snapshot is for the demonstration.
Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.
All the safety rulesStep by step
9 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.
Create a bot in the messaging app and note its token and your chat ID as the ebook describes.
Wire the serial adapter to the ESP32-CAM (5V, GND, U0R to TX, U0T to RX) and connect GPIO 0 to GND to enter flashing mode.
Open the CameraWebServer example, set the AI Thinker board model, add Wi-Fi details and upload; remove the GPIO 0 link and reset.
Open the IP address from the serial monitor in a browser and confirm a live image appears.
Wire the button between GPIO 13 and GND and the PIR output to GPIO 12.
Replace the web server code with the bot send-photo example from the ebook, keeping the camera setup.
In the loop, when the button is pressed or the PIR goes high, capture a frame and send it with a caption such as Visitor at the door.
Add a 10 second lockout after each send so one visitor does not produce ten photos.
Mount the board in the door frame with the lens looking through a hole and test from the phone.
What you should see
Within five seconds of a press or movement, the phone receives a photo of the door area with a caption. The serial monitor reports each upload status.
Viva questions
A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.
1Why does the ESP32-CAM need GPIO 0 grounded to program?
That pin tells the chip to boot into download mode so the new sketch can be written.
2What is a bot token?
A secret key that identifies your bot to the messaging service; anyone with it can send messages as the bot, so keep it private.
3Why does the board reset while sending?
The radio draws current pulses; a weak supply dips below the working voltage, so a 2 A supply and a capacitor are used.
4What is JPEG?
A compressed image format that stores the photo in far fewer bytes than the raw pixels, making upload fast.
Take it further
Add a small speaker and play a chime, and record the time of each visitor to an SD card.
Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.
Free ebooks for this project
Robotics
Arduino and Coding for Robots Study Book
The complete study notes, practice questions and glossary for Arduino and Coding for Robots
