RearSight: a Smart Keychain That Watches Your Back
by ayushmaan45 in Circuits > Cameras
2576 Views, 35 Favorites, 0 Comments
RearSight: a Smart Keychain That Watches Your Back
Hi, I’m Ayushmaan, a B.Tech student studying Electrical and Electronics Engineering in India. I like working on electronics projects, especially the kind that try to solve small everyday problems.
One thing that a lot of people have probably experienced is that uncomfortable feeling that someone might be following you while you’re walking alone, particularly at night. Even if nothing is actually happening, it still makes you check behind you again and again. The problem is that when you're walking, you can't really keep looking back all the time, and you can't see what’s happening behind you unless you turn around.
That thought is what gave me the idea for this project.
I wanted to build something small that could keep an eye on the area behind the user and let them know if something seemed unusual. The result is a small keychain device that uses a camera to monitor what’s behind you and sends a notification to your phone if someone stays in the camera view for too long.
The project is built around the DFRobot ESP32-CAM Development Board, which is a really handy board because it already has both a microcontroller and a camera on it. That makes it possible to run face detection directly on the device without needing any additional hardware.
The ESP32 also hosts a simple webpage with a live camera feed, so you can open it on your phone and see exactly what the camera is seeing. Another useful feature is that the camera can still work in low-light conditions, which means the device can continue monitoring even when it’s dark.
In the end, the goal of this project was just to create something small, practical, and interesting to build. By combining face detection, live video streaming, phone notifications, and night-vision capability in a compact design, the device works as a small keychain gadget that can help keep an eye on what’s happening behind you.
Supplies
- DFRobot ESP32-S3 AI Camera
- TP4056 charging module
- Li-ion battery
- Step-down voltage regulator module
- MT3608 DC‑DC Step‑Up Boost Converter Module
- 6-pin square tactile push button
- Jumper wires
- 3D-printed enclosure
Sketching the Design
Before starting the 3D model, I first sketched a rough design of the keychain on paper. This helped me visualize how the device should look and where the main components would fit.
I started by looking at a few reference images to get an idea of the overall shape and size that would work well for a keychain device. Since the DFRobot ESP32-S3 AI Camera already has a fixed camera position, I made sure the front of the design would leave space for the camera lens.
After that, I drew a simple sketch showing the basic shape of the enclosure and how the internal components might be arranged. This step helped me decide the approximate dimensions before moving on to the CAD model.
3D Modelling and Printing
Once the idea was clear, I recreated the design using Autodesk Fusion 360 and prepared the parts for 3D printing.
The enclosure is made of multiple parts:
- 1x Front Plate (main body with the camera opening for the ESP32 camera module)
- 1x Back Plate (holds the battery, TP4056 charging module, step-up module, and the switch)
- 10x Decorative Add-Ons (these are pasted onto the front plate to complete the design)
For printing, I used different PLA colors to give the keychain a better look:
- Front Plate: printed using red PLA
- Back Plate: printed using black PLA
- Decorative Add-Ons: printed using black PLA
After printing all the parts, the decorative add-ons were attached to the front plate, the electronics were mounted on the back plate, and finally both plates were assembled together to complete the enclosure.
Downloads
Attaching the Decorative Add-Ons
After printing all the parts, the next step was to attach the decorative pieces to the front plate.
The design includes 10 small add-on parts that are placed on top of the main front print to complete the final look of the keychain. These pieces were printed separately and then attached to the front plate.
To fix them in place, I used superglue. A small drop of glue was applied to each piece, and then it was carefully placed in its position on the front plate. Since the parts are small, it’s important to align them properly before the glue dries.
Circuit
The circuit for this project is quite simple. The Li-ion battery powers the device through the TP4056 charging module, and the output is regulated using the MT3608 DC-DC Step-Up Boost Converter Module before powering the DFRobot ESP32-S3 AI Camera.
A 6-pin tactile push button is used as the power switch for the device.
The complete wiring can be seen in the circuit diagram..
Assembling the Electronics
After completing the circuit connections, the next step is placing all the components inside the enclosure.
The Li-ion battery, TP4056 charging module, MT3608 step-up module, and the switch are mounted on the back plate, which was designed to hold these components in place. The DFRobot ESP32-S3 AI Camera is positioned in the front plate, with the camera lens aligned with the opening in the enclosure.
Once everything is placed properly, the wires are arranged neatly to fit inside the case, and the front and back plates are joined together to complete the assembly of the keychain device.
Adding the Final Touch
To make the device easier to carry, I added a small carabiner to the keychain loop of the enclosure. This allows the device to be clipped onto a backpack, belt loop, or bag.
The carabiner I used was taken from a project made by Arnov Sharma, called SolMate. It fit perfectly with the design and made the keychain much more practical to use.
With the carabiner attached, the device can now be easily clipped and carried wherever needed.
System Overview (Block Diagram)
The project is divided into three main parts: the camera unit, the processing system, and the user interface.
The camera unit is built using the DFRobot ESP32-S3 AI Camera, which captures images from behind the user and sends them over WiFi.
These images are received by a Python-based server, where face detection is performed. The system then checks if a person remains in the frame for a certain duration to determine if someone might be following.
Finally, the processed data is displayed on a web dashboard, and alerts are sent to the user when needed.
In simple terms, the flow of the system is:
ESP32 Camera → Server Processing → Detection Logic → Web Dashboard + Alerts
ESP32 Camera Setup and Data Transmission
In this step, the ESP32 is configured to initialize the camera, connect to WiFi, and capture image frames that are sent to the server.
1. Camera Initialization
The camera is configured using the pin definitions specific to the DFRobot ESP32-S3 AI Camera.
The camera configuration is set using the camera_config_t structure:
The camera is then initialized using:
2. WiFi Connection
The ESP32 connects to the WiFi network using:
Once connected, the IP address is printed to the Serial Monitor.
3. Capturing Image Frames
Inside the loop, frames are captured using:
This returns a frame buffer containing the image data.
4. Sending Data to Server
The captured image is sent to the server using an HTTP POST request:
Here:
- fb->buf → image data
- fb->len → size of image
5. Releasing Frame Buffer
After sending the data, the buffer is released:
Final Flow
Downloads
Python Server (Face Detection and Push Notification)
In this step, the Python server receives image frames from the ESP32, performs face detection, and triggers a Pushbullet notification when a person is detected continuously.
1. Setting Up the Server
The backend is created using Flask:
2. Pushbullet Configuration
Add your Pushbullet access token:
Function to send notification:
3. Receiving Image from ESP32
The ESP32 sends image data as raw bytes:
Convert image:
4. Face Detection
Faces are detected using:
5. Time-Based Detection Logic
The system checks if a face remains in the frame for a specific duration:
Reset when no face is detected:
6. Storing Latest Frame
For dashboard display:
7. Response to ESP32
Final Flow
Downloads
Web Dashboard (Frontend and API Integration)
In this step, a web dashboard is used to display the camera feed, detection status, and alerts in real time. The frontend communicates with the Python server using API endpoints.
1. Basic HTML Structure
The dashboard is created using a simple HTML layout:
2. Displaying Live Frame
The latest processed frame is fetched from the server:
3. Fetching Detection Status
The dashboard uses JavaScript to fetch data from the server:
4. Updating Image Feed
To refresh the latest frame:
5. Backend API (Python Side)
The dashboard depends on these endpoints:
Status API
Latest Frame
Final Flow
Final Thoughts
And that’s RearSight.
A small keychain device that can keep an eye on what’s happening behind you. Using the DFRobot ESP32-S3 AI Camera, the system can detect faces, send a notification to your phone, and allow you to check the live camera feed whenever needed. The camera also works in low-light conditions, so it can continue monitoring even at night.
The goal of this project was to see how much functionality could be packed into such a small device. It turned out to be a fun build and a great example of how powerful small AI-enabled boards have become.
That said, the current version does have a few limitations. For example, the system may face some issues in very crowded areas where multiple faces appear in the camera view. Improving the detection logic and making the system more reliable in such situations is something I plan to explore in future versions of the project.