All Projects
CompletedEmbeddedHardwareAutonomous Systems2024-02-01

Embedded & Autonomous Drone System

Hardware integration and telemetry processing platform linking a Raspberry Pi companion computer with a flight controller, camera module, and sensor telemetry.

Raspberry PiPythonC/C++UART/SerialSensorsMAVLink

Overview

This project explored hardware-level embedded system integration by pairing a companion computer (Raspberry Pi) with an onboard flight controller on a quadcopter frame. The objective was to capture sensor telemetry, process live video input, and exchange control commands reliably over serial interfaces.

Goal

Build an integrated embedded prototype to:

  • Establish reliable serial telemetry communication between a Raspberry Pi companion computer and a flight controller.
  • Read and parse real-time sensor streams (altitude, orientation, GPS coordinates, battery voltage).
  • Capture and process video frames from an onboard CSI camera module.
  • Implement safety boundaries and fail-safe monitoring for signal loss.

Hardware Stack

  • Companion Computer: Raspberry Pi 4 Model B (handling high-level logic, camera capture, and network communication).
  • Flight Controller: Pixhawk / ArduPilot-compatible STM32-based controller (managing real-time motor PID loops, gyroscopes, and accelerometers).
  • Sensors:
    • IMU (6-axis gyro/accelerometer).
    • Barometric pressure sensor (altitude estimation).
    • External compass and U-blox NEO-6M GPS module.
  • Camera: Raspberry Pi Camera Module v2 (connected via 15-pin ribbon CSI port).
  • Power System: 3S LiPo battery with 5V/3A UBEC power regulator dedicated to the Raspberry Pi to avoid brownouts.

System Architecture & Data Flow

[ Ground Station / Laptop ]
            |
            | Wi-Fi Telemetry Stream (UDP / SSH)
            v
+-------------------------------------------------------------+
|             Raspberry Pi Companion Computer                 |
|                                                             |
|  +--------------------+             +--------------------+  |
|  | Python Companion   |<--- CSI ----| Pi Camera Module   |  |
|  | Telemetry Script   |             | (Video Capture)    |  |
|  +---------+----------+             +--------------------+  |
|            |                                                |
|            | UART Serial (MAVLink protocol @ 57600 baud)    |
|            v                                                |
+------------+------------------------------------------------+
             |
             v
+-------------------------------------------------------------+
|             STM32 Flight Controller                         |
|  - Real-time attitude estimation (EKF)                      |
|  - Electronic Speed Controllers (ESCs) & Brushless Motors   |
|  - Fail-safe trigger: Return to Land on signal timeout      |
+-------------------------------------------------------------+

Software Implementation

  1. Serial Communication: Telemetry exchange uses the MAVLink protocol over the Raspberry Pi's hardware UART (/dev/ttyAMA0). A Python daemon using pymavlink listens for heartbeat packets:
python — companion computer telemetry listener
$ python3 telemetry_bridge.py --port /dev/ttyAMA0 --baud 57600
$ [INFO] Connecting to flight controller on /dev/ttyAMA0...
$ [INFO] Heartbeat received from system (type: QUADROTOR, autopilot: ARDUPILOT)
$ [TELEMETRY] Armed: False | Mode: STABILIZE | Battery: 11.8V (86%)
$ [TELEMETRY] Lat: 19.0760 | Lon: 72.8777 | Alt: 1.2m | Satellites: 9
$ [INFO] Camera stream started at 640x480 @ 30fps
  1. Camera Streaming: Captured lightweight video feed using OpenCV and GStreamer, encoding frames to H.264 before transmission to keep CPU utilization under 40% on the Raspberry Pi.

Hardware & Engineering Challenges

1. Power Instability & Undervoltage Crashes

  • Problem: When the motors were throttled up during ground testing, voltage drops on the main battery bus caused the Raspberry Pi to suffer undervoltage resets (the red power LED flashed, and SSH disconnected).
  • Fix: Separated the Raspberry Pi's power rail entirely using an isolated 5V step-down BEC with an added low-ESR capacitor (1000µF) to smooth out voltage ripples from high-current motor transients.

2. UART Level Shifting & Clock Drift

  • Problem: The flight controller telemetry port operated at 5V logic while the Raspberry Pi GPIO pins are strictly 3.3V-tolerant, risking damage to the Pi. Initial direct attempts also resulted in corrupted MAVLink packets due to clock jitter on the software UART.
  • Fix: Added a bi-directional logic level converter between the two boards and mapped the serial port to the Raspberry Pi's hardware UART (PL011 / ttyAMA0) by disabling Bluetooth on that UART in /boot/config.txt.

3. Vibration Interference on IMU

  • Problem: Mechanical vibrations from the motor mount caused severe accelerometer noise, leading to erratic attitude estimates.
  • Fix: Mounted the flight controller on anti-vibration silicone damping foam and balanced motor props manually before testing.

Safety & Fail-Safes

  • Software heartbeat watchdog: If no heartbeat packet is received within 2 seconds, high-level autonomous navigation commands are canceled and control reverts to manual radio override.
  • Hardware fail-safe: Configured low-voltage buzzer alarms and auto-disarm when landed.

Limitations

  • Prototype Level: Built and tested in bench testing and controlled tethered environments; not certified for long-range autonomous missions.
  • Payload & Flight Time: Battery flight duration is limited (approximately 8–10 minutes) due to companion computer power draw and payload weight.

What I Learned

  • Hardware engineering requires strict attention to electrical fundamentals: shared grounds, logic level matching, power decoupling, and EMI separation.
  • How binary communication protocols (MAVLink) pack telemetry into compact packets with checksum verification.
  • Debugging embedded systems with oscilloscopes, multimeters, and serial terminal analyzers.