-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdps310_simpletest.ino
43 lines (32 loc) · 1.04 KB
/
dps310_simpletest.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
// This example shows how to read temperature/pressure
#include <Adafruit_DPS310.h>
Adafruit_DPS310 dps;
// Can also use SPI!
#define DPS310_CS 10
void setup() {
Serial.begin(115200);
while (!Serial) delay(10);
Serial.println("DPS310");
if (! dps.begin_I2C()) { // Can pass in I2C address here
//if (! dps.begin_SPI(DPS310_CS)) { // If you want to use SPI
Serial.println("Failed to find DPS");
while (1) yield();
}
Serial.println("DPS OK!");
dps.configurePressure(DPS310_64HZ, DPS310_64SAMPLES);
dps.configureTemperature(DPS310_64HZ, DPS310_64SAMPLES);
}
void loop() {
sensors_event_t temp_event, pressure_event;
while (!dps.temperatureAvailable() || !dps.pressureAvailable()) {
return; // wait until there's something to read
}
dps.getEvents(&temp_event, &pressure_event);
Serial.print(F("Temperature = "));
Serial.print(temp_event.temperature);
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(pressure_event.pressure);
Serial.println(" hPa");
Serial.println();
}