diff --git a/CHANGELOG.md b/CHANGELOG.md index 643a81e..aea4e94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.4.2] - 2023-11-25 +- add **readTemperatureForHumidity()** to async interface +- update readme.md + ## [0.4.1] - 2023-11-25 - fix **reset()**: clear state of resolution, heater and error - update readme.md diff --git a/README.md b/README.md index 5d91214..2be2e3f 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,9 @@ Timing in milliseconds. #### 0.4.1 - fix reset(): clear state of resolution, heater and error +#### 0.4.2 +- add readTemperatureForHumidity() + #### Should - test test test diff --git a/SHT2x.cpp b/SHT2x.cpp index 5b31771..cd632fa 100644 --- a/SHT2x.cpp +++ b/SHT2x.cpp @@ -1,7 +1,7 @@ // // FILE: SHT2x.cpp // AUTHOR: Rob Tillaart, Viktor Balint, JensB -// VERSION: 0.4.1 +// VERSION: 0.4.2 // DATE: 2023-11-25 // PURPOSE: Arduino library for the SHT2x temperature and humidity sensor // URL: https://github.com/RobTillaart/SHT2x @@ -12,6 +12,7 @@ // SUPPORTED COMMANDS #define SHT2x_GET_TEMPERATURE_NO_HOLD 0xF3 +#define SHT2x_GET_TEMPERATURE_FOR_HUMIDITY 0xE0 #define SHT2x_GET_HUMIDITY_NO_HOLD 0xF5 #define SHT2x_SOFT_RESET 0xFE #define SHT2x_WRITE_USER_REGISTER 0xE6 @@ -229,6 +230,29 @@ bool SHT2x::readHumidity() } +bool SHT2x::readTemperatureForHumidity() +{ + if (_error == SHT2x_OK) + { + writeCmd(SHT2x_GET_TEMPERATURE_FOR_HUMIDITY); + uint8_t buffer[2]; + if (readBytes(2, (uint8_t*) &buffer[0], 10) == false) + { + _error = SHT2x_ERR_READBYTES; + return false; + } + _rawTemperature = buffer[0] << 8; + _rawTemperature += buffer[1]; + _rawTemperature &= 0xFFFC; + return true; + } + else + { + return false; + } +} + + uint32_t SHT2x::lastRequest() { return _lastRequest; diff --git a/SHT2x.h b/SHT2x.h index 6215530..797f243 100644 --- a/SHT2x.h +++ b/SHT2x.h @@ -2,7 +2,7 @@ // // FILE: SHT2x.h // AUTHOR: Rob Tillaart, Viktor Balint, JensB -// VERSION: 0.4.1 +// VERSION: 0.4.2 // DATE: 2023-11-25 // PURPOSE: Arduino library for the SHT2x temperature and humidity sensor // URL: https://github.com/RobTillaart/SHT2x @@ -13,7 +13,7 @@ #include "Wire.h" -#define SHT2x_LIB_VERSION (F("0.4.1")) +#define SHT2x_LIB_VERSION (F("0.4.2")) // fields getStatus @@ -152,6 +152,7 @@ class SHT2x bool requestReady(); bool readTemperature(); bool readHumidity(); + bool readTemperatureForHumidity(); uint32_t lastRequest(); uint8_t getRequestType(); diff --git a/keywords.txt b/keywords.txt index 0bd60fd..88a617e 100644 --- a/keywords.txt +++ b/keywords.txt @@ -49,6 +49,7 @@ reqHumReady KEYWORD2 requestReady KEYWORD2 readTemperature KEYWORD2 readHumidity KEYWORD2 +readTemperatureForHumidity KEYWORD2 lastRequest KEYWORD2 getRequestType KEYWORD2 diff --git a/library.json b/library.json index 9843e70..3ebd318 100644 --- a/library.json +++ b/library.json @@ -21,7 +21,7 @@ "type": "git", "url": "https://github.com/RobTillaart/SHT2x.git" }, - "version": "0.4.1", + "version": "0.4.2", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/library.properties b/library.properties index 246da4a..c45adb0 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SHT2x -version=0.4.1 +version=0.4.2 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for the I2C SHT20 SHT21 SHT25 series temperature and humidity sensor.