Sensor Interface
The Sensor
interface in MMFS defines a standard structure for hardware sensor modules such as barometers, GPS units, IMUs, and more. It provides a unified API for initialization, updates, and data reporting. All sensors inherit from the Sensor
base class, which itself inherits from DataReporter
, enabling each sensor to automatically expose its data in a standardized way for logging or telemetry.
Purpose
This interface ensures that all sensor types in MMFS can be:
- Queried consistently (via
update()
) - Initialized uniformly (via
begin()
) - Identified programmatically by type
- Hooked into telemetry/logging systems via inherited
DataReporter
Core Methods
Initialization
Prepares the sensor for use. May involve hardware initialization, I2C/SPI setup, and calibration. Some sensors support optional bias correction at startup.
Update
Fetches new data from the sensor. This function is called periodically (e.g., once per loop) and internally handles reading from the sensor and updating internal data buffers.
Type Identification
Returns the enum or string identifier for the sensor type. Useful for dynamic system configuration, debug messages, or logging.
DataReporter Integration
Because Sensor
inherits from DataReporter
, it can expose internal sensor values to the logging and telemetry system.
To expose a new value:
To remove a value:
The DataReporter
base handles linked list management of these columns, automatic formatting of values, and integration with the Logger.
Bias Correction Controls
Bias Mode Toggle
Determines whether the sensor should continuously zero itself using incoming data (Used before liftoff to prevent long-term drift).
Liftoff Lock-in
Disables any ongoing bias correction. Typically called once the rocket leaves the pad.
Implementing Your Own Sensor
To implement your own sensor, inherit from Sensor
and define the following:
In the constructor, register your output values using the inherited addColumn()
methods.
Example Constructor
SensorType Enum
Use these types to categorize your sensor. If none fit, use OTHER_
.
Summary
- All sensors inherit from
Sensor
, which requiresbegin()
,update()
, and type reporting methods. - Sensors automatically plug into the telemetry/logging system via
DataReporter
. - Bias correction and liftoff control allow for zeroing and stabilization of certain sensors.
- Extending the system with new sensors is easy—just inherit and override.
Written by ChatGPT. May not be fully accurate; verify before flight.