Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added getPT() to get both simultaneously
This can get both pressure and temperature simultaneously, saving a little time and eliminating repetitive code in getPressure() and getTemperature() while retaining the functionality.
- Loading branch information
Showing
3 changed files
with
59 additions
and
35 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,30 @@ | ||
#include <Wire.h> | ||
#include <Adafruit_MPL115A2.h> | ||
|
||
Adafruit_MPL115A2 mpl115a2; | ||
|
||
void setup(void) | ||
{ | ||
Serial.begin(9600); | ||
Serial.println("Hello!"); | ||
|
||
Serial.println("Getting barometric pressure ..."); | ||
mpl115a2.begin(); | ||
} | ||
|
||
void loop(void) | ||
{ | ||
float pressureKPA = 0, temperatureC = 0; | ||
|
||
mpl115a2.getPT(&pressureKPA,&temperatureC); | ||
Serial.print("Pressure (kPa): "); Serial.print(pressureKPA, 4); Serial.print(" kPa "); | ||
Serial.print("Temp (*C): "); Serial.print(temperatureC, 1); Serial.println(" *C both measured together"); | ||
|
||
pressureKPA = mpl115a2.getPressure(); | ||
Serial.print("Pressure (kPa): "); Serial.print(pressureKPA, 4); Serial.println(" kPa"); | ||
|
||
temperatureC = mpl115a2.getTemperature(); | ||
Serial.print("Temp (*C): "); Serial.print(temperatureC, 1); Serial.println(" *C"); | ||
|
||
delay(1000); | ||
} |