Skip to content

Commit 71ed74c

Browse files
authored
Merge pull request #6 from sparkfun/main
Move main to develop
2 parents 9e67711 + cf5a291 commit 71ed74c

File tree

24 files changed

+1055
-808
lines changed

24 files changed

+1055
-808
lines changed

examples/Example_01_BasicReadings/Example_01_BasicReadings.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,17 @@ void loop()
8383
{
8484
if (bmv080.readSensor())
8585
{
86+
float pm10 = bmv080.PM10();
8687
float pm25 = bmv080.PM25();
8788
float pm1 = bmv080.PM1();
8889

90+
Serial.print("PM10: ");
91+
Serial.print(pm10);
92+
Serial.print("\t");
93+
Serial.print("PM2.5: ");
8994
Serial.print(pm25);
9095
Serial.print("\t");
96+
Serial.print("PM1: ");
9197
Serial.print(pm1);
9298

9399
if (bmv080.isObstructed() == true)

examples/Example_04_SPI/Example_04_SPI.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "SparkFun_BMV080_Arduino_Library.h" // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_BMV080
3737

3838
SparkFunBMV080SPI bmv080; // Create an instance of the BMV080 class
39-
#define CS_PIN 15 // Define the chip select pin
39+
#define CS_PIN 5 // Define the chip select pin
4040

4141
void setup()
4242
{

examples/Example_05_Parameters/Example_05_Parameters.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,20 @@ void loop()
9393
{
9494
if(bmv080.readSensor())
9595
{
96+
float pm10 = bmv080.PM10();
9697
float pm25 = bmv080.PM25();
98+
float pm1 = bmv080.PM1();
9799

100+
Serial.print("PM10: ");
101+
Serial.print(pm10);
102+
Serial.print("\t");
103+
Serial.print("PM2.5: ");
98104
Serial.print(pm25);
105+
Serial.print("\t");
106+
Serial.print("PM1: ");
107+
Serial.print(pm1);
99108

100-
if(bmv080.isObstructed() == true)
109+
if (bmv080.isObstructed() == true)
101110
{
102111
Serial.print("\tObstructed");
103112
}

examples/Example_06_TwoSensors/Example_06_TwoSensors.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void setup()
6868
// Comment out this while loop, or it will prevent the remaining code from running.
6969

7070
Serial.println();
71-
Serial.println("BMV080 Example 1 - Basic Readings");
71+
Serial.println("BMV080 Example 6 - Two Sensors");
7272

7373
wirePort.begin();
7474

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/*
2+
Using the BMV080 Particulate Matter PM2.5 Sensor
3+
4+
This example shows how to open an instance of the object, take 5 readings,
5+
then close the object.
6+
7+
It then repeats this process every 5 seconds.
8+
9+
This example shows how to use the sensor in "continuous mode" to get
10+
particulate matter readings once every second.
11+
12+
It uses polling of the device to check if new data is available.
13+
14+
By: Pete Lewis
15+
SparkFun Electronics
16+
Date: September, 2024
17+
SparkFun code, firmware, and software is released under the MIT License.
18+
Please see LICENSE.md for further details.
19+
20+
Hardware Connections:
21+
IoT RedBoard --> BMV080
22+
QWIIC --> QWIIC
23+
24+
BMV080 "mode" jumper set to I2C (default)
25+
26+
Serial.print it out at 115200 baud to serial monitor.
27+
28+
Feel like supporting our work? Buy a board from SparkFun!
29+
https://www.sparkfun.com/products/26554
30+
*/
31+
32+
#include "SparkFun_BMV080_Arduino_Library.h" // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_BMV080
33+
#include <Wire.h>
34+
35+
36+
#define BMV080_ADDR 0x57 // SparkFun BMV080 Breakout defaults to 0x57
37+
38+
// Some Dev boards have their QWIIC connector on Wire or Wire1
39+
// This #ifdef will help this sketch work across more products
40+
41+
#ifdef ARDUINO_SPARKFUN_THINGPLUS_RP2040
42+
#define wirePort Wire1
43+
#else
44+
#define wirePort Wire
45+
#endif
46+
47+
int testTimes = 0; // Test times
48+
49+
void setup()
50+
{
51+
Serial.begin(115200);
52+
53+
while (!Serial)
54+
delay(10); // Wait for Serial to become available.
55+
// Necessary for boards with native USB (like the SAMD51 Thing+).
56+
// For a final version of a project that does not need serial debug (or a USB cable plugged in),
57+
// Comment out this while loop, or it will prevent the remaining code from running.
58+
59+
Serial.println();
60+
Serial.println("BMV080 Example 09 - Open and Close");
61+
}
62+
63+
void loop()
64+
{
65+
Serial.print("Test times: ");
66+
Serial.println(testTimes);
67+
testOnce();
68+
testTimes++;
69+
delay(5000);
70+
}
71+
72+
73+
void testOnce()
74+
{
75+
Serial.println();
76+
Serial.println("BMV080 Begin testing readings");
77+
78+
SparkFunBMV080 bmv080; // Create an instance of the BMV080 class
79+
80+
wirePort.begin();
81+
82+
if (bmv080.begin(BMV080_ADDR, wirePort) == false)
83+
{
84+
Serial.println(
85+
"BMV080 not detected at default I2C address. Check your jumpers and the hookup guide. Freezing...");
86+
while (1)
87+
;
88+
}
89+
Serial.println("BMV080 found!");
90+
91+
// wirePort.setClock(400000); //Increase I2C data rate to 400kHz
92+
93+
/* Initialize the Sensor (read driver, open, reset, id etc.)*/
94+
// Do what init() does, but check each call to each function individually
95+
// to see if there are any issues with the sensor
96+
97+
uint16_t major, minor, patch;
98+
if (bmv080.driverVersion(major, minor, patch) == true)
99+
{
100+
Serial.print("BMV080 Driver Version: ");
101+
Serial.print(major);
102+
Serial.print(".");
103+
Serial.print(minor);
104+
Serial.print(".");
105+
Serial.println(patch);
106+
}
107+
else
108+
{
109+
Serial.println("Error getting BMV080 driver version");
110+
}
111+
112+
if (bmv080.open() == true)
113+
{
114+
Serial.println("BMV080 Opened");
115+
}
116+
else
117+
{
118+
Serial.println("Error opening BMV080");
119+
}
120+
121+
if (bmv080.reset() == true)
122+
{
123+
Serial.println("BMV080 Reset");
124+
}
125+
else
126+
{
127+
Serial.println("Error resetting BMV080");
128+
}
129+
130+
char idOut[13];
131+
if (bmv080.ID(idOut) == true)
132+
{
133+
Serial.print("BMV080 ID: ");
134+
Serial.println(idOut);
135+
}
136+
else
137+
{
138+
Serial.println("Error getting BMV080 ID");
139+
}
140+
141+
/* Set the sensor mode to continuous mode */
142+
if (bmv080.setMode(SF_BMV080_MODE_CONTINUOUS) == true)
143+
{
144+
Serial.println("BMV080 set to continuous mode");
145+
}
146+
else
147+
{
148+
Serial.println("Error setting BMV080 mode");
149+
}
150+
151+
// Take 5 readings
152+
153+
// Poll the sensor 50 times, once every 100ms
154+
// The sensor is setup to report readings once per second
155+
// So this will result in 5 readings.
156+
for(int i = 0 ; i < 50 ; i++)
157+
{
158+
if (bmv080.readSensor())
159+
{
160+
float pm10 = bmv080.PM10();
161+
float pm25 = bmv080.PM25();
162+
float pm1 = bmv080.PM1();
163+
164+
Serial.print("PM10: ");
165+
Serial.print(pm10);
166+
Serial.print("\t");
167+
Serial.print("PM2.5: ");
168+
Serial.print(pm25);
169+
Serial.print("\t");
170+
Serial.print("PM1: ");
171+
Serial.print(pm1);
172+
173+
if (bmv080.isObstructed() == true)
174+
{
175+
Serial.print("\tObstructed");
176+
}
177+
178+
Serial.println();
179+
}
180+
delay(100);
181+
}
182+
183+
Serial.println("BMV080 End testing readings");
184+
185+
bmv080.close();
186+
187+
wirePort.end();
188+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ url=https://github.com/sparkfun/SparkFun_BMV080_Arduino_Library
99
architectures=esp32,esp32s2,esp32s3,cortex-m33,cortex-m0plus,cortex-m4f
1010
precompiled=true
1111
depends=SparkFun Toolkit (>=1.0.0)
12-
ldflags=-lbmv080
12+
ldflags=-lbmv080 -lpostProcessor

src/cortex-m0plus/libbmv080.a

-6.07 KB
Binary file not shown.

src/cortex-m0plus/libpostProcessor.a

-1.3 KB
Binary file not shown.

src/cortex-m33/libbmv080.a

-460 Bytes
Binary file not shown.

src/cortex-m33/libpostProcessor.a

37.1 KB
Binary file not shown.

src/cortex-m4/libbmv080.a

-4.65 KB
Binary file not shown.

src/cortex-m4/libpostProcessor.a

-1.86 KB
Binary file not shown.

src/cortex-m4f/libbmv080.a

-4.79 KB
Binary file not shown.

src/cortex-m4f/libpostProcessor.a

-1.79 KB
Binary file not shown.

src/esp32/libbmv080.a

-14.7 KB
Binary file not shown.

src/esp32/libpostProcessor.a

-4.48 KB
Binary file not shown.

src/esp32s2/libbmv080.a

-14.2 KB
Binary file not shown.

src/esp32s2/libpostProcessor.a

-6.08 KB
Binary file not shown.

src/esp32s3/libbmv080.a

-14.7 KB
Binary file not shown.

src/esp32s3/libpostProcessor.a

-4.48 KB
Binary file not shown.

0 commit comments

Comments
 (0)