From 2c792e91668049e8862835e3a9185c11f2ffe7d2 Mon Sep 17 00:00:00 2001 From: yanbec Date: Fri, 23 Feb 2018 22:19:16 +0100 Subject: [PATCH 1/2] Added reset() function --- src/BME280.cpp | 7 +++++++ src/BME280.h | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/BME280.cpp b/src/BME280.cpp index 10e2384..75e5162 100644 --- a/src/BME280.cpp +++ b/src/BME280.cpp @@ -127,6 +127,13 @@ bool BME280::begin return success; } +/****************************************************************/ +void BME280::reset() +{ + WriteRegister(RESET_ADDR, RESET_VALUE); + delay(2); //max. startup time according to datasheet +} + /****************************************************************/ void BME280::CalculateRegisters ( diff --git a/src/BME280.h b/src/BME280.h index 08b1247..0230123 100644 --- a/src/BME280.h +++ b/src/BME280.h @@ -161,6 +161,10 @@ class BME280 /// Method used to initialize the class. bool begin(); + //////////////////////////////////////////////////////////////// + /// Method to restart BME280. begin() needs to beed called afterwards + void reset(); + /*****************************************************************/ /* ENVIRONMENTAL FUNCTIONS */ /*****************************************************************/ @@ -239,6 +243,9 @@ class BME280 static const uint8_t HUM_DIG_ADDR1 = 0xA1; static const uint8_t HUM_DIG_ADDR2 = 0xE1; static const uint8_t ID_ADDR = 0xD0; + static const uint8_t RESET_ADDR = 0xE0; + + static const uint8_t RESET_VALUE = 0xB6; static const uint8_t TEMP_DIG_LENGTH = 6; static const uint8_t PRESS_DIG_LENGTH = 18; @@ -298,6 +305,7 @@ class BME280 /// successful and the id matches a known value. bool ReadChipID(); + ///////////////////////////////////////////////////////////////// /// Read the the trim data from the BME280, return true if /// successful. From 0ba0e1292c9d74912a039248cd6896f5927f8152 Mon Sep 17 00:00:00 2001 From: yanbec Date: Fri, 22 Jun 2018 11:05:40 +0200 Subject: [PATCH 2/2] Added begin() in reset() --- src/BME280.cpp | 3 ++- src/BME280.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BME280.cpp b/src/BME280.cpp index 75e5162..0c78c7d 100644 --- a/src/BME280.cpp +++ b/src/BME280.cpp @@ -128,10 +128,11 @@ bool BME280::begin } /****************************************************************/ -void BME280::reset() +bool BME280::reset() { WriteRegister(RESET_ADDR, RESET_VALUE); delay(2); //max. startup time according to datasheet + return(begin()); } /****************************************************************/ diff --git a/src/BME280.h b/src/BME280.h index 0230123..b9645e5 100644 --- a/src/BME280.h +++ b/src/BME280.h @@ -163,7 +163,7 @@ class BME280 //////////////////////////////////////////////////////////////// /// Method to restart BME280. begin() needs to beed called afterwards - void reset(); + bool reset(); /*****************************************************************/ /* ENVIRONMENTAL FUNCTIONS */