Skip to content

Software

Charles Zhou edited this page Apr 20, 2023 · 4 revisions

SkyNet Software Overview

Sensors

The onboard transmitter uses the following sensors to gather data:

  • VL53L0X: Time-of-flight sensor
  • BMP388: Pressure sensor
  • LSM6DS33: Accelerometer, gyroscope, and magnetometer

System Architecture

SkyNet consists of two main parts:

  1. Hardware components (onboard transmitter and receiver) written in C++ using standard Arduino practices.
  2. Ground software written in TypeScript using Node.js, Rust, and Tauri.

Dataflow

  1. The transmitter interfaces with sensors via I2C, collects data, and sends the data in a package via LoRa following the specified package format.
  2. The receiver reads the data package, appends the package RSSI, and prints it out via serial.
  3. The ground software reads the serial printout, parses it into a JSON structure, and plots and displays the data.
  [Onboard Transmitter]          [Receiver]             [Ground Software]
         Sensors                   (LoRa)                  (Tauri App)
            |                         |                       |
            v                         v                       v
    +----------------+       +----------------+       +----------------+
    | Interface with |       | Read data      |       | Read serial    |
    | sensors via    |------>| package &      |------>| printout       |
    | I2C & collect  |       | append RSSI    |       |                |
    | data           |       |                |       |                |
    +----------------+       +----------------+       +----------------+
                                         |                       |
                                         v                       v
                                  +----------------+       +----------------+
                                  | Print data     |       | Parse into     |
                                  | package via    |       | JSON structs   |
                                  | serial         |       |                |
                                  +----------------+       +----------------+
                                                                   |
                                                                   v
                                                           +----------------+
                                                           | Plot & display |
                                                           | data           |
                                                           +----------------+

Transmitter Program Logic

The program logic is implemented in the loop function, which executes continuously and performs the following tasks:

  1. Initialize the program and sensors using the setup function.

  2. Check the current state of the transmitter and perform appropriate actions based on the state:

    • IDLE: Check if the rocket should be armed and send sensory states. If an arm command is received, change the state to ARMED.
    • ARMED: Check if the rocket has launched. If launched, change the state to LAUNCHED.
    • LAUNCHED: Gather data from sensors and transmit it wirelessly to the ground station. Check if the rocket has landed. If landed, change the state to RECOVERY.
    • RECOVERY: Send GPS coordinates and wait for recovery.
  3. Wait for a specified amount of time before rerunning the loop.

Data Package

Data, mostly floats, is sent byte by byte using a uint8_t array for the LoRa library to transmit. The transmitted data is then reconstructed back to float. Time-of-flight (ToF) data is the only exception and is uint8_t. The package payload size is 49 bytes.

Raw Package Format:

tof_data,
bmp.temperature,
bmp.pressure,
bmp.readAltitude(SEALEVELPRESSURE_HPA),
accel_event.acceleration.x,
accel_event.acceleration.y,
accel_event.acceleration.z,
gyro_event.gyro.x,
gyro_event.gyro.y,
gyro_event.gyro.z,
mag_event.magnetic.x,
mag_event.magnetic.y,
mag_event.magnetic.z

Receiver Addition (Appended to Serial):

Package RSSI