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
SparkFun_BMV080_Arduino_Library.h
Go to the documentation of this file.
1/******************************************************************************
2 * @file SparkFun_BMV080_Arduino_Library.h
3 * @brief SparkFun BMV080 Library header file
4 *
5 * This file implements the SparkFunBMV080 and SparkFunBMV080SPI classes,
6 * for use with the SparkFun BMV080 sensor qwiic breakout board, HW version v01.
7 *
8 * @author Pete Lewis
9 * @date Sprint 2025
10 * @version 1.0
11 * @copyright (c) 2024 SparkFun Electronics Inc. This project is released under the MIT License.
12 *
13 * SPDX-License-Identifier: MIT
14 *
15 ******************************************************************************/
16
17#pragma once
18
19// helps to keep the Toolkit header before the tk calls
20// clang-format off
21#include <SparkFun_Toolkit.h>
22#include "sfTk/sfDevBMV080.h"
23// clang-format on
24
25// The BMV080 Bosch API requires a larger than usual stack size
26// In particular, bmv080_serve_interrupt is the culprit.
27// If we are an ESP32 architecture, then we need to increase the loop stack size
28// to 60KB. This is because the ESP32 has a 32KB stack size by default.
29#if defined(ESP32)
30SET_LOOP_TASK_STACK_SIZE(60 * 1024); // 60KB
31#endif
32
43{
44 public:
54 bool begin(const uint8_t address = SF_BMV080_DEFAULT_ADDRESS, TwoWire &wirePort = Wire)
55 {
56 // Setup Arduino I2C bus
57 _theI2CBus.init(wirePort, address);
58 _theI2CBus.setByteOrder(SFTK_MSBFIRST);
59
60 // Begin the sensor
61 sfTkError_t rc = sfDevBMV080::begin(&_theI2CBus);
62
63 return rc == ksfTkErrOk ? isConnected() : false;
64 }
65
69 {
70 return _theI2CBus.ping() == ksfTkErrOk;
71 }
72
73 private:
74 sfTkArdI2C _theI2CBus;
75};
76
87{
88 public:
99 bool begin(uint8_t csPin, SPIClass &spiPort = SPI,
100 SPISettings spiSettings = SPISettings(100000, MSBFIRST, SPI_MODE0))
101 {
102
103 // Setup Arduino SPI bus
104 _theSPIBus.init(spiPort, spiSettings, csPin, true);
105
106 // Begin the sensor
107 sfTkError_t rc = sfDevBMV080::begin(&_theSPIBus);
108
109 return rc == ksfTkErrOk ? true : false;
110 }
111
112 private:
113 sfTkArdSPI _theSPIBus;
114};
Class for interfacing with the BMV080 sensor using I2C communication.
Definition: SparkFun_BMV080_Arduino_Library.h:43
bool isConnected()
Checks if the Device is connected.
Definition: SparkFun_BMV080_Arduino_Library.h:68
bool begin(const uint8_t address=SF_BMV080_DEFAULT_ADDRESS, TwoWire &wirePort=Wire)
Begins the Device with I2C as the communication bus.
Definition: SparkFun_BMV080_Arduino_Library.h:54
Class for interfacing with the BMV080 sensor using SPI communication.
Definition: SparkFun_BMV080_Arduino_Library.h:87
bool begin(uint8_t csPin, SPIClass &spiPort=SPI, SPISettings spiSettings=SPISettings(100000, MSBFIRST, SPI_MODE0))
Begins the Device with SPI as the communication bus.
Definition: SparkFun_BMV080_Arduino_Library.h:99
Definition: sfDevBMV080.h:42
sfTkError_t begin(sfTkIBus *theBus=nullptr)
Begins communication with the BMV080 sensor.
Definition: sfDevBMV080.cpp:131
Header file for the SparkFun BMV080 Library.
#define SF_BMV080_DEFAULT_ADDRESS
Definition: sfDevBMV080.h:35