English WIKI - lbx-8023/DFRobot_BMV080 GitHub Wiki
- [C++/Aduino Example Tutorial](#C++/Aduino Example Tutorial)
-
References
- begin
- openBmv080
- closeBmv080
- resetBmv080
- stopBmv080
- getBmv080DV
- getBmv080ID
- getBmv080Data
- setBmv080Mode
- setIntegrationTime
- getIntegrationTime
- setDutyCyclingPeriod
- getDutyCyclingPeriod
- setObstructionDetection
- getObstructionDetection
- setDoVibrationFiltering
- getDoVibrationFiltering
- setMeasurementAlgorithm
- getMeasurementAlgorithm
- DFRobot_BMV080_I2C
#include "DFRobot_BMV080.h"
#include <string>
SET_LOOP_TASK_STACK_SIZE(60 * 1024); // 60KB
DFRobot_BMV080_I2C sensor(&Wire);
void setup() {
// put your setup code here, to run once:
char id[13];
Serial.begin(115200);
delay(500);
while(sensor.begin() != 0){
Serial.println("Initialization of the chip failed. Please confirm if the chip connection is correct.");
delay(1000);
}
delay(500);
Serial.println("Initialization of the chip was successful.");
while(sensor.openBmv080())
{
Serial.println("open error");
delay(1000);
}
Serial.println("open successful");
delay(100);
sensor.getBmv080ID(id);
Serial.println("id is:" + String(id));
delay(100);
if(sensor.setBmv080Mode(0))
Serial.println("Mode setting successful");
}
float pm1,pm2_5,pm10;
void loop() {
// put your main code here, to run repeatedly:
if(sensor.getBmv080Data(&pm1,&pm2_5,&pm10))
{
Serial.println("Read successfully");
Serial.println("pm1:");
Serial.println(pm1);
Serial.println("pm2_5:");
Serial.println(pm2_5);
Serial.println("pm10:");
Serial.println(pm10);
}
delay(1000);
}
- C++/Arduino Example Tutorial:
int DFRobot_BMV080_I2C::begin(void)
- Description: Initialize the communication bus.
- Parameter: none
- Return Value: none
- C++/Arduino Example Tutorial:
uint8_t DFRobot_BMV080::openBmv080(void)
- Description: Pass the bmv080 handle, write callback, read callback, and delay callback functions to the bmv080 SDK. It is necessary to call this function first before proceeding with the subsequent operations.
- Parameter: 无
-
Return Value:
-
0
:successful. -
Other values
: Failure status codes.
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::closeBmv080(void)
- Description: Close BMV080。
- Parameter: none
-
Return Value:
-
1
:successful。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::resetBmv080(void)
- Description: Reset the sensor unit, including the previous configuration, and all settings will revert to their default values.
- Parameter: none
-
Return Value:
-
1
:error。 -
0
:successful。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::stopBmv080(void)
- Description: Stop the sensor measurement.
- Parameter: none
-
Return Value:
-
1
:successul。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::getBmv080DV(uint16_t &major, uint16_t &minor, uint16_t &patch)
- Description: Obtain the driver version of the sensor.。
-
Parameter:
-
major
:Main version number. -
minor
:Secondary version number. -
patch
:Patch version number.
-
-
Return Value:
-
1
:successful。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::getBmv080ID(char *id)
- Description: Obtain the ID of the sensor.
-
Parameter:
-
id
:An array used for storing IDs.
-
-
Return Value:
-
1
:successful。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::getBmv080Data(float *PM1, float *PM2_5, float *PM10)
- Description: Obtain the output data from the sensor.
-
Parameter:
-
PM1
:Used to store PM1 data. -
PM2_5
:Used to store PM2.5 data. -
PM10
:Used to store PM10 data.
-
-
Return Value:
-
1
:successful -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::setBmv080Mode(uint8_t mode)
-
Description: Set the measurement mode of the sensor.
-
Parameter:
-
mode
: 0: Continuous measurement 1: Measurement at specified time intervals
-
-
Return Value:
-
1
:sucessful。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::setIntegrationTime(float integration_time)
-
Description: Set the interval measurement time in the interval measurement mode.
-
Parameter:
-
integration_time
:The set interval measurement time.
-
-
Return Value:
-
1
:successful。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::getIntegrationTime(float integration_time)
-
Description: Obtain the interval measurement time in the interval measurement mode.
-
Parameter:
-
integration_time
:The interval measurement time obtained.
-
-
Return Value:
-
1
:successful。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::setDutyCyclingPeriod(uint16_t duty_cycling_period)
-
Description: Set the working period.
-
Parameter:
-
integration_time
:Set the working cycle time.
-
-
Return Value:
-
1
:successful。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::getDutyCyclingPeriod(uint16_t *duty_cycling_period)
-
Description:
-
Parameter:
-
integration_time
:Obtain the working period.
-
-
Return Value:
-
1
:successful。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::setObstructionDetection(bool obstructed)
-
Description: Set whether to enable obstacle detection.
-
Parameter:
-
obstructed
: 0:close, 1:open
-
-
Return Value:
-
1
:successful。 -
0
:error。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::getObstructionDetection(void)
-
Description: Obstacle detection on/off status is obtained.
-
Parameter: nono
-
Return Value:
-
1
:open。 -
0
:close。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::setDoVibrationFiltering(bool do_vibration_filtering)
-
Description: Obstacle detection on/off status is obtained. Whether to activate the vibration filtering function.
-
Parameter:
-
do_vibration_filtering
: 0:close, 1:open
-
-
Return Value:
-
1
:successful。 -
0
:close。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::getDoVibrationFiltering(void)
-
Description: Obtain the status of the vibration filtering function (whether it is enabled or disabled).
-
Parameter: none
-
Return Value:
-
1
:open。 -
0
:close。
-
- C++/Arduino Example Tutorial:
bool DFRobot_BMV080::setMeasurementAlgorithm(uint8_t measurement_algorithm)
-
Description: Set up the sensor measurement algorithm.
-
Parameter:
-
measurement_algorithm
:1: Rapid Response Algorithm, 2: Balance Algorithm, 3: High Precision Algorithm.
-
-
Return Value:
-
1
:successful. -
0
:error.
-
- C++/Arduino Example Tutorial:
uint8_t DFRobot_BMV080::getMeasurementAlgorithm(void)
-
Description: Obtain the current algorithm mode.
-
Parameter: none
-
Return Value:
-
1
:Fast response algorithm. -
2
:Balance algorithm. -
3
:High-precision algorithm.
-
- Description: The constructor of BMV080 in the IIC communication mode.
- 用法:
DFRobot_BMV080_I2C sensor(&Wire);