Extend AeroAlign with mixed CoG planning and telemetry base

This commit is contained in:
2026-03-11 23:14:33 +01:00
parent 538c3081bf
commit 56890272a0
28 changed files with 1631 additions and 1332 deletions
+108 -375
View File
@@ -1,441 +1,174 @@
# SkyLogic AeroAlign - Wireless RC Telemetry System
# SkyLogic AeroAlign
**Precision Grounded.**
Wireless RC setup platform for two related jobs:
A low-cost, open-source wireless digital incidence and throw meter system for RC airplane setup. Replaces traditional spirit levels and pendulum meters with precise IMU-based angle measurement.
- AeroAlign: digital incidence, reference-angle and differential measurement
- CoG Scale: center-of-gravity measurement using load cells
---
Both parts are intended to run in the same ESP32 ecosystem and talk to the same Master over ESP-NOW.
## 🎯 Project Status
## Current State
**Phase 4: Differential Measurement (COMPLETE)**
Implemented now:
The MVP is fully functional with advanced differential measurement capabilities:
- Master firmware with WiFi AP, REST API and existing web UI
- IMU Master and IMU Slave support with robust MPU6050 access
- shared telemetry protocol for multiple device types
- UI support for both IMU nodes and future CoG scale nodes
- battery monitoring with optional hide/disable behavior on unsupported Master hardware
-**Master Node Firmware**: WiFi AP, ESP-NOW receiver, IMU driver, web server with REST API
-**Slave Node Firmware**: ESP-NOW transmitter, IMU driver, battery monitoring
-**Web UI**: Three-tab interface with real-time sensor display, calibration, and differential measurement
-**Median Filtering**: ±0.1° accuracy via 10-sample median filter with standard deviation monitoring
-**Hardware Design**: Bill of Materials ($72 for 2-sensor system), wiring diagrams, 3D printable housing specs
-**Development Environment**: PlatformIO configurations for ESP32-C3/ESP32-S3
Prepared but not fully implemented yet:
**Next Steps**: Phase 5 - Multi-node support for 4-6 simultaneous sensors
- dedicated HX711-based CoG scale firmware
- model profiles with support spacing, leading-edge offset and target CoG
- scale calibration workflow in the web UI
---
## ⚡ Quick Start
### For End Users
1. **Flash Firmware**:
```bash
cd firmware/master
pio run --target upload
cd ../slave
pio run --target upload
```
2. **Update Slave Configuration**:
- Connect Master to USB, open serial monitor (115200 baud)
- Note the Master MAC address printed at startup
- Edit `firmware/slave/src/config.h` and replace `master_mac` array
- Reflash Slave firmware
3. **Power On**:
- Power on both Master and Slave nodes
- Connect smartphone to WiFi: **"SkyLogic-AeroAlign"**
- Open browser: **http://192.168.4.1**
4. **Use**:
- Attach sensors to RC model control surfaces
- View real-time angles in web UI
- Calibrate (zero) sensors via web interface
### For Developers
See [specs/001-wireless-rc-telemetry/quickstart.md](specs/001-wireless-rc-telemetry/quickstart.md) for detailed build instructions.
---
## 📋 Features
### Implemented (Phases 1-4: MVP + Differential)
**Core Firmware**:
- ✅ **IMU Driver**: MPU6050 6-axis sensor with complementary filter (±0.5° raw accuracy)
- ✅ **ESP-NOW Protocol**: Low-latency (<20ms) wireless communication between nodes
- ✅ **WiFi Access Point**: Captive portal for smartphone/tablet connection (no internet required)
- ✅ **REST API**: HTTP endpoints for sensor data, calibration, differential, and system status
- ✅ **Calibration**: Zero-point calibration with NVS (Non-Volatile Storage) persistence
- ✅ **Battery Monitoring**: Real-time battery percentage via ADC
- ✅ **Multi-Node Support**: Auto-discovery of up to 8 sensor nodes
**Web UI**:
- ✅ **Real-Time Display**: 10Hz polling with three-tab interface (Sensors, Differential, System)
- ✅ **Calibration Interface**: One-click zero calibration for each sensor
- ✅ **Connection Indicators**: Pulse animation, timeout detection (1000ms)
- ✅ **Battery Warnings**: Visual alerts when <20%
- ✅ **Toast Notifications**: Success/failure feedback
**Differential Measurement**:
- ✅ **Median Filtering**: ±0.1° accuracy via 10-sample circular buffer
- ✅ **Standard Deviation**: Real-time measurement stability indicator
- ✅ **Color-Coded Results**: Green (<0.5°), Yellow (<2.0°), Red (>=2.0°)
- ✅ **EWD Mode**: Wing-to-elevator incidence calculation
- ✅ **Node Pair Selection**: Arbitrary sensor pairs via dropdown
### Planned (Phases 5-8)
- 📅 **Multi-Sensor UI**: 4-6 node simultaneous display with scrollable list
- 📅 **Throw Gauge Mode**: Control surface deflection distance measurement
- 📅 **8-Sensor Grid**: Full aircraft setup (wings, ailerons, elevator, rudder)
- 📅 **Sensor Pairing**: Aileron differential, butterfly mode, multi-wing configurations
- 📅 **Specialized Mounts**: Wing surface clips, hinge line mounts, magnetic quick-attach
---
## 🔧 Hardware Requirements
### Core Components (Per Sensor Node)
| Component | Spec | Price | Source |
|-----------|------|-------|--------|
| ESP32-C3 DevKit | RISC-V 160MHz, WiFi, USB-C | $6.50 | [Amazon](https://amazon.com) |
| MPU6050 IMU | 6-axis (gyro + accel), I2C | $4.50 | [Amazon](https://amazon.com) |
| LiPo Battery | 1S 3.7V 250-400mAh | $8.00 | [Amazon](https://amazon.com) |
| TP4056 Charger | USB-C, overcharge protection | $1.50 | [Amazon](https://amazon.com) |
| HT7333 LDO | 3.3V 250mA regulator | $0.80 | [Amazon](https://amazon.com) |
| **Total per node** | | **~$23** | |
**2-Sensor System**: ~$72 (Master + Slave)
**4-Sensor System**: ~$145
**8-Sensor System**: ~$289
See [hardware/schematics/bom.csv](hardware/schematics/bom.csv) for complete Bill of Materials.
### 3D Printed Parts
- Sensor housing (38mm × 28mm × 18mm)
- Control surface clips (3mm, 5mm, 8mm variants)
- Wing surface mounts (Phase 8)
See [hardware/cad/README.md](hardware/cad/README.md) for STL files and print settings.
---
## 📐 Architecture
### System Overview
## Architecture
```
Master Node (WiFi AP + Web Server + ESP-NOW Receiver)
↑ WiFi (HTTP/JSON)
Smartphone/Tablet (Web UI)
Master Node
↑ ESP-NOW (2.4GHz)
Slave Node(s) (0x02-0x09)
IMU Slave(s) ------\
\
CoG Scale Node(s) ----> Master ESP32 ----> WiFi AP ----> Browser UI
/
Master local IMU --/
```
### Master Node Responsibilities
### Device roles
1. **WiFi Access Point**: Hosts "SkyLogic-AeroAlign" network (192.168.4.1)
2. **Web Server**: Serves React UI and REST API endpoints
3. **ESP-NOW Receiver**: Accepts sensor data from Slave nodes (10Hz)
4. **IMU Sensor**: Measures Master node's own pitch/roll
5. **Calibration Manager**: Stores/loads zero-point offsets (NVS)
- `Master`
- hosts `SkyLogic-AeroAlign`
- receives ESP-NOW telemetry
- serves the web UI and REST API
- can also have its own MPU6050
- `IMU Slave`
- remote angle node
- sends pitch, roll and yaw fields as angle telemetry
- `CoG Scale`
- future load-cell node
- will send front weight, rear weight and computed CoG in the same shared packet
### Slave Node Responsibilities
## Telemetry Protocol
1. **IMU Sensor**: Measures pitch/roll at 100Hz
2. **ESP-NOW Transmitter**: Sends data to Master at 10Hz
3. **Battery Monitoring**: Reports battery percentage
4. **Low Power**: No WiFi AP (only ESP-NOW), extends battery life to 4-5 hours
The shared packet format is defined in [telemetry_protocol.h](/Users/florianklaner/Github/AeroAlign/firmware/common/telemetry_protocol.h).
### Data Flow
Device types currently defined:
1. Slave IMU samples at 100Hz (10ms intervals)
2. Slave transmits ESP-NOW packet to Master at 10Hz (100ms intervals)
3. Master receives packet, validates checksum, updates node data
4. Web UI polls GET /api/nodes every 100ms (10Hz)
5. React UI updates angle displays in real-time
- `DEVICE_TYPE_IMU`
- `DEVICE_TYPE_COG_SCALE`
- `DEVICE_TYPE_HYBRID`
---
For IMU nodes:
## 🌐 API Endpoints
- `pitch`, `roll`, `yaw` are angles
### GET /api/nodes
For CoG scale nodes:
Returns all connected sensor nodes with current angles, battery, RSSI.
- `pitch` => front support weight in grams
- `roll` => rear support weight in grams
- `yaw` => CoG position in millimeters
**Response**:
```json
[
{
"node_id": 1,
"label": "Master",
"pitch": -2.35,
"roll": 0.87,
"yaw": 0.0,
"battery_percent": 85,
"battery_voltage": 3.95,
"rssi": -45,
"is_connected": true,
"last_update_ms": 123456789
},
{
"node_id": 2,
"label": "Sensor 1",
"pitch": -3.12,
"roll": 0.43,
...
}
]
```
## Hardware Overview
### GET /api/differential?node1=1&node2=2
### IMU nodes
Calculates differential angle between two nodes (for EWD measurement).
Use:
**Response**:
```json
{
"node1_id": 1,
"node2_id": 2,
"node1_label": "Wing Root",
"node2_label": "Elevator",
"angle_diff_pitch": 0.77,
"angle_diff_roll": 0.44,
"median_diff": 0.75,
"std_dev": 0.03,
"mode": "EWD"
}
```
- ESP32-C3 or ESP32-S3
- MPU6050
- LiPo, charger and 3.3V supply
- optional battery divider depending on node
### POST /api/calibrate
See [sensor_node_wiring.md](/Users/florianklaner/Github/AeroAlign/hardware/schematics/sensor_node_wiring.md).
Zero-calibrates a sensor node (sets current angle as 0°).
### CoG scale
**Request**:
```json
{
"node_id": 1
}
```
Planned hardware stack:
**Response**:
```json
{
"success": true,
"message": "Node calibrated",
"node_id": 1,
"pitch_offset": -2.35,
"roll_offset": 0.87,
"yaw_offset": 0.0,
"timestamp": 1737590400
}
```
- ESP32-C3 or ESP32-S3
- two HX711 boards
- two load cells
- rigid support spacing and repeatable fixtures
### GET /api/status
See [cog_scale_wiring.md](/Users/florianklaner/Github/AeroAlign/hardware/schematics/cog_scale_wiring.md).
System health and statistics.
### BOM
**Response**:
```json
{
"master_battery_percent": 75,
"master_battery_voltage": 3.85,
"wifi_clients_connected": 1,
"wifi_channel": 6,
"uptime_seconds": 3600,
"esp_now_packets_received": 1200,
"esp_now_packet_loss_rate": 0.02,
"firmware_version": "1.0.0",
"hardware_model": "ESP32-C3",
"free_heap_kb": 280
}
```
The BOM is now maintained as a current component overview instead of placeholder shop links:
---
- [bom.csv](/Users/florianklaner/Github/AeroAlign/hardware/schematics/bom.csv)
## 🛠️ Development
## Firmware Layout
### Project Structure
### Existing
```
ewd-digiflo/
├── firmware/
│ ├── master/ # Master node firmware
│ │ ├── src/
│ │ │ ├── main.cpp # WiFi AP + ESP-NOW + Web Server
│ │ │ ├── imu_driver.cpp/h
│ │ │ ├── espnow_master.cpp/h
│ │ │ ├── calibration.cpp/h
│ │ │ ├── web_server.cpp/h
│ │ │ └── config.h # WiFi SSID, GPIO pins, constants
│ │ ├── data/
│ │ │ └── index.html # React web UI (to be implemented)
│ │ └── platformio.ini
│ │
│ └── slave/ # Slave node firmware
│ ├── src/
│ │ ├── main.cpp # ESP-NOW transmitter + IMU
│ │ ├── imu_driver.cpp/h
│ │ ├── espnow_slave.cpp/h
│ │ └── config.h # Master MAC, node ID
│ └── platformio.ini
├── hardware/
│ ├── cad/ # 3D printable STL files (placeholders)
│ ├── schematics/
│ │ ├── bom.csv # Bill of Materials
│ │ └── sensor_node_wiring.md # Wiring diagrams
│ └── docs/
├── docs/ # End-user documentation
│ ├── quickstart.md # Setup guide
│ ├── calibration.md # Calibration procedures
│ └── troubleshooting.md # Common issues
└── specs/ # Design specifications
└── 001-wireless-rc-telemetry/
├── spec.md # Feature specification
├── plan.md # Implementation plan
├── tasks.md # Task breakdown (86 tasks)
├── data-model.md # Data structures
├── research.md # Component selection
├── quickstart.md # Developer guide
└── contracts/
├── http-api.md # REST API spec
└── espnow-protocol.md # Binary protocol spec
```
- [firmware/master](/Users/florianklaner/Github/AeroAlign/firmware/master)
- [firmware/slave](/Users/florianklaner/Github/AeroAlign/firmware/slave)
- [firmware/common](/Users/florianklaner/Github/AeroAlign/firmware/common)
### Build Instructions
### Planned
**Prerequisites**:
- [PlatformIO](https://platformio.org/) (VS Code extension or CLI)
- Python 3.8+ (for esptool.py)
- Git
- `firmware/cog_slave`
- HX711 reading
- tare and scale calibration
- CoG computation
- ESP-NOW transmission as `DEVICE_TYPE_COG_SCALE`
## Build
Master:
**Build Master Firmware**:
```bash
cd firmware/master
pio run # Compile
pio run --target upload # Flash to ESP32
pio device monitor # View serial output (115200 baud)
pio run
```
**Build Slave Firmware**:
Slave:
```bash
cd firmware/slave
pio run --target upload
pio device monitor
pio run -e esp32-s3
pio run -e slave2-s3
```
**Build All 8 Slave Variants** (Phase 8):
```bash
cd firmware/slave
./build_all_slaves.sh # Compiles slave1-slave8 with different NODE_IDs
```
## Current Configuration Notes
---
### Slave Master MAC
## 📊 Project Progress
The Slave now reads the Master MAC from [config.cpp](/Users/florianklaner/Github/AeroAlign/firmware/slave/src/config.cpp), not `config.h`.
### Completed (32/130 tasks, 25%)
### Master battery monitoring
| Phase | Tasks | Status |
|-------|-------|--------|
| **Phase 1: Setup** | 7/7 | ✅ 100% |
| **Phase 2: Foundational** | 13/13 | ✅ 100% |
| **Phase 3: User Story 1 (MVP)** | 12/12 | ✅ 100% |
| **Phase 4: User Story 2** | 8/8 | ✅ 100% |
| Phase 5: User Story 3 | 0/8 | 📅 Next |
| Phase 6: User Story 4 | 0/7 | 📅 Not Started |
| Phase 7: Polish | 0/31 | 📅 Not Started |
| Phase 8: Multi-Sensor | 0/44 | 📅 Not Started |
On ESP32-S3 Master boards the battery ADC path is optional. If the divider is not fitted, the firmware and UI hide the battery value instead of showing dummy data.
### Next Milestones
## CoG Math
1. **Phase 5 (Multi-Node)**: Complete User Story 3 - 4-6 Sensor Support
- Implement scrollable node list in web UI
- Add node labeling/naming functionality
- Test with 4-6 physical nodes
With front and rear supports spaced by `L`:
2. **Phase 6 (Throw Gauge)**: Control surface throw measurement
- Distance measurement mode
- Min/max deflection tracking
`x_cog_from_front_support = rear_weight / (front_weight + rear_weight) * L`
3. **Phase 7 (Polish)**: Testing and refinement
- Unit tests for all modules
- 3D printing validation
- Comprehensive documentation
If the front support is offset from the wing leading edge:
---
`x_cog_from_leading_edge = support_offset_from_leading_edge + x_cog_from_front_support`
## 🔬 Constitution Compliance
The current design note is in [AEROALIGN_COG_INTEGRATION.md](/Users/florianklaner/Github/AeroAlign/docs/AEROALIGN_COG_INTEGRATION.md).
This project adheres to the [EWD-DigiFlow Constitution](.specify/memory/constitution.md):
## Workflow Plan
### I. Extreme Cost-Efficiency ✅
- All components available on Amazon
- **$72 per 2-sensor system** (vs. GliderThrow $600 for 8 sensors)
- 77% cost savings compared to competitors
The planned operating workflow and the recommended hardware roles are documented in:
### II. 3D Printing Reproducibility ✅
- All parts fit within 200mm × 200mm × 200mm build volume
- Support structures <30% part volume
- Print settings documented for PLA/PETG
- [WORKFLOW_AND_SYSTEM_PLAN.md](/Users/florianklaner/Github/AeroAlign/docs/WORKFLOW_AND_SYSTEM_PLAN.md)
- [AIRCRAFT_PROFILE_MODEL.md](/Users/florianklaner/Github/AeroAlign/docs/AIRCRAFT_PROFILE_MODEL.md)
### III. Lightweight Design ✅
- Each sensor node: ~23g (target: <25g)
- Minimal impact on control surface movement
## 3D Printed Parts
### IV. Software Simplicity (Plug-and-Play) ✅
- No app store submission required (web UI)
- No cloud services or internet needed
- 3-step setup: Power on → Connect WiFi → Open browser
The CAD readme now covers both IMU parts and planned CoG fixtures:
---
- [hardware/cad/README.md](/Users/florianklaner/Github/AeroAlign/hardware/cad/README.md)
## 🤝 Contributing
## Recommended Next Work
Contributions welcome! This is an open-source project for the RC community.
**Areas Needing Help**:
- Web UI design (React components)
- 3D CAD designs (FreeCAD → STL)
- Hardware testing (different 3D printers, IMU calibration)
- Documentation (assembly guides, troubleshooting)
See [specs/001-wireless-rc-telemetry/tasks.md](specs/001-wireless-rc-telemetry/tasks.md) for detailed task breakdown.
---
## 📄 License
**Firmware**: MIT License
**Hardware Designs** (STL, schematics): Creative Commons BY-SA 4.0
---
## 🙏 Acknowledgments
- **Adafruit** for MPU6050 and sensor libraries
- **Espressif** for ESP32 Arduino framework and ESP-NOW protocol
- **RC Community** for feature requests and beta testing
---
## 📞 Support
- **Documentation**: [specs/001-wireless-rc-telemetry/](specs/001-wireless-rc-telemetry/)
- **Issues**: [GitHub Issues](https://github.com/your-org/skylogic-aeroalign/issues)
- **Community**: [RC Groups Forum Thread](https://www.rcgroups.com/forums/showthread.php?12345)
---
*SkyLogic AeroAlign - Precision Grounded.*
1. Add `firmware/cog_slave` with HX711 support.
2. Add tare and calibration endpoints in the Master API.
3. Add a dedicated CoG tab in the web UI.
4. Add aircraft profiles in NVS.
5. Finalize mechanical design for the two support fixtures.