Skip to content

Commit 715f7bc

Browse files
committed
Adding examples. Adding keywords. Adding deprecated settings so original code compiles.
1 parent 7ef516c commit 715f7bc

File tree

21 files changed

+714
-563
lines changed

21 files changed

+714
-563
lines changed

examples/CSV_Output/CSV_Output.ino

-116
This file was deleted.

examples/Example1_BasicReadings/Example1_BasicReadings.ino

+12-11
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
Date: March 9th, 2018
66
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
77
8-
https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
8+
Feel like supporting our work? Buy a board from SparkFun!
9+
https://www.sparkfun.com/products/14348 - Qwiic Combo Board
10+
https://www.sparkfun.com/products/13676 - BME280 Breakout Board
11+
12+
This example shows how to read humidity, pressure, and current temperature from the BME280 over I2C.
913
10-
This example shows how to obtain humidity, pressure, and current temperature from the BME280. It
11-
assumes an I2C connection.
12-
13-
Resources:
14-
Uses Wire.h for I2C operation
15-
Uses SPI.h for SPI operation
16-
17-
Development environment specifics:
18-
Arduino IDE 1.8.5
14+
todo
15+
example set local ref pressure
16+
fix repo description
17+
example of reading/writing cal factors
1918
2019
*/
2120

@@ -27,9 +26,11 @@ BME280 mySensor; //Global sensor object
2726
void setup()
2827
{
2928
Serial.begin(9600);
30-
while(!Serial); //Wait for terminal to open
29+
while(!Serial);
3130
Serial.println("Reading basic values from BME280");
3231

32+
Wire.begin();
33+
3334
if (mySensor.beginI2C() == false) //Begin communication over I2C
3435
{
3536
Serial.println("The chip did not respond. Please check wiring.");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/******************************************************************************
2+
Read all the regigsters of the BME280
3+
BME280 Arduino and Teensy example
4+
Marshall Taylor @ SparkFun Electronics
5+
May 20, 2015
6+
7+
Feel like supporting our work? Buy a board from SparkFun!
8+
https://www.sparkfun.com/products/14348 - Qwiic Combo Board
9+
https://www.sparkfun.com/products/13676 - BME280 Breakout Board
10+
11+
This example shows how to connect to different I2C address and push to different Wire ports.
12+
13+
The BME280 has two I2C addresses: 0x77 (jumper open) or 0x76 (jumper closed)
14+
15+
This sketch configures the BME280 to read all measurements. The sketch also
16+
displays the BME280's physical memory and what the driver perceives the
17+
calibration words to be.
18+
19+
*/
20+
21+
#include "Wire.h"
22+
23+
#include "SparkFunBME280.h"
24+
BME280 mySensorA; //Global sensor object
25+
26+
void setup()
27+
{
28+
Serial.begin(9600);
29+
Serial.println("Example showing alternate I2C addresses");
30+
31+
//Other I2C ports are available but it depends on your platform.
32+
//For example: Wire1, Wire2, softWire, etc
33+
34+
Wire.begin();
35+
Wire.setClock(400000); //Increase to fast I2C speed!
36+
37+
//Wire1.begin();
38+
//Wire1.setClock(400000);
39+
40+
mySensorA.setI2CAddress(0x77); //The default for the SparkFun Environmental Combo board is 0x77 (jumper open).
41+
//If you close the jumper it is 0x76
42+
//The I2C address must be set before .begin() otherwise the cal values will fail to load.
43+
44+
mySensorA.beginI2C(Wire); //Connect to this sensor using the Wire port
45+
46+
//mySensorB.setI2CAddress(0x76); //Connect to a second sensor
47+
//mySensorB.beginI2C(Wire1); //Connect to this sensor using the Wire1 port
48+
}
49+
50+
void loop()
51+
{
52+
Serial.print("Humidity: ");
53+
Serial.print(mySensorA.readFloatHumidity(), 0);
54+
55+
Serial.print(" Pressure: ");
56+
Serial.print(mySensorA.readFloatPressure(), 0);
57+
58+
Serial.print(" Alt: ");
59+
//Serial.print(mySensor.readFloatAltitudeMeters(), 1);
60+
Serial.print(mySensorA.readFloatAltitudeFeet(), 1);
61+
62+
Serial.print(" Temp: ");
63+
//Serial.print(mySensor.readTempC(), 2);
64+
Serial.print(mySensorA.readTempF(), 2);
65+
66+
//Serial.print(" TempB: ");
67+
//Serial.print(mySensorB.readTempF(), 2);
68+
69+
Serial.println();
70+
71+
delay(50);
72+
}
73+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
Output all readings in CSV format
3+
BME280 Arduino and Teensy example
4+
Marshall Taylor @ SparkFun Electronics
5+
May 20, 2015
6+
https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
7+
8+
This sketch outputs BME280 data in comma separated values for generating spreadsheet graphs.
9+
10+
Feel like supporting our work? Buy a board from SparkFun!
11+
https://www.sparkfun.com/products/14348 - Qwiic Combo Board
12+
https://www.sparkfun.com/products/13676 - BME280 Breakout Board
13+
14+
This code is released under the [MIT License](http://opensource.org/licenses/MIT).
15+
Please review the LICENSE.md file included with this example. If you have any questions
16+
or concerns with licensing, please contact [email protected].
17+
Distributed as-is; no warranty is given.
18+
*/
19+
20+
#include "Wire.h"
21+
22+
#include "SparkFunBME280.h"
23+
BME280 mySensor; //Global sensor object
24+
25+
unsigned long sampleNumber = 0;
26+
27+
void setup()
28+
{
29+
Serial.begin(9600);
30+
31+
Wire.begin();
32+
33+
if (mySensor.beginI2C() == false) //Begin communication over I2C
34+
{
35+
Serial.println("The chip did not respond. Please check wiring.");
36+
while(1); //Freeze
37+
}
38+
39+
//Build a first-row of column headers
40+
Serial.print("SampleNumber,");
41+
Serial.print("Time(ms),");
42+
Serial.print("T(deg C),");
43+
Serial.print("T(deg F),");
44+
Serial.print("P(Pa),");
45+
Serial.print("Alt(m),");
46+
Serial.print("Alt(ft),");
47+
Serial.print("%RH");
48+
Serial.println("");
49+
}
50+
51+
void loop()
52+
{
53+
//Print each row in the loop
54+
//Start with temperature, as that data is needed for accurate compensation.
55+
//Reading the temperature updates the compensators of the other functions
56+
//in the background.
57+
Serial.print(sampleNumber);
58+
Serial.print(",");
59+
Serial.print(millis());
60+
Serial.print(",");
61+
Serial.print(mySensor.readTempC(), 2);
62+
Serial.print(",");
63+
Serial.print(mySensor.readTempF(), 3);
64+
Serial.print(",");
65+
Serial.print(mySensor.readFloatPressure(), 0);
66+
Serial.print(",");
67+
Serial.print(mySensor.readFloatAltitudeMeters(), 3);
68+
Serial.print(",");
69+
Serial.print(mySensor.readFloatAltitudeFeet(), 3);
70+
Serial.print(",");
71+
Serial.print(mySensor.readFloatHumidity(), 0);
72+
Serial.println();
73+
74+
sampleNumber++;
75+
76+
delay(50);
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
Control the various settings of the BME280
3+
Nathan Seidle @ SparkFun Electronics
4+
March 23, 2018
5+
6+
Feel like supporting our work? Buy a board from SparkFun!
7+
https://www.sparkfun.com/products/14348 - Qwiic Combo Board
8+
https://www.sparkfun.com/products/13676 - BME280 Breakout Board
9+
10+
This example shows how to set the various filter, and oversample settings of the BME280.
11+
*/
12+
13+
#include "Wire.h"
14+
15+
#include "SparkFunBME280.h"
16+
BME280 mySensor; //Global sensor object
17+
18+
void setup()
19+
{
20+
Serial.begin(9600);
21+
Serial.println("Example showing alternate I2C addresses");
22+
23+
Wire.begin();
24+
Wire.setClock(400000); //Increase to fast I2C speed!
25+
26+
mySensor.beginI2C();
27+
28+
mySensor.setFilter(1); //0 to 4 is valid. Filter coefficient. See 3.4.4
29+
mySensor.setStandbyTime(0); //0 to 7 valid. Time between readings. See table 27.
30+
31+
mySensor.setTempOverSample(1); //0 to 16 are valid. 0 disables temp sensing. See table 24.
32+
mySensor.setPressureOverSample(1); //0 to 16 are valid. 0 disables pressure sensing. See table 23.
33+
mySensor.setHumidityOverSample(1); //0 to 16 are valid. 0 disables humidity sensing. See table 19.
34+
35+
mySensor.setMode(MODE_NORMAL); //MODE_SLEEP, MODE_FORCED, MODE_NORMAL is valid. See 3.3
36+
}
37+
38+
void loop()
39+
{
40+
Serial.print("Humidity: ");
41+
Serial.print(mySensor.readFloatHumidity(), 0);
42+
43+
Serial.print(" Pressure: ");
44+
Serial.print(mySensor.readFloatPressure(), 0);
45+
46+
Serial.print(" Alt: ");
47+
//Serial.print(mySensor.readFloatAltitudeMeters(), 1);
48+
Serial.print(mySensor.readFloatAltitudeFeet(), 1);
49+
50+
Serial.print(" Temp: ");
51+
//Serial.print(mySensor.readTempC(), 2);
52+
Serial.print(mySensor.readTempF(), 2);
53+
54+
Serial.println();
55+
56+
delay(50);
57+
}
58+

0 commit comments

Comments
 (0)