This repository has been archived by the owner on Feb 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create separate examples for SDP3x and SDP8xx
- Loading branch information
Showing
4 changed files
with
95 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <Wire.h> | ||
|
||
#include <sdpsensor.h> | ||
|
||
// To configure the I2C address manually, choose one of the three calls below; | ||
// make sure you comment out the other two, otherwise the sketch won't build! | ||
|
||
SDP3XSensor sdp(SDP3X_I2C_ADDR_21); // Address 0x21 | ||
// SDP3XSensor sdp(SDP3X_I2C_ADDR_22); // Address 0x22 | ||
// SDP3XSensor sdp(SDP3X_I2C_ADDR_23); // Address 0x23 | ||
|
||
void setup() { | ||
Wire.begin(); | ||
Serial.begin(9600); | ||
delay(1000); // let serial console settle | ||
|
||
int ret = sdp.init(); | ||
if (ret == 0) { | ||
Serial.print("init(): success\n"); | ||
} else { | ||
Serial.print("init(): failed, ret = "); | ||
Serial.println(ret); | ||
while (true) { | ||
delay(1000); | ||
} | ||
} | ||
} | ||
|
||
void loop() { | ||
int ret = sdp.readSample(); | ||
if (ret == 0) { | ||
Serial.print("Differential pressure: "); | ||
Serial.print(sdp.getDifferentialPressure()); | ||
Serial.print("Pa | "); | ||
|
||
Serial.print("Temp: "); | ||
Serial.print(sdp.getTemperature()); | ||
Serial.print("C\n"); | ||
} else { | ||
Serial.print("Error in readSample(), ret = "); | ||
Serial.println(ret); | ||
} | ||
|
||
delay(500); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <Wire.h> | ||
|
||
#include <sdpsensor.h> | ||
|
||
SDP8XXSensor sdp; | ||
|
||
void setup() { | ||
Wire.begin(); | ||
Serial.begin(9600); | ||
delay(1000); // let serial console settle | ||
|
||
int ret = sdp.init(); | ||
if (ret == 0) { | ||
Serial.print("init(): success\n"); | ||
} else { | ||
Serial.print("init(): failed, ret = "); | ||
Serial.println(ret); | ||
while (true) { | ||
delay(1000); | ||
} | ||
} | ||
} | ||
|
||
void loop() { | ||
int ret = sdp.readSample(); | ||
if (ret == 0) { | ||
Serial.print("Differential pressure: "); | ||
Serial.print(sdp.getDifferentialPressure()); | ||
Serial.print("Pa | "); | ||
|
||
Serial.print("Temp: "); | ||
Serial.print(sdp.getTemperature()); | ||
Serial.print("C\n"); | ||
} else { | ||
Serial.print("Error in readSample(), ret = "); | ||
Serial.println(ret); | ||
} | ||
|
||
delay(500); | ||
} |