0.4.1 SHT2X

This commit is contained in:
Rob Tillaart 2023-11-27 09:44:42 +01:00
parent 7a54362066
commit 675e9eb012
6 changed files with 43 additions and 26 deletions

View File

@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.4.1] - 2023-11-25
- fix **reset()**: clear state of resolution, heater and error
- update readme.md
- minor edits
## [0.4.0] - 2023-09-21
- moved TwoWire param from begin() to Constructor
- FIx #23 support for Wire1 for ESP32

View File

@ -26,9 +26,9 @@ Accuracy table
| Sensor | Temperature | Humidity | Notes |
|:---------:|:-----------:|:--------:|:--------|
| SHT20 | ~0.3 | ±3.0 | |
| SHT21 | ~0.3 | ±3.0 | |
| SHT25 | ~0.3 | ±1.8 | |
| SHT20 | ~0.3 | ±3.0 | |
| SHT21 | ~0.3 | ±3.0 | |
| SHT25 | ~0.3 | ±1.8 | |
| HTU20 | | | to-do |
| HTU21 | | | to-do |
| Si7013 | | | to-do |
@ -83,7 +83,7 @@ Initial release has a blocking delay.
- **uint32_t lastRead()** in milliSeconds since start of program.
- **bool reset()** resets the sensor, soft reset, no hard reset supported.
- **float getHumidity()** computes the relative humidity in % based off the latest raw reading, and returns it.
- **float getTemperature()** computes the temperature in °C based off the latest raw reading, and returns it.
- **float getTemperature()** computes the temperature in °C based off the latest raw reading, and returns it.
- **uint16_t getRawHumidity()** returns the raw two-byte representation of humidity directly from the sensor.
- **uint16_t getRawTemperature()** returns the raw two-byte representation of temperature directly from the sensor.
@ -244,6 +244,9 @@ Timing in milliseconds.
- investigate blocking delay() in read
- add offset for temperature and humidity
#### 0.4.1
- fix reset(): clear state of resolution, heater and error
#### Should
- test test test

View File

@ -1,8 +1,8 @@
//
// FILE: SHT2x.cpp
// AUTHOR: Rob Tillaart, Viktor Balint
// VERSION: 0.4.0
// DATE: 2021-09-25
// AUTHOR: Rob Tillaart, Viktor Balint, JensB
// VERSION: 0.4.1
// DATE: 2023-11-25
// PURPOSE: Arduino library for the SHT2x temperature and humidity sensor
// URL: https://github.com/RobTillaart/SHT2x
@ -11,20 +11,20 @@
// SUPPORTED COMMANDS
#define SHT2x_GET_TEMPERATURE_NO_HOLD 0xF3
#define SHT2x_GET_HUMIDITY_NO_HOLD 0xF5
#define SHT2x_SOFT_RESET 0xFE
#define SHT2x_WRITE_USER_REGISTER 0xE6
#define SHT2x_READ_USER_REGISTER 0xE7
#define SHT2x_GET_TEMPERATURE_NO_HOLD 0xF3
#define SHT2x_GET_HUMIDITY_NO_HOLD 0xF5
#define SHT2x_SOFT_RESET 0xFE
#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
#define SHT2x_ADDRESS 0x40
#define SHT2x_USRREG_RESOLUTION 0x81
#define SHT2x_USRREG_BATTERY 0x20
#define SHT2x_USRREG_HEATER 0x04
#define SHT2x_USRREG_RESOLUTION 0x81
#define SHT2x_USRREG_BATTERY 0x20
#define SHT2x_USRREG_HEATER 0x04
//////////////////////////////////////////////////////////////
@ -273,8 +273,14 @@ uint16_t SHT2x::getRawHumidity()
bool SHT2x::reset()
{
bool b = writeCmd(SHT2x_SOFT_RESET);
return b;
bool success = writeCmd(SHT2x_SOFT_RESET);
if (success)
{
_resolution = 0;
_heaterOn = false;
_error = SHT2x_OK;
}
return success;
}

View File

@ -1,9 +1,9 @@
#pragma once
//
// FILE: SHT2x.h
// AUTHOR: Rob Tillaart, Viktor Balint
// VERSION: 0.4.0
// DATE: 2021-09-25
// AUTHOR: Rob Tillaart, Viktor Balint, JensB
// VERSION: 0.4.1
// DATE: 2023-11-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.4.0"))
#define SHT2x_LIB_VERSION (F("0.4.1"))
// fields getStatus
@ -63,7 +63,7 @@ public:
//
// TEMPERATURE AND HUMIDTY
//
// read must be called get getTemperature / getHumidity
// read must be called before calling getTemperature / getHumidity
bool read();
float getTemperature();

View File

@ -11,6 +11,9 @@
},
{
"name": "Viktor Balint"
},
{
"name": "JensB"
}
],
"repository":
@ -18,7 +21,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/SHT2x.git"
},
"version": "0.4.0",
"version": "0.4.1",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

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