Skip to content

๐Ÿ›ฉ๏ธ Advanced ESP32 dual-core flight control system with LoRa communication, OLED display, and PS5 controller support for RC aircraft. Features real-time servo control, safety systems, and precision flight management.

License

Notifications You must be signed in to change notification settings

Arsalan134/Airplane

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

94 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ฉ๏ธ ESP32 Dual-Core Airplane Control System โœˆ๏ธ

ESP32 PlatformIO License

๐Ÿš€ Advanced dual-core flight control system built for ESP32, featuring real-time LoRa communication, OLED display, and precision servo control for RC aircraft.


๐ŸŒŸ Features

๐ŸŽฏ Core Capabilities

  • โšก Dual-Core Architecture - Dedicated cores for flight control and communication
  • ๐Ÿ“ก LoRa Communication - Long-range wireless control with packet validation
  • ๐Ÿ–ฅ๏ธ OLED Display - Real-time flight data visualization
  • ๐ŸŽฎ PS5 Controller Support - Wireless controller integration
  • ๐Ÿ›ก๏ธ Safety Systems - Connection timeout and emergency procedures
  • ๐Ÿ”ง Advanced Trim Control - Precise flight surface adjustments

๐Ÿ›ฉ๏ธ Flight Control

  • โšก Engine/Throttle Control (0-100%)
  • ๐ŸŽฏ Rudder Control (ยฑ30ยฐ freedom)
  • โฌ†๏ธโฌ‡๏ธ Elevator Control (Full range)
  • ๐Ÿ›ฉ๏ธ Aileron Control (Dual servo setup)
  • ๐Ÿชถ Flap Control (0-4 positions)
  • ๐Ÿ›‘ Emergency Airbrake

๐ŸŽ›๏ธ Flight Modes

  • ๐ŸŽฎ Manual Mode - Direct pilot control
  • ๐Ÿ“ Stability Mode - Computer-assisted stabilization
  • ๐ŸŽข Acrobatic Mode - High-performance maneuvers
  • ๐Ÿ›ฌ Landing Mode - Automated landing assistance

๐Ÿ”ง Hardware Requirements

๐Ÿ“Ÿ Main Controller

  • ๐ŸŽฏ ESP32-PICO-D4 (Revision v1.1)
    • โšก Dual Core 240MHz
    • ๐Ÿ“ถ WiFi + ๐Ÿ“ฑ Bluetooth
    • ๐Ÿ’พ Embedded Flash
    • ๐Ÿ”ฎ 40MHz Crystal

๐Ÿ“ก Communication

  • LoRa Module - Long range control
  • OLED Display (SSD1306, I2C) - Status monitoring
  • PS5 Controller (Bluetooth) - Primary input

๐Ÿš€ Getting Started

๐Ÿ“‹ Prerequisites

# Install PlatformIO Core
pip install platformio

# Or use PlatformIO IDE extension in VS Code

โฌ‡๏ธ Installation

  1. Clone the repository

    git clone https://github.com/Arsalan134/Airplane.git
    cd Airplane
  2. Build the project

    pio build
  3. Upload to ESP32

    pio upload
  4. Monitor serial output

    pio device monitor

๐Ÿ—๏ธ Project Structure

๐Ÿ“ Airplane/
โ”œโ”€โ”€ ๐Ÿ“„ LICENSE                         # ๐Ÿ“ MIT License file
โ”œโ”€โ”€ ๐Ÿ“„ platformio.ini                  # ๐Ÿ”ง PlatformIO configuration
โ”œโ”€โ”€ ๏ฟฝ README.md                       # ๐Ÿ“š This comprehensive documentation
โ”œโ”€โ”€ ๐Ÿ“„ README_DUAL_CORE.md             # ๐Ÿ—๏ธ Dual-core implementation details
โ”œโ”€โ”€ ๐Ÿ“‚ include/                        # ๐Ÿ“‚ Header files directory
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Airplane.h                  # ๐Ÿ›ฉ๏ธ Aircraft class definition
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ common.h                    # ๐Ÿ”— Shared definitions and pin config
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Display.h                   # ๐Ÿ“บ Display interface and prototypes
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ images.h                    # ๐Ÿ–ผ๏ธ OLED graphics and icons
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ main.h                      # ๐Ÿ”ง Main header includes
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ SD-Card.h                   # ๐Ÿ’พ Storage definitions
โ”œโ”€โ”€ ๐Ÿ“‚ src/                           # ๏ฟฝ Source code directory
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ main.cpp                    # ๏ฟฝ๐Ÿš€ Main dual-core setup and control loop
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Airplane.cpp               # โœˆ๏ธ Flight control logic and servo management
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Display.cpp                # ๏ฟฝ๏ธ OLED display functions and UI
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Lora.cpp                   # ๏ฟฝ LoRa communication and protocol handling
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ SD-Card.cpp                # ๐Ÿ’พ Data logging functionality
โ””โ”€โ”€ ๐Ÿ“‚ test/                          # ๐Ÿ“‚ Unit tests directory
    โ”œโ”€โ”€ ๏ฟฝ README                      # ๐Ÿ“š Test documentation
    โ”œโ”€โ”€ ๐Ÿ“‚ test_airplane/              # โœˆ๏ธ Aircraft control tests
    โ”‚   โ””โ”€โ”€ ๐Ÿ“„ test_airplane.cpp       # ๐Ÿงช Aircraft functionality unit tests
    โ”œโ”€โ”€ ๐Ÿ“‚ test_lora/                  # ๐Ÿ“ก LoRa communication tests
    โ”‚   โ””โ”€โ”€ ๐Ÿ“„ test_lora.cpp           # ๐Ÿงช LoRa protocol unit tests
    โ”œโ”€โ”€ ๏ฟฝ test_main/                  # ๏ฟฝ Main functionality tests
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ test_main.cpp           # ๐Ÿงช Main system integration tests
    โ”‚   โ””โ”€โ”€ ๐Ÿ“„ test_main_simple.cpp    # ๐Ÿงช Simplified main function tests
    โ””โ”€โ”€ ๐Ÿ“‚ test_safety/                # ๏ฟฝ๏ธ Safety system tests
        โ””โ”€โ”€ ๐Ÿ“„ test_safety.cpp         # ๐Ÿงช Safety feature validation tests

๐Ÿ“‹ Key Files Description

๏ฟฝ Core System Files

  • main.cpp: Dual-core task implementation with FreeRTOS scheduling
  • common.h: Shared definitions, pin configurations, and system constants
  • main.h: Function declarations and system-wide includes

โœˆ๏ธ Flight Control System

  • Airplane.cpp/.h: Complete aircraft control logic, servo management, and flight algorithms
  • Display.cpp/.h: OLED display management with real-time flight data visualization
  • images.h: Graphics definitions, icons, and display assets

๏ฟฝ Communication System

  • Lora.cpp: LoRa communication protocol, packet handling, and error recovery
  • SD-Card.cpp/.h: Data logging system for flight data recording

๐Ÿงช Testing Framework

  • test/: Comprehensive unit testing suite with dedicated test categories
    • test_airplane/: Aircraft-specific functionality tests
    • test_lora/: LoRa communication and protocol tests
    • test_main/: Core system and integration tests
    • test_safety/: Critical safety system validation tests

๐Ÿ“š Documentation & Configuration

  • README.md: This comprehensive project documentation
  • README_DUAL_CORE.md: Detailed dual-core architecture implementation guide
  • platformio.ini: Build configuration with dual-core optimization flags
  • LICENSE: MIT License terms and conditions

๐Ÿ“ก Communication Protocol

The system uses a custom LoRa protocol with the following data structure:

๐Ÿ“ฆ Packet Format

e[engine]a[aileron]r[rudder]l[elevator]t[trim]i[aileron_trim]f[flaps]z[reset_aileron]y[reset_elevator]b[airbrake]#[checksum]

๐ŸŽ›๏ธ Control Mapping

Command Range Description Emoji
e 0-180 Engine throttle โšก
a 0-180 Aileron position (90=center) ๐Ÿ›ฉ๏ธ
r 0-180 Rudder position (90=center) ๐ŸŽฏ
l 0-180 Elevator position (90=center) โฌ†๏ธโฌ‡๏ธ
t -1,0,1 Elevator trim adjustment ๐Ÿ”ง
i -1,0,1 Aileron trim adjustment ๐Ÿ”ง
f 0-4 Flap position ๐Ÿชถ
z 0-1 Reset aileron trim ๐Ÿ”„
y 0-1 Reset elevator trim ๐Ÿ”„
b 0-1 Airbrake activation ๐Ÿ›‘

๐Ÿ” Safety Features

  • โœ… XOR Checksum - Packet integrity verification
  • โฑ๏ธ Connection Timeout - 2 second failsafe
  • ๐Ÿšจ Emergency Procedures - Auto-safe mode on signal loss
  • ๐Ÿ”’ Packet Validation - Malformed packet rejection

๐Ÿ–ฅ๏ธ Display Interface

The OLED display shows real-time flight data:

๐Ÿ“Š Status Information

  • ๐ŸŽฏ Aileron position
  • โฌ†๏ธโฌ‡๏ธ Elevator position
  • ๐ŸŽฏ Rudder position
  • ๐Ÿ”ง Trim values (elevator & aileron)
  • ๐Ÿ“ถ Signal strength (RSSI)
  • โฑ๏ธ Last packet time
  • โšก Engine power percentage
  • ๐Ÿชถ Flap position
  • ๐Ÿ‘จโ€โœˆ๏ธ Pilot identification

โšก Dual-Core Architecture

๐ŸŽฏ Core 1 - Flight Control (High Priority)

  • ๐Ÿ›ฉ๏ธ Real-time servo control
  • ๐Ÿšจ Emergency safety systems
  • ๐Ÿ“Š Performance monitoring
  • ๐Ÿ”„ 100Hz update rate

๐Ÿ“ก Core 0 - Communication (Lower Priority)

  • ๐Ÿ“ป LoRa packet handling
  • ๐Ÿ–ฅ๏ธ Display updates
  • ๐Ÿ“ฑ Bluetooth management
  • ๐Ÿ”„ 50Hz update rate

๐Ÿ›ก๏ธ Safety Systems

๐Ÿšจ Emergency Procedures

  1. Connection Loss - Automatic safe mode activation
  2. Invalid Packets - Ignore corrupted data
  3. Hardware Timeout - Servo centering
  4. Memory Protection - Mutex-based data sharing

๐Ÿ”ง Failsafe Defaults

  • โšก Engine: 0% (Motor off)
  • ๐Ÿ›ฉ๏ธ All control surfaces: Center position (90ยฐ)
  • ๐Ÿ“ Flight mode: Stability mode
  • ๐Ÿ›‘ Airbrakes: Deactivated

๐Ÿ“ˆ Performance Monitoring

The system provides real-time performance metrics:

  • ๐Ÿ”„ Update Frequencies - Per-core execution rates
  • ๐Ÿ’พ Memory Usage - Heap and stack monitoring
  • โฑ๏ธ Task Timing - Microsecond precision logging
  • ๐Ÿ“Š Communication Stats - Packet success rates

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒŸ Create a feature branch (git checkout -b feature/amazing-feature)
  3. ๐Ÿ’พ Commit your changes (git commit -m 'โœจ Add amazing feature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/amazing-feature)
  5. ๐Ÿ”ƒ Open a Pull Request

๐ŸŽฏ Areas for Contribution

  • ๐Ÿ“ฑ Mobile app development
  • ๐Ÿงช Unit testing
  • ๐Ÿ“š Documentation improvements
  • ๐Ÿ”ง Hardware integration
  • ๐Ÿ›ฉ๏ธ Flight algorithms

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ‘จโ€๐Ÿ’ป Author

๐Ÿ›ฉ๏ธ Arsalan Iravani


๐Ÿ™ Acknowledgments

  • ๐Ÿš€ ESP32 Community - For excellent hardware support
  • ๐Ÿ“ก LoRa Alliance - For long-range communication standards
  • ๐ŸŽฎ Gaming Community - For PS5 controller integration inspiration
  • โœˆ๏ธ RC Aviation Community - For flight control insights

๐Ÿ“Š Project Stats

  • ๐Ÿ—“๏ธ Started: 2024
  • ๐Ÿ’ป Language: C++ (Arduino Framework)
  • ๐ŸŽฏ Target: ESP32-PICO-D4
  • ๐Ÿ“ฆ Dependencies: PlatformIO, Arduino, LoRa
  • ๐Ÿท๏ธ Version: 1.0.0

๐Ÿ›ฉ๏ธ Ready for Takeoff! โœˆ๏ธ

Built with โค๏ธ for the RC aviation community

โญ Star this repository if you found it helpful!

About

๐Ÿ›ฉ๏ธ Advanced ESP32 dual-core flight control system with LoRa communication, OLED display, and PS5 controller support for RC aircraft. Features real-time servo control, safety systems, and precision flight management.

Topics

Resources

License

Stars

Watchers

Forks