-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch_may24f.ino
62 lines (47 loc) · 1.38 KB
/
sketch_may24f.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdint.h>
#include "SparkFunBME280.h"
#include "Wire.h"
#include "SPI.h"
//Global sensor object
BME280 mySensor;
void setup()
{
Serial.begin(9600);
//SPI
mySensor.settings.commInterface = SPI_MODE;
mySensor.settings.chipSelectPin = 10;
//Operation settings
mySensor.settings.runMode = 3; //Normal mode
mySensor.settings.tStandby = 0;
mySensor.settings.filter = 0;
mySensor.settings.tempOverSample = 1;
mySensor.settings.pressOverSample = 1;
mySensor.settings.humidOverSample = 1;
Serial.print("Starting BME280... result of .begin(): 0x");
delay(10); //BME280 requires 2ms to start up.
Serial.println(mySensor.begin(), HEX);
}
void loop()
{
//Each loop, take a reading.
Serial.print("Temperature: ");
Serial.print(mySensor.readTempC(), 2);
Serial.println(" degrees C");
Serial.print("Temperature: ");
Serial.print(mySensor.readTempF(), 2);
Serial.println(" degrees F");
Serial.print("Pressure: ");
Serial.print(mySensor.readFloatPressure(), 2);
Serial.println(" Pa");
Serial.print("Altitude: ");
Serial.print(mySensor.readFloatAltitudeMeters(), 2);
Serial.println("m");
Serial.print("Altitude: ");
Serial.print(mySensor.readFloatAltitudeFeet(), 2);
Serial.println("ft");
Serial.print("%RH: ");
Serial.print(mySensor.readFloatHumidity(), 2);
Serial.println(" %");
Serial.println();
delay(1000);
}