0.5.0 SHT85

This commit is contained in:
Rob Tillaart 2023-09-21 16:40:54 +02:00
parent 64cca7e6d6
commit b83d5eba75
7 changed files with 38 additions and 43 deletions

View File

@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.5.0] - 2023-09-21
- fix #21, support Wire1 for ESP32
- move TwoWire selection to constructor.
- update readme.md
----
## [0.4.2] - 2023-09-05
- fix #19 SHT85 cannot be address 0x45
- rewrote begin()
@ -15,7 +22,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- 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.

View File

@ -120,21 +120,20 @@ I2C multiplexer
#### Base interface
- **SHT()** constructor of the base class. **getType()** will return 0.
- **SHT30()** constructor.
- **SHT31()** constructor.
- **SHT35()** constructor.
- **SHT85()** constructor.
- **SHT(TwoWire \*wire = &Wire)** constructor of the base class. **getType()** will return 0.
- **SHT30(TwoWire \*wire = &Wire)** constructor. Optional select the I2C bus (Wire, Wire1 etc).
- **SHT31(TwoWire \*wire = &Wire)** constructor. Optional select the I2C bus (Wire, Wire1 etc).
- **SHT35(TwoWire \*wire = &Wire)** constructor. Optional select the I2C bus (Wire, Wire1 etc).
- **SHT85(TwoWire \*wire = &Wire)** constructor. Optional select the I2C bus (Wire, Wire1 etc).
- **uint8_t getType()** returns numeric part of sensor type.
Returns 0 for the base class.
- **bool begin(uint8_t address, uint8_t dataPin, uint8_t clockPin)** begin function for ESP8266, ESP32 and similar. **WARNING: not verified yet**.
- **bool begin(uint8_t address, uint8_t dataPin, uint8_t clockPin)** begin function for ESP8266, ESP32 and similar.
**WARNING: not verified yet**.
Returns false if device address is incorrect or device cannot be reset.
- **bool begin(uint8_t dataPin, uint8_t clockPin)** same as above.
Uses SHT_DEFAULT_ADDRESS (0x44) as address.
- **bool begin(uint8_t address, TwoWire \*wire = &Wire)** for platforms with multiple I2C buses. The default I2C bus is Wire.
- **bool begin(uint8_t address = SHT_DEFAULT_ADDRESS)**
Returns false if device address is incorrect or device cannot be reset.
- **bool begin(TwoWire \*wire = &Wire)** same as above.
Uses SHT_DEFAULT_ADDRESS (0x44) as address.
#### Status

View File

@ -1,7 +1,7 @@
//
// FILE: SHT85.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.4.2
// VERSION: 0.5.0
// 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
@ -29,10 +29,10 @@
#define SHT_GET_SERIAL 0x3682
SHT::SHT()
SHT::SHT(TwoWire *wire)
{
_address = 0;
_wire = NULL;
_wire = wire;
_lastRead = 0;
_rawTemperature = 0;
_rawHumidity = 0;
@ -74,25 +74,18 @@ bool SHT::begin(const uint8_t dataPin, const uint8_t clockPin)
#endif
bool SHT::begin(const uint8_t address, TwoWire *wire)
bool SHT::begin(const uint8_t address)
{
if ((address != 0x44) && (address != 0x45))
{
return false;
}
_address = address;
_wire = wire;
_wire->begin();
return reset();
}
bool SHT::begin(TwoWire *wire)
{
return begin(SHT_DEFAULT_ADDRESS, wire);
}
uint8_t SHT::getType()
{
return _type;
@ -461,25 +454,25 @@ bool SHT::readBytes(uint8_t n, uint8_t *val)
//
// DERIVED CLASSES
//
SHT30::SHT30()
SHT30::SHT30(TwoWire *wire) : SHT(wire)
{
_type = 30;
}
SHT31::SHT31()
SHT31::SHT31(TwoWire *wire) : SHT(wire)
{
_type = 31;
}
SHT35::SHT35()
SHT35::SHT35(TwoWire *wire) : SHT(wire)
{
_type = 35;
}
SHT85::SHT85()
SHT85::SHT85(TwoWire *wire) : SHT(wire)
{
_type = 85;
}
@ -493,10 +486,10 @@ bool SHT85::begin(const uint8_t address, uint8_t dataPin, uint8_t clockPin)
#endif
bool SHT85::begin(const uint8_t address, TwoWire *wire)
bool SHT85::begin(const uint8_t address)
{
if (address != 0x44) return false;
return SHT::begin(address, wire);
return SHT::begin(address);
}

View File

@ -2,7 +2,7 @@
//
// FILE: SHT85.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.2
// VERSION: 0.5.0
// 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.2"))
#define SHT_LIB_VERSION (F("0.5.0"))
#define SHT85_LIB_VERSION SHT_LIB_VERSION
#ifndef SHT_DEFAULT_ADDRESS
@ -58,7 +58,7 @@
class SHT
{
public:
SHT();
SHT(TwoWire *wire = &Wire);
#if defined(ESP8266) || defined(ESP32)
bool begin(const uint8_t address, uint8_t dataPin, uint8_t clockPin);
@ -66,9 +66,7 @@ public:
bool begin(const uint8_t dataPin, const uint8_t clockPin);
#endif
bool begin(const uint8_t address, TwoWire *wire = &Wire);
// use SHT_DEFAULT_ADDRESS
bool begin(TwoWire *wire = &Wire);
bool begin(const uint8_t address = SHT_DEFAULT_ADDRESS);
uint8_t getType();
@ -162,34 +160,34 @@ protected:
class SHT30 : public SHT
{
public:
SHT30();
SHT30(TwoWire *wire = &Wire);
};
class SHT31 : public SHT
{
public:
SHT31();
SHT31(TwoWire *wire = &Wire);
};
class SHT35 : public SHT
{
public:
SHT35();
SHT35(TwoWire *wire = &Wire);
};
class SHT85 : public SHT
{
public:
SHT85();
SHT85(TwoWire *wire = &Wire);
// 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);
bool begin(const uint8_t address = SHT_DEFAULT_ADDRESS);
// EXPERIMENTAL for 0.4.1
uint32_t GetSerialNumber();

View File

@ -23,6 +23,7 @@ uint32_t stop;
uint16_t count = 0;
uint32_t last = 0;
// SHT85 sht(&Wire1);
SHT85 sht;
@ -67,5 +68,3 @@ void loop()
// -- END OF FILE --

View File

@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/SHT85"
},
"version": "0.4.2",
"version": "0.5.0",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "SHT85.h"
}

View File

@ -1,5 +1,5 @@
name=SHT85
version=0.4.2
version=0.5.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for the SHT85, SHT30, SHT31, SHT35 Senserion temperature and humidity sensors and compatibles.