
Look, weāve all been there. You leave your desk for five minutes to grab a coffee, and when you get back, your favorite pen is missing, or worse, someone touched your perfectly organized pile of āIāll need this laterā components. You could talk to HR, or you could over-engineer a solution that involves microcontrollers, servos, and a camera that stares unblinkingly at anyone who approaches. Welcome to the ESP32-CAM Desktop Security Turret.
Building this is like giving a toddler a laser pointer, except the toddler is a tiny computer, and instead of a laser, itās streaming a live video feed to your browser while furiously twitching its dual-axis neck. You will experience the joy of the magic blue smoke if you plug the 5V power into the wrong pin, and you will accidentally compile your code with the wrong board settings at least three times. Itās a rite of passage. Letās build a robot that judges your coworkers from afar.
Forget the junk drawer; you need specific hardware for this build.
Need help wiring up the FTDI programmer? Check out Lesson 157: Over-The-Air (OTA) Updates where we first tackled FTDI programming.
First, assemble the plastic bracket. It usually comes in pieces that require microscopic screws and a lot of patience. Mount one SG90 servo in the base (the pan axis) and the other in the top bracket (the tilt axis). Attach the ESP32-CAM to the flat faceplate using some heavy-duty double-sided tape or a 3D printed clip if youāre feeling fancy.
The ESP32-CAM is notoriously picky about power. If you power the servos directly from the 3.3V or 5V pin on the ESP32 while itās actively transmitting Wi-Fi, it will brownout, reset, and leave you crying in the corner.
Pro Tip: Use an external 5V power supply (like a bench power supply) to power the servos, and make absolutely sure to connect all the GND (ground) pins together!
Having servo jitter issues? Review our guide on PWM and Analog Outputs.
Weāll use a modified version of the standard ESP32 Web Server example but inject some servo logic using the ESP32Servo library.
(Full code snippet will go here in the final publish)
The code spins up a web server on your local Wi-Fi network. You open your browser, enter the IP address, and you get a live feed with sliders to manually control the Pan and Tilt angles.
Once you have manual control working flawlessly, you can start messing with OpenCV or a Python script on your PC to send HTTP requests to the ESP32-CAM to automatically track faces or movement. But thatās a headache for another day. For now, enjoy your manual desk defender.