MRAS
Multi Rocket Avionics System
Loading...
Searching...
No Matches
Sensor_MS5607 Class Reference

#include <Sensor_MS5607.h>

Inheritance diagram for Sensor_MS5607:
Inheritance graph
Collaboration diagram for Sensor_MS5607:
Collaboration graph

Public Member Functions

 Sensor_MS5607 (uint8_t id, byte i2c_address, TwoWire &i2c_bus, uint32_t frequency)
 
int8_t setup () override
 
int8_t loop () override
 
- Public Member Functions inherited from Subsystem
virtual const char * get_name ()=0
 
virtual int8_t setup ()=0
 
virtual int8_t loop ()=0
 
uint8_t get_id () const
 
int8_t get_status () const
 
int8_t self_test () const
 
bool add_subscriber (Subsystem *subscriber)
 
 Subsystem (uint8_t id)
 

Additional Inherited Members

- Protected Member Functions inherited from Subsystem
void log (const char fmt[],...)
 
virtual void on_message (SystemMessage *msg)=0
 
void publish (SystemMessage *msg)
 
- Static Protected Member Functions inherited from Subsystem
static void buzzer (uint16_t frequency, uint32_t duration, bool block=false)
 
- Protected Attributes inherited from Subsystem
int8_t status = 0
 
int8_t self_test_result = -1
 

Detailed Description

Sensor_MS5607 class is a C++ driver for the MS5607 barometric pressure sensor. It is a child class of the Subsystem base class and is responsible for communicating with the sensor over I2C, reading and interpreting the sensor's data, and providing that data to the system.

High-level Overview:

The setup() method initializes the I2C bus and reads the sensor's calibration coefficients from its PROM (Programmable Read-Only Memory). It returns 0 on success and a non-zero value on failure.

The loop() method reads pressure and temperature data from the sensor. It uses a finite state machine to control the timing of the pressure and temperature measurements. It returns different status codes depending on the state of the sensor and the outcome of the measurements.

The class has several private variables, such as the i2c address of the sensor, the i2c bus object, and the sensor's calibration coefficients. It also has several private constants, such as the OSR (Oversampling Ratio), which determines the resolution of the sensor's measurements, and the CONV_D1, CONV_D2, and CONV_Delay constants, which determine the timing of the pressure and temperature measurements.

Step by step process for how data is read from the sensor:

  1. In the setup() method, the I2C bus is initialized and the read_PROM() method is called to read the sensor's calibration coefficients from its PROM.
  2. In the loop() method, a switch case statement is used to determine the current state of the sensor, and based on that, the appropriate action is taken.
  3. If the state is IDLE, a command is sent to the sensor to start converting pressure measurement.
  4. After sending the command, the state is set to READING_PRESSURE and the time at which the state was changed is recorded.
  5. The program then waits for the conversion delay.
  6. After the delay, the read_ADC() method is called to read the digital value of the pressure measurement from the sensor's ADC (Analog-to-Digital Converter).
  7. If the reading is successful, the state is changed to READING_TEMPERATURE and a similar process is followed to read the temperature measurement.
  8. The read values are then used to calculate the temperature and pressure using the sensor's calibration coefficients and a mathematical formula, taking into account the sensor's OSR value.

Member Function Documentation

◆ loop()

int8_t Sensor_MS5607::loop ( )
overridevirtual

Implements Subsystem.

◆ setup()

int8_t Sensor_MS5607::setup ( )
overridevirtual

Implements Subsystem.


The documentation for this class was generated from the following files: