This repository contains the complete flight software for a dual ESP32-based CanSat mission system designed for the IN-SPACe CANSAT India Student Competition 2024-25.
The CanSat consists of two ESP32 DevKit boards working in tandem:
- Role: Main flight computer handling sensors, data logging, and flight state management
- Location:
/primary/directory - Key Functions:
- GPS tracking and navigation
- Altitude and pressure monitoring (BMP280)
- Motion detection (MPU6050 accelerometer/gyroscope)
- SD card data logging
- Battery voltage monitoring
- Flight state management
- UART communication coordination
- Role: Local sensor data collection and LoRa telemetry transmission
- Location:
/secondary/directory - Key Functions:
- High-precision altitude sensing (BMP390)
- LoRa long-range data transmission
- Servo control for deployment mechanisms
- Real-time telemetry relay
- Backup sensor data collection
- ESP32 DevKit (30 pins)
- GPS NEO-6M module
- BMP280 pressure/temperature sensor
- MPU6050 accelerometer/gyroscope
- MicroSD card module
- Buzzer and LED indicators
- Battery voltage monitoring circuit
- ESP32 DevKit (30 pins)
- LoRa SX1278 433MHz module
- BMP390 high-precision pressure sensor
- Servo motor for deployment
- LED status indicators
- Primary ESP32 collects onboard sensor data (GPS, BMP280, MPU6050, battery)
- Primary requests additional sensor data from Secondary via UART
- Secondary responds with BMP390, servo status, and PID data
- Primary consolidates all data into CSV format and logs to SD card
- Primary sends consolidated telemetry back to Secondary
- Secondary transmits telemetry via LoRa to ground station
- PlatformIO IDE or PlatformIO Core
- ESP32 DevKit boards (2x)
- Required sensors and components (see hardware lists above)
-
Clone this repository:
git clone https://github.com/JayZ6969/cansat cd cansat -
Open each project in PlatformIO:
- Primary: Open
/primary/folder - Secondary: Open
/secondary/folder
- Primary: Open
-
Install dependencies (automatically handled by PlatformIO):
# For primary cd primary pio lib install # For secondary cd secondary pio lib install
cd primary
pio run # Build
pio run --target upload # Upload to ESP32
pio device monitor # Monitor serial outputcd secondary
pio run # Build
pio run --target upload # Upload to ESP32
pio device monitor # Monitor serial output- GPS: UART2 (GPIO16-RX, GPIO17-TX)
- I2C Sensors: GPIO21-SDA, GPIO22-SCL
- SD Card: SPI (GPIO23-MOSI, GPIO19-MISO, GPIO18-SCK, GPIO5-CS)
- Battery Monitor: GPIO36 (ADC)
- LEDs: GPIO12 (RED), GPIO13 (YELLOW), GPIO14 (GREEN)
- Buzzer: GPIO0
- LoRa SX1278: SPI (GPIO18-SCK, GPIO19-MISO, GPIO23-MOSI, GPIO5-SS, GPIO4-RST, GPIO26-DIO0)
- BMP390: I2C (default pins)
- Servo: GPIO25
- UART2: GPIO16-RX, GPIO17-TX (Primary communication)
- LEDs: GPIO2, GPIO13
The system manages the following flight states:
- BOOT (0): Initialization and system checks
- TEST_MODE (1): Pre-flight testing and calibration
- LAUNCH_PAD (2): Ready for launch
- ASCENDING (3): Active flight phase
- DESCENDING (4): Parachute deployment phase
- LANDED (5): Post-landing data collection
Telemetry data is stored and transmitted in CSV format:
TEAM_ID, TIMESTAMP, PACKET_COUNT, ALTITUDE, PRESSURE, TEMP, VOLTAGE,
GNSS_TIME, GNSS_LAT, GNSS_LONG, GNSS_ALT, GNSS_SATS,
ACCEL_X, ACCEL_Y, ACCEL_Z, GYRO_X, GYRO_Y, GYRO_Z,
GYRO_SPIN_RATE, FLIGHT_STATE, OPTIONAL_DATA
- SD Card not detected: Check wiring and card formatting (FAT32)
- GPS not acquiring lock: Ensure clear sky view and proper antenna connection
- LoRa transmission fails: Verify antenna connection and frequency settings
Primary ESP32:
- Red LED: Boot state indicator
- Yellow LED: GPS lock status (on = no lock)
- Green LED: System OK + data operation blinks
Secondary ESP32:
- GPIO2 LED: Initialization/data reception indicator
- GPIO13 LED: LoRa status/error indicator
This project is licensed under the MIT License - see the LICENSE file for details.
This project is developed for educational purposes as part of the IN-SPACe CANSAT India Student Competition 2024-25.
Competition: IN-SPACe CANSAT India Student Competition 2024-25 (2nd Edition)
Team: AVINYA
Date: 2024-25 Academic Year