0.4.0 SHT2x

This commit is contained in:
Rob Tillaart 2023-09-21 16:37:38 +02:00
parent f7fa184791
commit d8a49ff21b
7 changed files with 57 additions and 54 deletions

View File

@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.4.0] - 2023-09-21
- moved TwoWire param from begin() to Constructor
- FIx #23 support for Wire1 for ESP32
- update readme.md
- minor edits
----
## [0.3.1] - 2023-09-10
- fix #21 example for elaborated async.
- improve async interface
@ -15,7 +23,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- update readme.md
- minor edits
## [0.3.0] - 2023-03-26
- fix setResolution #13, #18
- fix heater settings

View File

@ -59,23 +59,23 @@ or one should switch sensors on/off like the select in SPI communication.
All classes below are derived from SHT2x class.
- **SHT2x()** constructor base class.
- **SHT20()** constructor.
- **SHT21()** constructor.
- **SHT25()** constructor.
- **HTU20()** constructor.
- **HTU21()** constructor.
- **Si7013()** constructor.
- **Si7020()** constructor.
- **Si7021()** constructor.
- **SHT2x(TwoWire \*wire = &Wire)** constructor base class.
Optional set the wire interface for platforms with multiple I2C buses.
- **SHT20(TwoWire \*wire = &Wire)** constructor.
- **SHT21(TwoWire \*wire = &Wire)** constructor.
- **SHT25(TwoWire \*wire = &Wire)** constructor.
- **HTU20(TwoWire \*wire = &Wire)** constructor.
- **HTU21(TwoWire \*wire = &Wire)** constructor.
- **Si7013(TwoWire \*wire = &Wire)** constructor.
- **Si7020(TwoWire \*wire = &Wire)** constructor.
- **Si7021(TwoWire \*wire = &Wire)** constructor.
#### Base interface
- **bool begin(int dataPin, int clockPin)** begin function for ESP8266 & ESP32;
returns false if device address is incorrect or device cannot be reset.
- **bool begin(TwoWire \*wire = &Wire)** optional set the wire interface
for platforms with multiple I2C buses. **begin()** calls **reset()** which can take up to 15 ms.
- **bool begin()** calls **reset()** which can take up to 15 ms.
- **bool read()** Reads both the temperature and humidity.
Initial release has a blocking delay.
- **bool isConnected()** check if sensor is reachable over I2C. Returns false if not connected.

View File

@ -1,7 +1,7 @@
//
// FILE: SHT2x.cpp
// AUTHOR: Rob Tillaart, Viktor Balint
// VERSION: 0.3.1
// VERSION: 0.4.0
// DATE: 2021-09-25
// PURPOSE: Arduino library for the SHT2x temperature and humidity sensor
// URL: https://github.com/RobTillaart/SHT2x
@ -31,8 +31,9 @@
//
// PUBLIC
//
SHT2x::SHT2x()
SHT2x::SHT2x(TwoWire *wire)
{
_wire = wire;
_lastRead = 0;
_lastRequest = 0;
_requestType = SHT2x_REQ_NONE;
@ -51,7 +52,6 @@ SHT2x::SHT2x()
#if defined(ESP8266) || defined(ESP32)
bool SHT2x::begin(const int dataPin, const int clockPin)
{
_wire = &Wire;
if ((dataPin < 255) && (clockPin < 255))
{
_wire->begin(dataPin, clockPin);
@ -63,9 +63,8 @@ bool SHT2x::begin(const int dataPin, const int clockPin)
#endif
bool SHT2x::begin(TwoWire *wire)
bool SHT2x::begin()
{
_wire = wire;
_wire->begin();
return reset();
}
@ -620,17 +619,17 @@ bool SHT2x::readBytes(uint8_t n, uint8_t *val, uint8_t maxDuration)
//
// DERIVED SHT
//
SHT20::SHT20() : SHT2x()
SHT20::SHT20(TwoWire *wire) : SHT2x(wire)
{
}
SHT21::SHT21() : SHT2x()
SHT21::SHT21(TwoWire *wire) : SHT2x(wire)
{
}
SHT25::SHT25() : SHT2x()
SHT25::SHT25(TwoWire *wire) : SHT2x(wire)
{
}
@ -639,12 +638,12 @@ SHT25::SHT25() : SHT2x()
//
// DERIVED HTU
//
HTU20::HTU20() : SHT2x()
HTU20::HTU20(TwoWire *wire) : SHT2x(wire)
{
}
HTU21::HTU21() : SHT2x()
HTU21::HTU21(TwoWire *wire) : SHT2x(wire)
{
}
@ -653,17 +652,17 @@ HTU21::HTU21() : SHT2x()
//
// DERIVED Si70xx
//
Si7013::Si7013() : SHT2x()
Si7013::Si7013(TwoWire *wire) : SHT2x(wire)
{
}
Si7020::Si7020() : SHT2x()
Si7020::Si7020(TwoWire *wire) : SHT2x(wire)
{
}
Si7021::Si7021() : SHT2x()
Si7021::Si7021(TwoWire *wire) : SHT2x(wire)
{
}
@ -672,7 +671,7 @@ Si7021::Si7021() : SHT2x()
//
// DERIVED Si70xx
//
GY21::GY21() : SHT2x()
GY21::GY21(TwoWire *wire) : SHT2x(wire)
{
}

View File

@ -2,7 +2,7 @@
//
// FILE: SHT2x.h
// AUTHOR: Rob Tillaart, Viktor Balint
// VERSION: 0.3.1
// VERSION: 0.4.0
// DATE: 2021-09-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.3.1"))
#define SHT2x_LIB_VERSION (F("0.4.0"))
// fields getStatus
@ -48,12 +48,12 @@
class SHT2x
{
public:
SHT2x();
SHT2x(TwoWire *wire = &Wire);
#if defined(ESP8266) || defined(ESP32)
bool begin(const int dataPin, const int clockPin);
#endif
bool begin(TwoWire *wire = &Wire);
bool begin();
// check sensor is reachable over I2C
bool isConnected();
@ -201,21 +201,21 @@ protected:
class SHT20 : public SHT2x
{
public:
SHT20();
SHT20(TwoWire *wire = &Wire);
};
class SHT21 : public SHT2x
{
public:
SHT21();
SHT21(TwoWire *wire = &Wire);
};
class SHT25 : public SHT2x
{
public:
SHT25();
SHT25(TwoWire *wire = &Wire);
};
@ -226,14 +226,14 @@ public:
class HTU20 : public SHT2x
{
public:
HTU20();
HTU20(TwoWire *wire = &Wire);
};
class HTU21 : public SHT2x
{
public:
HTU21();
HTU21(TwoWire *wire = &Wire);
};
@ -244,21 +244,21 @@ public:
class Si7013 : public SHT2x
{
public:
Si7013();
Si7013(TwoWire *wire = &Wire);
};
class Si7020 : public SHT2x
{
public:
Si7020();
Si7020(TwoWire *wire = &Wire);
};
class Si7021 : public SHT2x
{
public:
Si7021();
Si7021(TwoWire *wire = &Wire);
};
@ -269,7 +269,7 @@ public:
class GY21 : public SHT2x
{
public:
GY21();
GY21(TwoWire *wire = &Wire);
};

View File

@ -9,15 +9,13 @@
#include "Wire.h"
#include "SHT2x.h"
#define SDA_1 21
#define SCL_1 22
#define SDA_2 33
#define SCL_2 32
#define SDA_1 21
#define SCL_1 22
#define SDA_2 33
#define SCL_2 32
TwoWire I2Cone = TwoWire(0);
TwoWire I2Ctwo = TwoWire(1);
SHT2x internal;
SHT2x external;
SHT2x internal(&Wire);
SHT2x external(&Wire1);
uint32_t start;
uint32_t stop;
@ -30,11 +28,11 @@ void setup()
Serial.print("SHT2x_LIB_VERSION: \t");
Serial.println(SHT2x_LIB_VERSION);
I2Cone.begin(SDA_1, SCL_1);
I2Ctwo.begin(SDA_2, SCL_2);
Wire.begin(SDA_1, SCL_1);
Wire1.begin(SDA_2, SCL_2);
internal.begin(&I2Cone);
external.begin(&I2Ctwo);
internal.begin();
external.begin();
uint8_t stat = internal.getStatus();
Serial.print(stat, HEX);
@ -68,4 +66,3 @@ void loop()
// -- END OF FILE --

View File

@ -18,7 +18,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/SHT2x.git"
},
"version": "0.3.1",
"version": "0.4.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=SHT2x
version=0.3.1
version=0.4.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for the I2C SHT20 SHT21 SHT25 series temperature and humidity sensor.