Table of Contents

Remote-Controlled Pan-Tilt Selfie Camera

Introduction

Project Overview: This project consists of an internet-enabled camera system mounted on a dual-axis (Pan-Tilt) mechanical platform. It allows users to remotely control the camera's orientation through a web interface and capture high-resolution images stored locally on an SD card.

Purpose and Goal: The primary goal is to create a versatile monitoring tool that combines real-time low-latency video streaming with on-demand high-definition photography. By offloading mechanical control to a dedicated microcontroller, the system ensures smooth movement without interrupting the visual processing.

General Description

Module Descriptions

ESP32-CAM : Acts as the central processing unit. It hosts the Web Server, handles Wi-Fi connectivity, captures video frames via the OV2640 sensor, and manages the SD interface for file storage.

ATmega328P : Dedicated to hardware execution. It listens for commands via UART from the ESP32 and generates PWM signals to drive the servomotors. It also manages the 16×2 LCD for real-time telemetry.

Pan-Tilt Mechanism: Driven by two SG90 servomotors, providing vertical and horizontal movement.

I2C LCD Display: Provides immediate feedback on system status, such as the current IP address and coordinates.

Hardware Design

The hardware implementation will use the following components:

- ESP32-CAM

- ATMega328P-Xmini

- OV2640: high resolution camera for esp32

- SG90 servo x 2

- QAPASS 1602A: 16 x 2 LCD

Software Design

The project's software architecture adopts a distributed Master-Slave model, where intensive processing tasks (networking, video, storage) are completely separated from real-time physical execution (servo control, display).

The system utilizes two development environments interconnected via the UART protocol at a stable speed of 38400 bps.

A. ESP32-CAM Module (Master / Web Server)

This module manages the user interface, video stream, and local storage. It initializes a local Wi-Fi Access Point and runs an asynchronous HTTP server on port 80.

Camera Management (OV2640): To prevent chip overheating, the hardware clock frequency (XCLK) is reduced to 10MHz. The video stream runs natively at a low resolution (QVGA) for a high frame-rate, dynamically switching to UXGA (HD) resolution only when saving to the SD card.

Video Stream Optimization: The HTML page sent to clients uses a feedback mechanism based on the image's onload event. Unlike a rigid timer (setInterval), a new frame request (/jpg) is sent to the server only after the previous frame has been fully downloaded. This eliminates HTTP buffer congestion and prevents system freezing.

B. ATmega328P Module (Slave / Hardware Controller)

This module runs a finite state machine that asynchronously processes incoming commands on the UART bus and controls the attached peripherals.

Servo Motor Control: It uses the Servo.h library to generate PWM signals on pins 9 and 10. Movement on the Pan and Tilt axes is implemented discretely, in 5-degree steps, with strict software limitations between the 0° and 90° thresholds to prevent mechanical jamming of the mount.

Display Management (I2C): It uses the LiquidCrystal_I2C library to update the LCD screen. To avoid screen flickering, the updateLCD() function rewrites only the dynamic angle values at fixed coordinates, clearing residual characters by overwriting them with blank spaces.

Data Flow Diagram (UART Protocol)

Remotely transmitted commands are mapped directly onto unique characters (1 Byte), minimizing bus latency:

- U (Up) / D (Down) → Modifies the angle on the Pan axis.

- L (Left) / R (Right) → Modifies the angle on the Tilt axis.

- S (Snapshot) → Remains internal to the ESP32 for writing to the SD card (it is not sent to the ATmega).

Rezultate Obţinute

Concluzii

Bibliografie/Resurse

Datasheets:

* ESP32-CAM: https://www.handsontec.com/dataspecs/module/ESP32-CAM.pdf * ATMega328P-Xmini: https://ww1.microchip.com/downloads/en/devicedoc/50002659a.pdf * OV2640 camera: https://www.uctronics.com/download/cam_module/OV2640DS.pdf?srsltid=AfmBOoo3vdFbGk7ETYZYiuJ8k7jHcNlunSU3DsBpVrOuNQln2gw7Lgb2 * SG90 servo: https://www.friendlywire.com/projects/ne555-servo-safe/SG90-datasheet.pdf * QAPASS LCD: https://mm.digikey.com/Volume0/opasdata/d220001/medias/docus/5773/CN0295D%20other%20related%20document.pdf