From d68cbc84c7a7eebb5255bd54745ceb730df72b10 Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Mon, 21 Dec 2020 20:23:46 +0100 Subject: [PATCH] fix examples compiled for UNO --- .../LPS35HW_fast_reading/LPS35HW_fast_reading.ino | 12 ++++++++++-- examples/LPS35HW_low_power/LPS35HW_low_power.ino | 10 ++++++++++ examples/LPS35HW_test/LPS35HW_test.ino | 10 ++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/examples/LPS35HW_fast_reading/LPS35HW_fast_reading.ino b/examples/LPS35HW_fast_reading/LPS35HW_fast_reading.ino index 57e4bb3..132121e 100644 --- a/examples/LPS35HW_fast_reading/LPS35HW_fast_reading.ino +++ b/examples/LPS35HW_fast_reading/LPS35HW_fast_reading.ino @@ -5,16 +5,24 @@ LPS35HW lps; void setup() { while(!Serial); - Wire.begin(SDA, SCL); - Wire.setClock(400000); Serial.begin(115200); Serial.println("LPS barometer fast reading test"); +#if defined(ESP8266) + Wire.begin(SDA, SCL); + Wire.setClock(400000); + if (!lps.begin(&Wire)) { // pass already began Wire Serial.println("Could not find a LPS barometer, check wiring!"); while (1) {} } +#else + if (!lps.begin()) { + Serial.println("Could not find a LPS barometer, check wiring!"); + while (1) {} + } +#endif lps.setLowPassFilter(LPS35HW::LowPassFilter_ODR20); // filter last 20 samples, default off lps.setOutputRate(LPS35HW::OutputRate_75Hz); // optional, default is 10Hz diff --git a/examples/LPS35HW_low_power/LPS35HW_low_power.ino b/examples/LPS35HW_low_power/LPS35HW_low_power.ino index acc16cf..ca02aa1 100644 --- a/examples/LPS35HW_low_power/LPS35HW_low_power.ino +++ b/examples/LPS35HW_low_power/LPS35HW_low_power.ino @@ -9,10 +9,20 @@ void setup() { Serial.begin(9600); Serial.println("LPS barometer low power test"); +#if defined(ESP8266) + Wire.begin(SDA, SCL); + Wire.setClock(400000); + + if (!lps.begin(&Wire)) { // pass already began Wire + Serial.println("Could not find a LPS barometer, check wiring!"); + while (1) {} + } +#else if (!lps.begin()) { Serial.println("Could not find a LPS barometer, check wiring!"); while (1) {} } +#endif lps.setLowPower(true); lps.setOutputRate(LPS35HW::OutputRate_OneShot); // get results on demand diff --git a/examples/LPS35HW_test/LPS35HW_test.ino b/examples/LPS35HW_test/LPS35HW_test.ino index 71ff888..ae2510a 100644 --- a/examples/LPS35HW_test/LPS35HW_test.ino +++ b/examples/LPS35HW_test/LPS35HW_test.ino @@ -7,10 +7,20 @@ void setup() { Serial.begin(9600); Serial.println("LPS barometer test"); +#if defined(ESP8266) + Wire.begin(SDA, SCL); + Wire.setClock(400000); + + if (!lps.begin(&Wire)) { // pass already began Wire + Serial.println("Could not find a LPS barometer, check wiring!"); + while (1) {} + } +#else if (!lps.begin()) { Serial.println("Could not find a LPS barometer, check wiring!"); while (1) {} } +#endif lps.setLowPassFilter(LPS35HW::LowPassFilter_ODR9); // filter last 9 samples, default off lps.setOutputRate(LPS35HW::OutputRate_1Hz); // optional, default is 10Hz