diff --git a/libraries/SHT31_SW/CHANGELOG.md b/libraries/SHT31_SW/CHANGELOG.md index afc51a7f..a1bee4af 100644 --- a/libraries/SHT31_SW/CHANGELOG.md +++ b/libraries/SHT31_SW/CHANGELOG.md @@ -6,10 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.2.0] - 2023-12-09 +- refactor API, follow SHT31 + +---- + ## [0.1.3] - 2023-11-22 - update readme.md - ## [0.1.2] - 2023-07-23 - update documentation - remove commented **SoftwareWire** version => own repo. diff --git a/libraries/SHT31_SW/README.md b/libraries/SHT31_SW/README.md index 186494e9..e4eb72f0 100644 --- a/libraries/SHT31_SW/README.md +++ b/libraries/SHT31_SW/README.md @@ -59,6 +59,12 @@ Test on UNO | SHT85 | ~0.2 | 1.5 | no | See SHT31_SWW +#### 0.2.0 Breaking change + +Version 0.2.0 introduced a breaking change in constructor and begin(). +Parameters have moved from begin() to the constructor. + + #### Related These libraries need to be installed to get SHT31_SW working: diff --git a/libraries/SHT31_SW/SHT31_SW.cpp b/libraries/SHT31_SW/SHT31_SW.cpp index 57346699..bac5aef9 100644 --- a/libraries/SHT31_SW/SHT31_SW.cpp +++ b/libraries/SHT31_SW/SHT31_SW.cpp @@ -1,7 +1,7 @@ // // FILE: SHT31_SW.cpp -// AUTHOR: Rob Tillaart -// VERSION: 0.1.3 +// AUTHOR: Rob Tillaart, Gunter Haug +// VERSION: 0.2.0 // DATE: 2019-02-08 (base SHT31 lib) // PURPOSE: Arduino library for the SHT31 temperature and humidity sensor // to be used with the SoftWire library instead of (hardware) Wire. @@ -14,10 +14,10 @@ #include "SHT31_SW.h" -SHT31_SW::SHT31_SW() +SHT31_SW::SHT31_SW(const uint8_t address, SoftWire *softWire) { - _softWire = NULL; - _address = 0; + _address = address; + _softWire = softWire; _lastRead = 0; _rawTemperature = 0; _rawHumidity = 0; @@ -29,25 +29,17 @@ SHT31_SW::SHT31_SW() } -bool SHT31_SW::begin(const uint8_t address, SoftWire *softWire) +bool SHT31_SW::begin() { - if ((address != 0x44) && (address != 0x45)) + if ((_address != 0x44) && (_address != 0x45)) { return false; } - _address = address; - _softWire = softWire; _softWire->begin(); return reset(); } -bool SHT31_SW::begin(SoftWire *softWire) -{ - return begin(SHT_DEFAULT_ADDRESS, softWire); -} - - bool SHT31_SW::isConnected() { _softWire->beginTransmission(_address); diff --git a/libraries/SHT31_SW/SHT31_SW.h b/libraries/SHT31_SW/SHT31_SW.h index b35030ca..f209a0c1 100644 --- a/libraries/SHT31_SW/SHT31_SW.h +++ b/libraries/SHT31_SW/SHT31_SW.h @@ -2,7 +2,7 @@ // // FILE: SHT31_SW.h // AUTHOR: Rob Tillaart, Gunter Haug -// VERSION: 0.1.3 +// VERSION: 0.2.0 // DATE: 2019-02-08 (base SHT31 lib) // PURPOSE: Arduino library for the SHT31 temperature and humidity sensor // to be used with the SoftWire library instead of (hardware) Wire. @@ -12,7 +12,7 @@ // https://github.com/RobTillaart/SHT31 -#define SHT31_SW_LIB_VERSION (F("0.1.3")) +#define SHT31_SW_LIB_VERSION (F("0.2.0")) #include "Arduino.h" @@ -23,11 +23,8 @@ class SHT31_SW : public SHT31 { public: - SHT31_SW(); - - // use SHT_DEFAULT_ADDRESS - bool begin(const uint8_t address, SoftWire *wire); - bool begin(SoftWire *wire); + SHT31_SW(uint8_t address, SoftWire *wire); + bool begin(); // check if sensor is reachable over I2C bool isConnected(); diff --git a/libraries/SHT31_SW/examples/SHT31_I2Cspeed/SHT31_I2Cspeed.ino b/libraries/SHT31_SW/examples/SHT31_I2Cspeed/SHT31_I2Cspeed.ino index 0e028ec4..a19f5e80 100644 --- a/libraries/SHT31_SW/examples/SHT31_I2Cspeed/SHT31_I2Cspeed.ino +++ b/libraries/SHT31_SW/examples/SHT31_I2Cspeed/SHT31_I2Cspeed.ino @@ -16,7 +16,7 @@ SoftWire sw(6, 7); uint32_t start; uint32_t stop; -SHT31_SW sht; +SHT31_SW sht(SHT31_ADDRESS, &sw); void setup() @@ -27,8 +27,8 @@ void setup() Serial.println(SHT31_SW_LIB_VERSION); sw.begin(); - sht.begin(SHT31_ADDRESS, &sw); sw.setClock(100000); + sht.begin(); uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); @@ -58,7 +58,7 @@ void test() Serial.print(sht.getTemperature(), 1); Serial.print("\t"); Serial.println(sht.getHumidity(), 1); - delay(100); + delay(1000); } diff --git a/libraries/SHT31_SW/examples/SHT31_async/SHT31_async.ino b/libraries/SHT31_SW/examples/SHT31_async/SHT31_async.ino index 70fa6f69..de9e8cf8 100644 --- a/libraries/SHT31_SW/examples/SHT31_async/SHT31_async.ino +++ b/libraries/SHT31_SW/examples/SHT31_async/SHT31_async.ino @@ -17,7 +17,7 @@ uint32_t start; uint32_t stop; uint32_t cnt; -SHT31_SW sht; +SHT31_SW sht(SHT31_ADDRESS, &sw); void setup() @@ -28,8 +28,8 @@ void setup() Serial.println(SHT31_SW_LIB_VERSION); sw.begin(); - sht.begin(SHT31_ADDRESS, &sw); sw.setClock(100000); + sht.begin(); uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); @@ -45,9 +45,9 @@ void loop() if (sht.dataReady()) { start = micros(); - bool success = sht.readData(); // default = true = fast + bool success = sht.readData(); // default = true = fast stop = micros(); - sht.requestData(); // request for next sample + sht.requestData(); // request for next sample Serial.print("\t"); Serial.print(stop - start); @@ -66,8 +66,8 @@ void loop() cnt = 0; } } - cnt++; // simulate other activity + cnt++; // simulate other activity } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/libraries/SHT31_SW/examples/SHT31_demo/SHT31_demo.ino b/libraries/SHT31_SW/examples/SHT31_demo/SHT31_demo.ino index 52e3698c..75f18059 100644 --- a/libraries/SHT31_SW/examples/SHT31_demo/SHT31_demo.ino +++ b/libraries/SHT31_SW/examples/SHT31_demo/SHT31_demo.ino @@ -16,7 +16,7 @@ SoftWire sw(6, 7); uint32_t start; uint32_t stop; -SHT31_SW sht; +SHT31_SW sht(SHT31_ADDRESS, &sw); void setup() @@ -28,7 +28,7 @@ void setup() sw.begin(); sw.setClock(100000); - sht.begin(SHT31_ADDRESS, &sw); + sht.begin(); Serial.print("CON:\t"); Serial.println(sht.isConnected()); diff --git a/libraries/SHT31_SW/examples/SHT31_heater/SHT31_heater.ino b/libraries/SHT31_SW/examples/SHT31_heater/SHT31_heater.ino index a260ea69..c930aeed 100644 --- a/libraries/SHT31_SW/examples/SHT31_heater/SHT31_heater.ino +++ b/libraries/SHT31_SW/examples/SHT31_heater/SHT31_heater.ino @@ -16,7 +16,7 @@ SoftWire sw(6, 7); uint32_t start; uint32_t stop; -SHT31_SW sht; +SHT31_SW sht(SHT31_ADDRESS, &sw); uint16_t status; @@ -28,10 +28,10 @@ void setup() Serial.println(SHT31_SW_LIB_VERSION); sw.begin(); - sht.begin(SHT31_ADDRESS, &sw); sw.setClock(100000); + sht.begin(); - sht.setHeatTimeout(30); // heater timeout 30 seconds, just for demo. + sht.setHeatTimeout(30); // heater timeout 30 seconds, just for demo. status = sht.readStatus(); printHeaterStatus(status); @@ -71,4 +71,4 @@ void printHeaterStatus(uint16_t status) } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/libraries/SHT31_SW/examples/SHT31_isConnected/SHT31_isConnected.ino b/libraries/SHT31_SW/examples/SHT31_isConnected/SHT31_isConnected.ino index b43589df..fa5cfe7a 100644 --- a/libraries/SHT31_SW/examples/SHT31_isConnected/SHT31_isConnected.ino +++ b/libraries/SHT31_SW/examples/SHT31_isConnected/SHT31_isConnected.ino @@ -17,7 +17,7 @@ uint32_t start; uint32_t stop; uint32_t connectionFails = 0; -SHT31_SW sht; +SHT31_SW sht(SHT31_ADDRESS, &sw); void setup() @@ -28,8 +28,8 @@ void setup() Serial.println(SHT31_SW_LIB_VERSION); sw.begin(); - sht.begin(SHT31_ADDRESS, &sw); sw.setClock(100000); + sht.begin(); uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); diff --git a/libraries/SHT31_SW/examples/SHT31_lastRead/SHT31_lastRead.ino b/libraries/SHT31_SW/examples/SHT31_lastRead/SHT31_lastRead.ino index a93c44b8..98a1b2a1 100644 --- a/libraries/SHT31_SW/examples/SHT31_lastRead/SHT31_lastRead.ino +++ b/libraries/SHT31_SW/examples/SHT31_lastRead/SHT31_lastRead.ino @@ -16,7 +16,7 @@ SoftWire sw(6, 7); uint32_t start; uint32_t stop; -SHT31_SW sht; +SHT31_SW sht(SHT31_ADDRESS, &sw); void setup() @@ -27,8 +27,8 @@ void setup() Serial.println(SHT31_SW_LIB_VERSION); sw.begin(); - sht.begin(SHT31_ADDRESS, &sw); sw.setClock(100000); + sht.begin(); uint16_t stat = sht.readStatus(); @@ -39,7 +39,7 @@ void setup() void loop() { - sht.read(); // default = true/fast slow = false + sht.read(); // default = true/fast slow = false Serial.print("\t"); Serial.print(sht.lastRead()); Serial.print("\t"); @@ -50,5 +50,5 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/libraries/SHT31_SW/examples/SHT31_rawValues/SHT31_rawValues.ino b/libraries/SHT31_SW/examples/SHT31_rawValues/SHT31_rawValues.ino index e7f45afc..f9c5e785 100644 --- a/libraries/SHT31_SW/examples/SHT31_rawValues/SHT31_rawValues.ino +++ b/libraries/SHT31_SW/examples/SHT31_rawValues/SHT31_rawValues.ino @@ -17,7 +17,7 @@ uint32_t start; uint32_t stop; uint32_t cnt; -SHT31_SW sht; +SHT31_SW sht(SHT31_ADDRESS, &sw); void setup() @@ -28,8 +28,8 @@ void setup() Serial.println(SHT31_SW_LIB_VERSION); sw.begin(); - sht.begin(SHT31_ADDRESS, &sw); sw.setClock(100000); + sht.begin(); uint16_t stat = sht.readStatus(); @@ -49,9 +49,9 @@ void loop() if (sht.dataReady()) { start = micros(); - bool success = sht.readData(); // default = true = fast + bool success = sht.readData(); // default = true = fast stop = micros(); - sht.requestData(); // request for next sample + sht.requestData(); // request for next sample Serial.print("\t"); Serial.print(stop - start); @@ -66,19 +66,23 @@ void loop() rawHumidity = sht.getRawHumidity(); Serial.print(rawTemperature, HEX); Serial.print(" = "); - Serial.print(rawTemperature * (175.0 / 65535) - 45, 1); // This formula comes from page 14 of the SHT31 datasheet + + // This formula comes from page 14 of the SHT31 datasheet + Serial.print(rawTemperature * (175.0 / 65535) - 45, 1); Serial.print("°C\t"); Serial.print(sht.getRawHumidity(), HEX); Serial.print(" = "); - Serial.print(rawHumidity * (100.0 / 65535), 1); // This formula comes from page 14 of the SHT31 datasheet + + // This formula comes from page 14 of the SHT31 datasheet + Serial.print(rawHumidity * (100.0 / 65535), 1); Serial.print("%\t"); Serial.println(cnt); cnt = 0; } } - cnt++; // simulate other activity + cnt++; // simulate other activity } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/libraries/SHT31_SW/examples/SHT31_slowRead/SHT31_slowRead.ino b/libraries/SHT31_SW/examples/SHT31_slowRead/SHT31_slowRead.ino index 9a11ec93..7feafee5 100644 --- a/libraries/SHT31_SW/examples/SHT31_slowRead/SHT31_slowRead.ino +++ b/libraries/SHT31_SW/examples/SHT31_slowRead/SHT31_slowRead.ino @@ -16,7 +16,7 @@ SoftWire sw(6, 7); uint32_t start; uint32_t stop; -SHT31_SW sht; +SHT31_SW sht(SHT31_ADDRESS, &sw); void setup() @@ -27,8 +27,8 @@ void setup() Serial.println(SHT31_SW_LIB_VERSION); sw.begin(); - sht.begin(SHT31_ADDRESS, &sw); sw.setClock(100000); + sht.begin(); uint16_t stat = sht.readStatus(); Serial.print(stat, HEX); diff --git a/libraries/SHT31_SW/library.json b/libraries/SHT31_SW/library.json index f1bd83c5..b33107b3 100644 --- a/libraries/SHT31_SW/library.json +++ b/libraries/SHT31_SW/library.json @@ -31,7 +31,7 @@ "version": "^1.1.2" } ], - "version": "0.1.3", + "version": "0.2.0", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/libraries/SHT31_SW/library.properties b/libraries/SHT31_SW/library.properties index 6bb8107a..dac6b2e7 100644 --- a/libraries/SHT31_SW/library.properties +++ b/libraries/SHT31_SW/library.properties @@ -1,5 +1,5 @@ name=SHT31_SW -version=0.1.3 +version=0.2.0 author=Rob Tillaart , Gunter Haug maintainer=Rob Tillaart sentence=Arduino library for the I2C SHT31 temperature and humidity sensor diff --git a/libraries/SHT31_SW/test/unit_test_001.cpp b/libraries/SHT31_SW/test/unit_test_001.cpp index ec4006fe..fc66232c 100644 --- a/libraries/SHT31_SW/test/unit_test_001.cpp +++ b/libraries/SHT31_SW/test/unit_test_001.cpp @@ -36,7 +36,7 @@ #include "SHT31_SW.h" -int expect; // TODO needed as there seems a problem with 8 bit comparisons (char?) +int expect; // TODO needed as there seems a problem with 8 bit comparisons (char?) uint32_t start, stop;