Pressure

Pressure

Device Compatibility

Overview

The pressure sensor reports values for:

  • Pressure
  • Altitude
  • Temperature

Based on component location, the temperature values from the humidity sensor are recommended over the pressure sensor.

References

Below is the overview of the pressure sensor implementation. Code example can be found here.

These header files are required to use the pressure sensor.

// Interfaces with pressure sensor
#include "matrix_hal/pressure_sensor.h"
// Holds data from pressure sensor
#include "matrix_hal/pressure_data.h"
// Communicates with MATRIX device
#include "matrix_hal/matrixio_bus.h"
PressureData

PressureData is a required object that contains the pressure sensor's supported data parameters.

// Create PressureData object
matrix_hal::PressureData pressure_data;

The following code accesses the parameters of PressureData.

// Output is represented in meters
float altitude = pressure_data.altitude;
// Output is represented in Pa
float pressure = pressure_data.pressure;
// Output is represented in Celsius
float temperature = pressure_data.temperature;
PressureSensor

PressureSensor is a required object that contains functions to interface with the pressure sensor.

// Create PressureSensor object
matrix_hal::PressureSensor pressure_sensor;
The functions below are part of PressureSensor.

.Setup

Setup is a function that takes a MatrixIOBus object as a parameter and sets that object as the bus to use for communicating with MATRIX device.

// Function declaration in header file
void Setup(MatrixIOBus *bus);
// Set pressure_sensor to use MatrixIOBus bus
pressure_sensor.Setup(&bus);
.Read

Read is a function that takes a PressureData object as a parameter and writes the current pressure sensor data into the PressureData object.

// Function declaration in header file
bool Read(PressureData *data);
// Overwrites pressure_data with new data from pressure sensor
pressure_sensor.Read(&pressure_data);