![]() |
SparkFun Air Quality PM1/PM2.5/PM10 Sensor - BMV080
v1.0.0-15-g8f97a54
Library for the SparkFun Air Quality PM1/PM2.5/PM10 Sensor - BMV080r
|
#include <sfDevBMV080.h>
Public Member Functions | |
sfDevBMV080 () | |
Default constructor. More... | |
sfTkError_t | begin (sfTkIBus *theBus=nullptr) |
Begins communication with the BMV080 sensor. More... | |
bool | init (void) |
Initializes the BMV080 sensor. More... | |
bool | driverVersion (uint16_t &major, uint16_t &minor, uint16_t &patch) |
Gets the version information of the BMV080 sensor driver. More... | |
bool | open (void) |
Opens and initializes communication with the BMV080 sensor. More... | |
bool | close (void) |
Closes communication with the BMV080 sensor. More... | |
bool | reset (void) |
Resets the BMV080 sensor to its default state. More... | |
bool | ID (char idOut[kBMV800IDLength]) |
Gets the unique identifier of the BMV080 sensor. More... | |
bool | setMode (uint8_t mode) |
Sets the operational mode of the BMV080 sensor. More... | |
float | PM10 (void) |
Gets the PM10 (particulate matter ≤10 µm) concentration. More... | |
float | PM25 (void) |
Gets the PM2.5 (particulate matter ≤2.5 µm) concentration. More... | |
float | PM1 (void) |
Gets the PM1 (particulate matter ≤1.0 µm) concentration. More... | |
bool | isObstructed () |
Checks if the BMV080 sensor is obstructed. More... | |
void | setSensorValue (bmv080_output_t bmv080_output) |
Internal method to set sensor values from callback. More... | |
bool | readSensor (bmv080_output_t *bmv080_output=nullptr) |
Reads the latest sensor values from the BMV080. More... | |
uint16_t | dutyCyclingPeriod () |
Gets the current duty cycling period setting. More... | |
bool | setDutyCyclingPeriod (uint16_t duty_cycling_period) |
Sets the time interval between measurements in duty cycle mode. More... | |
float | volumetricMassDensity () |
Gets the volumetric mass density setting. More... | |
bool | setVolumetricMassDensity (float volumetric_mass_density) |
Sets the volumetric mass density for particle concentration calculations. More... | |
float | integrationTime () |
Gets the sensor's integration time setting. More... | |
bool | setIntegrationTime (float integration_time) |
Sets the sensor's integration time for measurements. More... | |
uint32_t | distributionId () |
Gets the current distribution ID setting. More... | |
bool | setDistributionId (uint32_t distribution_id) |
Sets the distribution ID for particle size classification. More... | |
bool | doObstructionDetection () |
Gets the obstruction detection setting. More... | |
bool | setDoObstructionDetection (bool do_obstruction_detection) |
Enables or disables the sensor's obstruction detection feature. More... | |
bool | doVibrationFiltering () |
Gets the vibration filtering setting. More... | |
bool | setDoVibrationFiltering (bool do_vibration_filtering) |
Enables or disables vibration filtering. More... | |
uint8_t | measurementAlgorithm () |
Gets the current measurement algorithm setting. More... | |
bool | setMeasurementAlgorithm (uint8_t measurement_algorithm) |
Sets the measurement algorithm for particle analysis. More... | |
Static Public Attributes | |
static const size_t | kBMV800IDLength = 13 |
Length of the BMV080 sensor ID string buffer. More... | |
Protected Attributes | |
sfTkIBus * | _theBus |
|
inline |
Default constructor.
sfTkError_t sfDevBMV080::begin | ( | sfTkIBus * | theBus = nullptr | ) |
Begins communication with the BMV080 sensor.
This method initializes the communication interface with the sensor. It must be called before init() and any other operations with the sensor.
theBus | SparkFun Toolkit bus interface to use for communication. |
bool sfDevBMV080::close | ( | void | ) |
Closes communication with the BMV080 sensor.
uint32_t sfDevBMV080::distributionId | ( | ) |
Gets the current distribution ID setting.
This method returns the distribution ID used by the sensor for particle size classification. The distribution ID affects how particles are categorized into different size bins.
bool sfDevBMV080::doObstructionDetection | ( | ) |
Gets the obstruction detection setting.
This method returns whether the sensor's obstruction detection feature is enabled. When enabled, the sensor will monitor for any blockages in its optical path.
bool sfDevBMV080::doVibrationFiltering | ( | ) |
Gets the vibration filtering setting.
This method returns whether the sensor's vibration filtering feature is enabled. When enabled, the sensor applies algorithms to reduce measurement noise caused by mechanical vibrations.
bool sfDevBMV080::driverVersion | ( | uint16_t & | major, |
uint16_t & | minor, | ||
uint16_t & | patch | ||
) |
Gets the version information of the BMV080 sensor driver.
This method retrieves the vendor-supplied version information for the sensor driver software. The version follows semantic versioning format with major, minor, and patch numbers.
[out] | major | Major version number indicating incompatible API changes |
[out] | minor | Minor version number indicating backwards-compatible functionality |
[out] | patch | Patch version number indicating backwards-compatible bug fixes |
uint16_t sfDevBMV080::dutyCyclingPeriod | ( | ) |
Gets the current duty cycling period setting.
Returns the time interval between measurements when the sensor is in duty cycle mode. This setting has no effect when the sensor is in continuous measurement mode.
bool sfDevBMV080::ID | ( | char | idOut[kBMV800IDLength] | ) |
Gets the unique identifier of the BMV080 sensor.
This method retrieves the sensor's unique identification string. The ID can be used to distinguish between different BMV080 sensors or verify the sensor's authenticity.
[out] | idOut | Buffer to store the sensor's ID string. Must be at least kBMV800IDLength (13) bytes long. |
bool sfDevBMV080::init | ( | void | ) |
Initializes the BMV080 sensor.
This method performs complete initialization of the sensor by:
It must be called after begin() and before attempting any other operations.
float sfDevBMV080::integrationTime | ( | ) |
Gets the sensor's integration time setting.
This method returns the current integration time setting used for particle measurements. The integration time affects the sensor's measurement accuracy and response time.
bool sfDevBMV080::isObstructed | ( | ) |
Checks if the BMV080 sensor is obstructed.
This method returns the obstruction status from the latest sensor reading. An obstruction could be caused by dust, debris, or other particles blocking the sensor's optical path.
uint8_t sfDevBMV080::measurementAlgorithm | ( | ) |
Gets the current measurement algorithm setting.
This method returns the measurement algorithm used by the sensor for particle analysis. Different algorithms can be optimized for specific measurement conditions or particle types.
bool sfDevBMV080::open | ( | void | ) |
Opens and initializes communication with the BMV080 sensor.
This method initializes a new handle for communicating with the sensor. It must be called before attempting to configure or read from the sensor.
float sfDevBMV080::PM1 | ( | void | ) |
Gets the PM1 (particulate matter ≤1.0 µm) concentration.
This method returns the latest PM1 reading from the sensor's internal cache. The value represents the mass concentration of particles with a diameter of 1.0 micrometers or less.
float sfDevBMV080::PM10 | ( | void | ) |
Gets the PM10 (particulate matter ≤10 µm) concentration.
This method returns the latest PM10 reading from the sensor's internal cache. The value represents the mass concentration of particles with a diameter of 10 micrometers or less.
float sfDevBMV080::PM25 | ( | void | ) |
Gets the PM2.5 (particulate matter ≤2.5 µm) concentration.
This method returns the latest PM2.5 reading from the sensor's internal cache. The value represents the mass concentration of particles with a diameter of 2.5 micrometers or less.
bool sfDevBMV080::readSensor | ( | bmv080_output_t * | bmv080_output = nullptr | ) |
Reads the latest sensor values from the BMV080.
This method triggers a sensor reading and updates the internal data cache. If a pointer to a bmv080_output_t struct is provided, it will be populated with the latest sensor values.
[out] | bmv080_output | Optional pointer to a bmv080_output_t struct to store the sensor readings. If nullptr (default), the values are only stored internally. |
bool sfDevBMV080::reset | ( | void | ) |
Resets the BMV080 sensor to its default state.
This method performs a soft reset of the sensor, returning all settings to their default values. The sensor will need to be reconfigured after a reset.
bool sfDevBMV080::setDistributionId | ( | uint32_t | distribution_id | ) |
Sets the distribution ID for particle size classification.
This method configures which particle size distribution model the sensor uses for classifying particles. Different distribution IDs are optimized for different types of particles and environments.
distribution_id | The distribution ID to use for particle classification |
bool sfDevBMV080::setDoObstructionDetection | ( | bool | do_obstruction_detection | ) |
Enables or disables the sensor's obstruction detection feature.
This method controls whether the sensor actively monitors for obstructions in its optical path. When enabled, the sensor will report blockages through the isObstructed() method.
do_obstruction_detection | true to enable obstruction detection, false to disable it |
bool sfDevBMV080::setDoVibrationFiltering | ( | bool | do_vibration_filtering | ) |
Enables or disables vibration filtering.
This method controls whether the sensor applies vibration filtering algorithms to reduce measurement noise caused by mechanical vibrations. Enabling this feature can improve measurement accuracy in environments with significant vibration.
do_vibration_filtering | true to enable vibration filtering, false to disable it |
bool sfDevBMV080::setDutyCyclingPeriod | ( | uint16_t | duty_cycling_period | ) |
Sets the time interval between measurements in duty cycle mode.
This method configures how frequently the sensor takes measurements when operating in duty cycle mode. A longer period reduces power consumption but provides less frequent updates.
duty_cycling_period | The time between measurements in seconds |
bool sfDevBMV080::setIntegrationTime | ( | float | integration_time | ) |
Sets the sensor's integration time for measurements.
This method configures the integration time used for particle measurements. Longer integration times can improve measurement accuracy but increase response time and power consumption.
integration_time | The measurement integration time in milliseconds (ms) |
bool sfDevBMV080::setMeasurementAlgorithm | ( | uint8_t | measurement_algorithm | ) |
Sets the measurement algorithm for particle analysis.
This method configures which algorithm the sensor uses for analyzing particle measurements. Different algorithms can be optimized for specific types of particles or measurement environments.
measurement_algorithm | The algorithm identifier to use for measurements |
bool sfDevBMV080::setMode | ( | uint8_t | mode | ) |
Sets the operational mode of the BMV080 sensor.
This method configures how the sensor takes measurements. It supports two modes: continuous measurement or duty-cycled measurement.
mode | The desired operational mode:
|
void sfDevBMV080::setSensorValue | ( | bmv080_output_t | bmv080_output | ) |
Internal method to set sensor values from callback.
This method is called by the BMV080 driver callback to update internal sensor data. It stores the latest sensor readings and sets the data available flag.
bmv080_output | The sensor output structure containing the latest readings including PM2.5, PM1, and obstruction status |
bool sfDevBMV080::setVolumetricMassDensity | ( | float | volumetric_mass_density | ) |
Sets the volumetric mass density for particle concentration calculations.
This method configures the density value used to convert between particle counts and mass concentrations. This setting affects the accuracy of PM2.5 and PM1 measurements based on the expected particle density.
volumetric_mass_density | The particle density in grams per cubic centimeter (g/cm³) |
float sfDevBMV080::volumetricMassDensity | ( | ) |
Gets the volumetric mass density setting.
This method returns the current volumetric mass density setting used for particle concentration calculations. This value affects how the sensor converts between particle counts and mass concentrations.
|
protected |
|
static |