Humidity

Humidity

Device Compatibility

Overview

The humidity sensor reports values for:

  • Humidity
  • Temperature

References

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

These header files are required to use the humidity sensor.

// Interfaces with humidity sensor
#include "matrix_hal/humidity_sensor.h"
// Holds data from humidity sensor
#include "matrix_hal/humidity_data.h"
// Communicates with MATRIX device
#include "matrix_hal/matrixio_bus.h"
HumidityData

HumidityData is a required object that contains the humidity sensor's supported data parameters.

// Create HumidityData object
matrix_hal::HumidityData humidity_data;

The following code accesses the parameters of HumidityData.

// Output is represented in %
float humidity = humidity_data.humidity; 
// Output is represented in Celsius
float temperature = humidity_data.temperature; 
HumiditySensor

HumiditySensor is a required object that contains functions to interface with the humidity sensor.

// Create HumiditySensor object
matrix_hal::HumiditySensor humidity_sensor;
The functions below are part of HumiditySensor.

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 humidity_sensor to use MatrixIOBus bus
humidity_sensor.Setup(&bus);
.Read

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

// Function declaration in header file
bool Read(HumidityData *data);
// Overwrites humidity_data with new data from humidity sensor
humidity_sensor.Read(&humidity_data);