41 lines
753 B
C++
41 lines
753 B
C++
SFE_BMP180 bmp180;
|
|
int bmp180Connected = 0;
|
|
|
|
int setupBMP180() {
|
|
bmp180Connected = bmp180.begin(SDA, SCL);
|
|
return bmp180Connected;
|
|
}
|
|
|
|
bool isBMPConnected() {
|
|
return bmp180Connected != 0;
|
|
}
|
|
|
|
int getTemperature(double &t) {
|
|
char status;
|
|
status = bmp180.startTemperature();
|
|
if (status != 0)
|
|
{
|
|
// Wait for the measurement to complete:
|
|
delay(status);
|
|
status = bmp180.getTemperature(t);
|
|
if (status != 0)
|
|
return 0;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int getTempAndPressure(double &t, double &p) {
|
|
if (getTemperature(t) == 0) {
|
|
char status;
|
|
status = bmp180.startPressure(3);
|
|
if (status != 0)
|
|
{
|
|
delay(status);
|
|
status = bmp180.getPressure(p, t);
|
|
if (status != 0)
|
|
return 0;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|