From 1cf039eb8a5d0af70a99d458201cc0cc2ef2eb23 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Wed, 6 Sep 2023 11:42:30 +0200 Subject: [PATCH] 0.4.2 SHT85 --- libraries/SHT85/CHANGELOG.md | 11 ++- libraries/SHT85/README.md | 33 +++++++- libraries/SHT85/SHT85.cpp | 17 +++- libraries/SHT85/SHT85.h | 11 ++- .../SHT85/examples/SHT85_duo/SHT85_duo.ino | 68 ---------------- .../examples/SHT85_multiplex/.arduino-ci.yml | 29 +++++++ .../SHT85_multiplex/SHT85_multiplex.ino | 78 +++++++++++++++++++ libraries/SHT85/library.json | 2 +- libraries/SHT85/library.properties | 2 +- 9 files changed, 173 insertions(+), 78 deletions(-) delete mode 100644 libraries/SHT85/examples/SHT85_duo/SHT85_duo.ino create mode 100644 libraries/SHT85/examples/SHT85_multiplex/.arduino-ci.yml create mode 100644 libraries/SHT85/examples/SHT85_multiplex/SHT85_multiplex.ino diff --git a/libraries/SHT85/CHANGELOG.md b/libraries/SHT85/CHANGELOG.md index 4f7a02e8..079c104e 100644 --- a/libraries/SHT85/CHANGELOG.md +++ b/libraries/SHT85/CHANGELOG.md @@ -6,12 +6,21 @@ 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-09-05 +- fix #19 SHT85 cannot be address 0x45 +- rewrote begin() +- removed example SHT85_duo +- add example SHT85_multiplex +- add section about multiple SHT85 to readme.md +- redo badges in readme.md +- minor edits + + ## [0.4.1] - 2022-05-09 - add **uint32_t getSerialNumber()** for SHT85 (no CRC check). - improve error handling. - update readme.md - ## [0.4.0] - 2022-12-14 - redo asynchronous interface - add **uint32_t getLastRequest()** timestamp. diff --git a/libraries/SHT85/README.md b/libraries/SHT85/README.md index 1526a03a..b31062de 100644 --- a/libraries/SHT85/README.md +++ b/libraries/SHT85/README.md @@ -1,9 +1,12 @@ -[![Arduino CI](https://github.com/robtillaart/SHT85/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) +[![Arduino CI](https://github.com/RobTillaart/SHT85/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) [![Arduino-lint](https://github.com/RobTillaart/SHT85/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/SHT85/actions/workflows/arduino-lint.yml) [![JSON check](https://github.com/RobTillaart/SHT85/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/SHT85/actions/workflows/jsoncheck.yml) +[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/SHT85.svg)](https://github.com/RobTillaart/SHT85/issues) + [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/SHT85/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/RobTillaart/SHT85.svg?maxAge=3600)](https://github.com/RobTillaart/SHT85/releases) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/SHT85.svg)](https://registry.platformio.org/libraries/robtillaart/SHT85) # SHT85 @@ -34,7 +37,7 @@ Always check datasheet before connecting! ``` -The SHT85 sensors should work up to 1000 KHz. +The SHT85 sensors should work (I2C) up to 1000 KHz. During tests with an Arduino UNO it stopped between 500 - 550 KHz. So to be safe I recommend not to use the sensor above 400 KHz. Also the differences in read time becomes quite small. (max 15% gain). @@ -58,13 +61,13 @@ SPS (= samples per second) are added later. | 550 KHz | ---- | | fail -At 10% load the SHT85 can be used to make about 10-15 SPS. +At 10% load the SHT85 can be used to make about 10 - 15 SPS. #### Compatibility The SHT85 is protocol compatible with the SHT3x series. -Main difference is the accuracy. +Main difference is the accuracy and the SHT85 only has address 0x44. Compare the data sheets to see all differences. Accuracy table: @@ -81,6 +84,16 @@ Note: The SHT40, SHT41 and SHT45 are not protocol compatible with SHT3x and SHT8 The SHT4x series is slightly faster than the SHT3x series. +#### Multiple SHT85 + +The SHT3x comes with two I2C address options, 0x44 and 0x45. +The SHT85 only has 0x44 as I2C address, so it is not possible to have more than +one on a single I2C bus. +This means you need to use multiple I2C buses (if your board support this), +a software I2C (below) or an I2C multiplexer e.g. https://github.com/RobTillaart/TCA9548 + + + #### Related libraries - https://github.com/RobTillaart/SHT2x @@ -94,6 +107,9 @@ An elaborated library for the SHT31 sensor can be found here Dewpoint, heatindex, related functions and conversions. - https://github.com/RobTillaart/Temperature +I2C multiplexer +- https://github.com/RobTillaart/TCA9548 + ## Interface @@ -313,3 +329,12 @@ Will switch the heater off if maximum heating time has passed. - **getKelvin()** wrapper? (no => check temperature class) ==> set Offset to 273.15 ! + +## Support + +If you appreciate my libraries, you can support the development and maintenance. +Improve the quality of the libraries by providing issues and Pull Requests, or +donate through PayPal or GitHub sponsors. + +Thank you, + diff --git a/libraries/SHT85/SHT85.cpp b/libraries/SHT85/SHT85.cpp index 51adba07..73c4020f 100644 --- a/libraries/SHT85/SHT85.cpp +++ b/libraries/SHT85/SHT85.cpp @@ -1,7 +1,7 @@ // // FILE: SHT85.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.4.1 +// VERSION: 0.4.2 // DATE: 2021-02-10 // PURPOSE: Arduino library for the SHT85 temperature and humidity sensor // https://nl.rs-online.com/web/p/temperature-humidity-sensor-ics/1826530 @@ -484,6 +484,21 @@ SHT85::SHT85() _type = 85; } +#if defined(ESP8266) || defined(ESP32) +bool SHT85::begin(const uint8_t address, uint8_t dataPin, uint8_t clockPin) +{ + if (address != 0x44) return false; + return SHT::begin(SHT_DEFAULT_ADDRESS, dataPin, clockPin); +} +#endif + + +bool SHT85::begin(const uint8_t address, TwoWire *wire) +{ + if (address != 0x44) return false; + return SHT::begin(address, wire); +} + uint32_t SHT85::GetSerialNumber() { diff --git a/libraries/SHT85/SHT85.h b/libraries/SHT85/SHT85.h index 650e5889..7c11aea6 100644 --- a/libraries/SHT85/SHT85.h +++ b/libraries/SHT85/SHT85.h @@ -2,7 +2,7 @@ // // FILE: SHT85.h // AUTHOR: Rob Tillaart -// VERSION: 0.4.1 +// VERSION: 0.4.2 // DATE: 2021-02-10 // PURPOSE: Arduino library for the SHT85 temperature and humidity sensor // https://nl.rs-online.com/web/p/temperature-humidity-sensor-ics/1826530 @@ -25,7 +25,7 @@ #include "Wire.h" -#define SHT_LIB_VERSION (F("0.4.1")) +#define SHT_LIB_VERSION (F("0.4.2")) #define SHT85_LIB_VERSION SHT_LIB_VERSION #ifndef SHT_DEFAULT_ADDRESS @@ -184,6 +184,13 @@ class SHT85 : public SHT { public: SHT85(); + +// catch incorrect calls with an address, only 0x44 allowed, see #19 +#if defined(ESP8266) || defined(ESP32) + bool begin(const uint8_t address, uint8_t dataPin, uint8_t clockPin); +#endif + bool begin(const uint8_t address, TwoWire *wire = &Wire); + // EXPERIMENTAL for 0.4.1 uint32_t GetSerialNumber(); }; diff --git a/libraries/SHT85/examples/SHT85_duo/SHT85_duo.ino b/libraries/SHT85/examples/SHT85_duo/SHT85_duo.ino deleted file mode 100644 index dd58feaa..00000000 --- a/libraries/SHT85/examples/SHT85_duo/SHT85_duo.ino +++ /dev/null @@ -1,68 +0,0 @@ -// -// FILE: SHT85_duo.ino -// AUTHOR: Rob Tillaart -// PURPOSE: demo -// URL: https://github.com/RobTillaart/SHT85 -// -// TOPVIEW SHT85 (check datasheet) -// +-------+ -// +-----\ | SDA 4 ----- -// | +-+ ----+ GND 3 ----- -// | +-+ ----+ +5V 2 ----- -// +-----/ | SCL 1 ----- -// +-------+ - - -#include "SHT85.h" - -#define SHT85_ADDRESS 0x44 - -uint32_t start; -uint32_t stop; - -SHT85 sht1; -SHT85 sht2; - - -void setup() -{ - Serial.begin(115200); - Serial.println(__FILE__); - Serial.print("SHT_LIB_VERSION: \t"); - Serial.println(SHT_LIB_VERSION); - - Wire.begin(); - sht1.begin(0x44); - sht2.begin(0x45); - Wire.setClock(100000); - - uint16_t stat = sht1.readStatus(); - Serial.print(stat, HEX); - Serial.println(); - stat = sht2.readStatus(); - Serial.print(stat, HEX); - Serial.println(); - Serial.println(); -} - - -void loop() -{ - Serial.print(millis()); - sht1.read(); // default = true/fast slow = false - Serial.print("\t0x44\t"); - Serial.print(sht1.getTemperature(), 1); - Serial.print("\t"); - Serial.print(sht1.getHumidity(), 1); - - sht2.read(); - Serial.print("\t0x45\t"); - Serial.print(sht2.getTemperature(), 1); - Serial.print("\t"); - Serial.println(sht2.getHumidity(), 1); - delay(100); -} - - -// -- END OF FILE -- - diff --git a/libraries/SHT85/examples/SHT85_multiplex/.arduino-ci.yml b/libraries/SHT85/examples/SHT85_multiplex/.arduino-ci.yml new file mode 100644 index 00000000..37997942 --- /dev/null +++ b/libraries/SHT85/examples/SHT85_multiplex/.arduino-ci.yml @@ -0,0 +1,29 @@ +platforms: + rpipico: + board: rp2040:rp2040:rpipico + package: rp2040:rp2040 + gcc: + features: + defines: + - ARDUINO_ARCH_RP2040 + warnings: + flags: + +packages: + rp2040:rp2040: + url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + +compile: + # Choosing to run compilation tests on 2 different Arduino platforms + platforms: + - uno + # - due + # - zero + # - leonardo + - m4 + - esp32 + - esp8266 + # - mega2560 + - rpipico + libraries: + - TCA9548 diff --git a/libraries/SHT85/examples/SHT85_multiplex/SHT85_multiplex.ino b/libraries/SHT85/examples/SHT85_multiplex/SHT85_multiplex.ino new file mode 100644 index 00000000..ea696115 --- /dev/null +++ b/libraries/SHT85/examples/SHT85_multiplex/SHT85_multiplex.ino @@ -0,0 +1,78 @@ +// +// FILE: SHT85_multiplex.ino +// AUTHOR: Rob Tillaart +// PURPOSE: demo +// URL: https://github.com/RobTillaart/SHT85 +// +// TOPVIEW SHT85 (check datasheet) +// +-------+ +// +-----\ | SDA 4 ----- +// | +-+ ----+ GND 3 ----- +// | +-+ ----+ +5V 2 ----- +// +-----/ | SCL 1 ----- +// +-------+ + +// TODO: test with hardware + +#include "SHT85.h" +#include "TCA9548.h" + +TCA9548 MP(0x70); +#define SHT85_ADDRESS 0x44 + +SHT85 sht; // the object is reused in the multiplexing. + +void setup() +{ + Serial.begin(115200); + Serial.println(__FILE__); + Serial.print("TCA9548_LIB_VERSION: \t"); + Serial.println(TCA9548_LIB_VERSION); + Serial.print("SHT_LIB_VERSION: \t"); + Serial.println(SHT_LIB_VERSION); + + Wire.begin(); + Wire.setClock(100000); + + if (MP.begin() == false) + { + Serial.println("Error: Could not connect to the multiplexer."); + while (1); + } + + // initialize 4 SHT85's + for (int channel = 0; channel < 4; channel++) + { + Serial.print(channel); + MP.selectChannel(channel); // rotate over all SHT85's + if (sht.begin(0x44) == false) + { + Serial.println("\tconnect error.");; + } + else + { + Serial.println("\tOK!.");; + } + delay(10); + } + + Serial.println(); +} + + +void loop() +{ + Serial.print(millis()); + Serial.print("\t"); + for (int channel = 0; channel < 4; channel++) + { + sht.read(); // default = true/fast slow = false + Serial.print(sht.getTemperature(), 1); + Serial.print("\t"); + Serial.print(sht.getHumidity(), 1); + delay(100); + } +} + + +// -- END OF FILE -- diff --git a/libraries/SHT85/library.json b/libraries/SHT85/library.json index 798ade79..01d53868 100644 --- a/libraries/SHT85/library.json +++ b/libraries/SHT85/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/SHT85" }, - "version": "0.4.1", + "version": "0.4.2", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/libraries/SHT85/library.properties b/libraries/SHT85/library.properties index 63da4046..f1cac3b7 100644 --- a/libraries/SHT85/library.properties +++ b/libraries/SHT85/library.properties @@ -1,5 +1,5 @@ name=SHT85 -version=0.4.1 +version=0.4.2 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for the SHT85, SHT30, SHT31, SHT35 Senserion temperature and humidity sensors and compatibles.