The main firmware of the onboard computer runs on an ESP32 platform, managing sensors, communication and parachute control during flight.
- firmware.ino - Main code with setup and loop
setup() // Initialization of all components
├── setupLittleFS() // File system
├── setupBMP() // Pressure sensor
├── setupMPU() // IMU
├── setupLoRa() // Communication
└── setupServo() // Servo motor
loop() // Continuous execution
├── readSensors() // Data collection
├── handleParachute() // Parachute control
├── logData() // Storage
└── sendLoRa() // Transmission
Function: Measure altitude and atmospheric pressure
Libraries:
Adafruit_BMP280Wire(I2C)
Collected Data:
- Relative altitude (m)
- Pressure (hPa)
- Base pressure (calibrated at setup)
Test Code: test/basico/basico.ino
Related Variables:
float base_altitude // Initial altitude (reference)
float base_pressure // Base pressure (hPa)
float previous_altitude // Previous height (for velocity calculation)
float max_altitude // Maximum height reachedFunction: Measure acceleration and rotation (flight dynamics data)
Libraries:
Adafruit_MPU6050Adafruit_SensorWire(I2C)
Collected Data:
- Acceleration in X, Y, Z (m/s²)
- Angular velocity in X, Y, Z (rad/s)
- Sensor temperature (°C)
Related Variables:
sensors_event_t acc, gyr, temp // Acceleration, gyroscope and temperature eventsFunction: Get latitude, longitude, GPS altitude and time
Libraries:
TinyGPS++- Serial UART communication
Communication Pins:
- RX_GPS: Pin 20 (receives data from GPS)
- TX_GPS: Pin 21 (sends data to GPS)
Collected Data:
- Latitude (°)
- Longitude (°)
- GPS Altitude (m)
- Number of satellites
- Date and time UTC
Features:
- Waits 3 seconds in setup for synchronization
- Uses GPS time to name log file
Function: Long-range wireless communication with the base
Frequency: 868 MHz
Libraries:
LoRaSPI
Communication Pins:
- SS_LORA: Pin 7 (Chip Select)
- RST_LORA: Pin 1 (Reset)
- DIO0_LORA: Pin 2 (Interrupt)
Configuration:
#define LORA_FREQ 868E6 // Frequency
#define SYNC_WORD 0xF3 // Sync codeTransmitted Data: Concatenated string with data from all sensors in CSV format
Function: Open parachute at appropriate altitude
Pin: SERVO_PIN = 3
Positions:
- MAXPOS = 0° (Parachute closed)
- MINPOS = 90° (Parachute open)
Opening Criteria:
const float ALTITUDE_THRESHOLD = 750.0 // Minimum height (m)
const float ALTITUDE_DROP_THRESHOLD = 10.0 // Minimum drop from peak (m)
const float VELOCITY_THRESHOLD = 80.0 // Descent velocity minimum (m/s)Control Function: handleParachute()
Function: Indicate initialization status and operation
Pin: BUZZER_PIN = 0
Signals:
- Alert: Multiple short beeps (initialization failure)
- Success: Beep sequence (components started correctly)
Control Function: buzzSignal()
Function: Store telemetry data in real time
File Format: CSV
File Name:
- If GPS is synchronized:
HH_MM_SS-Dados.csv(GPS time) - If GPS not synchronized:
{millis}-Dados.csv
CSV Header:
ID,Packet,Time,Latitude,Longitude,GPS_Altitude,Satellites,Date,Hours,Minutes,Seconds,
BMP_Altitude,Pressure,AccX,AccY,AccZ,GyroX,GyroY,GyroZ,Temp,ParachuteStatusFile Functions:
setupLittleFS()- Initializes the systemwriteFile()- Creates new file with headerappendFile()- Adds line to file
- Baud Rate: 115200
- Use: Debug and real-time monitoring
- Range: Up to ~4 km (in open field)
- Data Rate: ~1-5 kbps
- Frequency: 868 MHz
Functionality: Asynchronous server on port 80
Endpoints:
GET /- Home page (HTML)GET /api/files- List files in JSONGET /api/file?name=- Download fileDELETE /api/file?name=- Delete file
Libraries:
ESPAsyncWebServerWiFiArduinoJson
#define INTERVAL 200 // Reading interval (ms)
const float ALTITUDE_THRESHOLD = 750.0 // Minimum height for parachute (m)
const float ALTITUDE_DROP_THRESHOLD = 10.0 // Drop from reference (m)
const float VELOCITY_THRESHOLD = 80.0 // Descent velocity minimum (m/s)
const String TEAM_ID = "#100" // Team ID-
Initialization (setup)
- Configure serial communication
- Initialize I2C and SPI
- Wait for GPS synchronization (3s)
- Create log file
- Initialize sensors and modules
- Start web server
-
Main Loop
- Check 200ms interval
- Read altitude and IMU
- Calculate descent velocity
- Check parachute opening criteria
- Record data in file
- Transmit via LoRa
-
Parachute Control
- Wait for minimum height
- Monitor drop relative to peak
- Check descent velocity
- Open servo when all criteria are met
The files in extras/ contain functional and tested code for reference:
- extras/ino_files/ - Earlier versions of integrated code
- extras/FileBrowser/FileBrowser.ino - File browser, base for async server
- extras/LoraReceiver/LoraReceiver.ino - LoRa receiver for base
- extras/Serial/Serial.py - Python script for serial monitoring
Unit tests are located in test/:
- test/basico/basico.ino - Basic initialization test
- test/buzzer/buzzer.ino - Buzzer test
- test/lora/lora.ino - LoRa communication test
- test/testeGPS/testeGPS.ino - GPS module test
- test/servo/servo.ino - Servo motor test
- test/LittleFS/LittleFS.ino - File system test
| Library | Version | Use |
|---|---|---|
| Adafruit BMP280 | Latest | Pressure sensor |
| Adafruit MPU6050 | Latest | IMU |
| Adafruit Sensor | Latest | Sensor base |
| TinyGPS++ | Latest | GPS decoding |
| LoRa | Latest | LoRa module |
| ESP32Servo | Latest | Servo control |
| ArduinoJson | ^6.0 | JSON serialization |
| ESPAsyncWebServer | Latest | Web server |
- Synchronization: The system waits for GPS synchronization before flight starts
- Redundancy: The parachute uses multiple criteria to prevent incorrect opening
- Logging: All data is stored locally before transmission via LoRa
- Power Efficiency: The ESP32 operates in continuous mode during flight