|
@ -5,7 +5,9 @@ |
|
|
#include <Adafruit_Sensor.h> |
|
|
#include <Adafruit_Sensor.h> |
|
|
#include <Adafruit_BME280.h> |
|
|
#include <Adafruit_BME280.h> |
|
|
|
|
|
|
|
|
BME280::BME280() {} |
|
|
BME280::BME280() { |
|
|
|
|
|
valid = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
bool BME280::begin(void) { |
|
|
bool BME280::begin(void) { |
|
|
// SPI.begin(BME_SCK, BME_MISO, BME_MOSI, BME_CS);
|
|
|
// SPI.begin(BME_SCK, BME_MISO, BME_MOSI, BME_CS);
|
|
@ -16,14 +18,14 @@ bool BME280::begin(void) { |
|
|
delay(50); |
|
|
delay(50); |
|
|
bme = new Adafruit_BME280(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
|
|
|
bme = new Adafruit_BME280(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
|
|
|
int retries = 0; |
|
|
int retries = 0; |
|
|
while (!(status = bme->begin())) { |
|
|
while (!(valid = bme->begin())) { |
|
|
if (retries > 5) break; |
|
|
if (retries > 5) break; |
|
|
retries++; |
|
|
retries++; |
|
|
Serial.println("Could not find a valid BME280 sensor, check wiring!"); |
|
|
Serial.println("Could not find a valid BME280 sensor, check wiring!"); |
|
|
// bme->reset();
|
|
|
// bme->reset();
|
|
|
delay(500); |
|
|
delay(500); |
|
|
} |
|
|
} |
|
|
if (!status) return false; |
|
|
if (!valid) return false; |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|