0.2.1 SHT2x

This commit is contained in:
rob tillaart 2022-11-24 14:09:52 +01:00
parent 8948c69a81
commit 49ddc35547
9 changed files with 155 additions and 39 deletions

View File

@ -1,3 +1,18 @@
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:
@ -7,5 +22,6 @@ compile:
# - leonardo
- m4
- esp32
# - esp8266
#- mega2560
- esp8266
# - mega2560
- rpipico

View File

@ -0,0 +1,43 @@
# Change Log SHT2x
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.1] - 2022-11-24
- Add RP2040 support to build-CI.
- Add CHANGELOG.md
## [0.2.0] - 2022-07-10
- Fix #11 RawTemp + rawHum (kudos to theandy94)
- add experimental getResolution() + setResolution()
- adjust read delay
- add experimental batteryOK()
- add CRC in read() - no fail.
----
## [0.1.4] - 2022-06-21
- Fix #9 ESP32 wire.begin()
- Fix getEIDB() bug.
## [0.1.3] - 2021-12-28
- update library.json
- update license
- minor edits
## [0.1.2] - 2021-09-29
- Add Si70xx derived classes
- add getEIDA(), getEIDB(), getFirmwareVersion()
- update build-CI, readme.md badges
## [0.1.1] - 2021-09-28
- Add HTU2x derived classes,
- update readme.md + add some status info
## [0.1.0] - 2021-09-25
- initial version

View File

@ -187,20 +187,11 @@ Timing in milliseconds.
## Future
- test test test
- get hardware
- investigate resolution anomalies
#### must
- improve documentation
- fix TODO in code (.cpp and .h)
- add examples
- test resolutions
- performance different resolutions
- test battery
- update unit tests
#### 0.3.0
- add crc8 check (need sensor)
- improve error handling (all code paths)
- investigate blocking delay() in read
@ -208,6 +199,22 @@ Timing in milliseconds.
- **void requestTemperature()** ==> **void readTemperature()**
- **void requestHumidity()** ==> **void readHumidity()**
#### should
- test test test
- get hardware
- add examples
- test resolutions
- performance different resolutions
- test battery
#### could
- investigate resolution anomalies
- fix TODO in code (.cpp and .h)
- update unit tests
#### wont
- add **getSerialNumber()**

View File

@ -1,28 +1,10 @@
//
// FILE: SHT2x.cpp
// AUTHOR: Rob Tillaart, Viktor Balint
// VERSION: 0.2.0
// VERSION: 0.2.1
// DATE: 2021-09-25
// PURPOSE: Arduino library for the SHT2x temperature and humidity sensor
// URL: https://github.com/RobTillaart/SHT2x
//
// HISTORY:
// 0.1.0 2021-09-25 initial version
// 0.1.1 2021-09-28 Add HTU2x derived classes,
// update readme.md + add some status info
// 0.1.2 2021-09-29 Add Si70xx derived classes
// add getEIDA(), getEIDB(), getFirmwareVersion()
// update build-CI, readme.md badges
// 0.1.3 2021-12-28 update library.json, license, minor edits
// 0.1.4 2022-06-21 Fix #9 ESP32 wire.begin()
// Fix getEIDB() bug.
//
// 0.2.0 2022-07-10 Fix #11 RawTemp + rawHum (kudos to theandy94)
// add experimental getResolution() + setResolution()
// adjust read delay
// add experimental batteryOK()
// add CRC in read() - no fail.
#include "SHT2x.h"
@ -35,7 +17,7 @@
#define SHT2x_WRITE_USER_REGISTER 0xE6
#define SHT2x_READ_USER_REGISTER 0xE7
#define SHT2x_HEATER_TIMEOUT 180000UL // milliseconds
#define SHT2x_HEATER_TIMEOUT 180000UL // milliseconds
#define SHT2x_ADDRESS 0x40

View File

@ -2,7 +2,7 @@
//
// FILE: SHT2x.h
// AUTHOR: Rob Tillaart, Viktor Balint
// VERSION: 0.2.0
// VERSION: 0.2.1
// 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.2.0"))
#define SHT2x_LIB_VERSION (F("0.2.1"))
// fields getStatus
@ -119,7 +119,7 @@ public:
bool batteryOK();
private:
protected:
uint8_t crc8(const uint8_t *data, uint8_t len);
bool writeCmd(uint8_t cmd);
@ -127,9 +127,9 @@ private:
bool readBytes(uint8_t n, uint8_t *val, uint8_t maxDuration);
TwoWire* _wire;
uint8_t _heatTimeout; // seconds
uint8_t _heatTimeout; // seconds
uint32_t _lastRead;
uint32_t _lastRequest; // for async interface
uint32_t _lastRequest; // for async interface
uint32_t _heaterStart;
uint32_t _heaterStop;
bool _heaterOn;

View File

@ -0,0 +1,27 @@
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

View File

@ -0,0 +1,41 @@
//
// FILE: SHT2x_demo.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// URL: https://github.com/RobTillaart/SHT2x
#include "Wire.h"
#include "SHT2x.h"
uint32_t start;
uint32_t stop;
SHT2x sht;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("SHT2x_LIB_VERSION: \t");
Serial.println(SHT2x_LIB_VERSION);
sht.begin();
// uint8_t buf[3] = { 0x7C, 0x82, 0 };
// Serial.println(sht.crc8(buf, 2), HEX); // 97
// uint8_t buf[3] = { 0x68, 0x3A, 0 };
// Serial.println(sht.crc8(buf, 2), HEX); // 7C
uint8_t buf[3] = { 0x4E, 0x85, 0 };
Serial.println(sht.crc8(buf, 2), HEX); // 6B
}
void loop()
{
}
// -- END OF FILE --

View File

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

View File

@ -1,5 +1,5 @@
name=SHT2x
version=0.2.0
version=0.2.1
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.