From 4689354964e8ee25bade359044387ec61fa8a626 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Wed, 7 Feb 2018 16:57:11 +0100 Subject: [PATCH] retry bme --- src/BME280.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BME280.cpp b/src/BME280.cpp index ce2b136..0b4f556 100644 --- a/src/BME280.cpp +++ b/src/BME280.cpp @@ -15,11 +15,15 @@ bool BME280::begin(void) { digitalWrite(23, HIGH); // enable bme280 CS delay(50); bme = new Adafruit_BME280(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI + int retries = 0; while (!(status = bme->begin())) { + if (retries > 5) break; + retries++; Serial.println("Could not find a valid BME280 sensor, check wiring!"); // bme->reset(); delay(500); } + if (!status) return false; return true; }