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
Loading...
Searching...
No Matches
sfDevBMV080 Class Reference

#include <sfDevBMV080.h>

Inheritance diagram for sfDevBMV080:

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
 

Constructor & Destructor Documentation

◆ sfDevBMV080()

sfDevBMV080::sfDevBMV080 ( )
inline

Default constructor.

Member Function Documentation

◆ begin()

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.

Parameters
theBusSparkFun Toolkit bus interface to use for communication.
Returns
sfTkError_t Status code:
  • 0: Success
  • Negative: Error occurred
  • Positive: Warning condition
See also
init()
open()

◆ close()

bool sfDevBMV080::close ( void  )

Closes communication with the BMV080 sensor.

Returns
true if the sensor was successfully closed and handle created
false if the sensor could not be closed or handle creation failed
See also
open()

◆ distributionId()

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.

Returns
The current distribution ID value
See also
setDistributionId()
PM25()
PM1()

◆ doObstructionDetection()

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.

Returns
true if obstruction detection is enabled
false if obstruction detection is disabled
See also
setDoObstructionDetection()
isObstructed()

◆ doVibrationFiltering()

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.

Returns
true if vibration filtering is enabled
false if vibration filtering is disabled
See also
setDoVibrationFiltering()
readSensor()

◆ driverVersion()

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.

Parameters
[out]majorMajor version number indicating incompatible API changes
[out]minorMinor version number indicating backwards-compatible functionality
[out]patchPatch version number indicating backwards-compatible bug fixes
Returns
true if the version information was successfully retrieved
false if there was an error getting the version information
See also
init()

◆ dutyCyclingPeriod()

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.

Returns
The duty cycling period in seconds
Note
This setting only affects the sensor when in SFE_BMV080_MODE_DUTY_CYCLE mode
See also
setDutyCyclingPeriod()
setMode()

◆ ID()

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.

Parameters
[out]idOutBuffer to store the sensor's ID string. Must be at least kBMV800IDLength (13) bytes long.
Returns
true if the ID was successfully retrieved
false if there was an error reading the ID
Note
The buffer must be pre-allocated with at least kBMV800IDLength bytes
See also
kBMV800IDLength

◆ init()

bool sfDevBMV080::init ( void  )

Initializes the BMV080 sensor.

This method performs complete initialization of the sensor by:

  • Opening communication with the sensor
  • Performing a soft reset
  • Getting driver version information
  • Reading the sensor ID

It must be called after begin() and before attempting any other operations.

Returns
true if initialization was successful
false if any initialization step failed
See also
begin()
open()
reset()
driverVersion()
ID()

◆ integrationTime()

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.

Returns
The integration time in milliseconds (ms)
See also
setIntegrationTime()
readSensor()

◆ isObstructed()

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.

Returns
true if the sensor is obstructed
false if the sensor is not obstructed
Note
The obstruction status is updated when readSensor() is called
See also
readSensor()
bmv080_output_t

◆ measurementAlgorithm()

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.

Returns
The current measurement algorithm identifier
See also
setMeasurementAlgorithm()
readSensor()

◆ open()

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.

Returns
true if the sensor was successfully opened and handle created
false if the sensor could not be opened or handle creation failed
Note
This method is automatically called by init()
See also
init()
begin()

◆ PM1()

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.

Returns
The PM1 concentration in micrograms per cubic meter (µg/m³)
Note
The PM1 value is updated when readSensor() is called
See also
readSensor()
PM25()
bmv080_output_t

◆ PM10()

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.

Returns
The PM10 concentration in micrograms per cubic meter (µg/m³)
Note
The PM10 value is updated when readSensor() is called
See also
readSensor()
PM1()
bmv080_output_t

◆ PM25()

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.

Returns
The PM2.5 concentration in micrograms per cubic meter (µg/m³)
Note
The PM2.5 value is updated when readSensor() is called
See also
readSensor()
PM1()
bmv080_output_t

◆ readSensor()

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.

Parameters
[out]bmv080_outputOptional pointer to a bmv080_output_t struct to store the sensor readings. If nullptr (default), the values are only stored internally.
Returns
true if new data was successfully read from the sensor
false if the sensor read failed or no new data is available
Note
This method clears the _dataAvailable flag before attempting to read new data
See also
sensorServiceRoutine()
bmv080_output_t

◆ reset()

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.

Returns
true if the reset was successful
false if the reset failed
Note
After reset, you may need to reinitialize settings like operational mode and duty cycling period
See also
init()
setMode()

◆ setDistributionId()

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.

Parameters
distribution_idThe distribution ID to use for particle classification
Returns
true if the distribution ID was successfully set
false if setting the distribution ID failed
See also
distributionId()
PM25()
PM1()

◆ setDoObstructionDetection()

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.

Parameters
do_obstruction_detectiontrue to enable obstruction detection, false to disable it
Returns
true if the setting was successfully changed
false if changing the setting failed
See also
doObstructionDetection()
isObstructed()

◆ setDoVibrationFiltering()

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.

Parameters
do_vibration_filteringtrue to enable vibration filtering, false to disable it
Returns
true if the setting was successfully changed
false if changing the setting failed
See also
doVibrationFiltering()
readSensor()

◆ setDutyCyclingPeriod()

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.

Parameters
duty_cycling_periodThe time between measurements in seconds
Returns
true if the period was successfully set
false if setting the period failed
Note
This setting only takes effect when the sensor is in SFE_BMV080_MODE_DUTY_CYCLE mode
See also
dutyCyclingPeriod()
setMode()

◆ setIntegrationTime()

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.

Parameters
integration_timeThe measurement integration time in milliseconds (ms)
Returns
true if the integration time was successfully set
false if setting the integration time failed
See also
integrationTime()
readSensor()

◆ setMeasurementAlgorithm()

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.

Parameters
measurement_algorithmThe algorithm identifier to use for measurements
Returns
true if the algorithm was successfully set
false if setting the algorithm failed
See also
measurementAlgorithm()
readSensor()

◆ setMode()

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.

Parameters
modeThe desired operational mode:
  • SFE_BMV080_MODE_CONTINUOUS: Sensor takes measurements continuously
  • SFE_BMV080_MODE_DUTY_CYCLE: Sensor takes measurements at specified intervals
Returns
true if the mode was set successfully
false if setting the mode failed
Note
When using duty cycle mode, the measurement interval can be configured using setDutyCyclingPeriod()
See also
setDutyCyclingPeriod()
readSensor()
bmv080_output_t

◆ setSensorValue()

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.

Parameters
bmv080_outputThe sensor output structure containing the latest readings including PM2.5, PM1, and obstruction status
Note
This is primarily an internal method used as part of the callback mechanism from the Bosch BMV080 driver. It should not typically be called directly by library users.
See also
set_sensor_value()
bmv080_output_t

◆ setVolumetricMassDensity()

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.

Parameters
volumetric_mass_densityThe particle density in grams per cubic centimeter (g/cm³)
Returns
true if the density was successfully set
false if setting the density failed
See also
volumetricMassDensity()
PM25()
PM1()

◆ volumetricMassDensity()

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.

Returns
The volumetric mass density in grams per cubic centimeter (g/cm³)
See also
setVolumetricMassDensity()
PM25()
PM1()

Member Data Documentation

◆ _theBus

sfTkIBus* sfDevBMV080::_theBus
protected

◆ kBMV800IDLength

const size_t sfDevBMV080::kBMV800IDLength = 13
static

Length of the BMV080 sensor ID string buffer.

This constant defines the required buffer size for storing the sensor's unique identification string. The buffer must be at least this size when calling the ID() method.

See also
ID()

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