Sensirion SHT40, SHT41, and SHT45 topic
- Introduction
- Sensor Datasheet
- Sensor Constructors
- Example Code
- Reference
- Detailed Descriptions
Classes for the Sensirion SHT40, SHT41, and SHT45 I2C humidity and temperature sensors.
Introduction
SHT4x is a digital sensor platform for measuring relative humidity and temperature at different accuracy classes. The I2C interface provides several preconfigured I2C addresses and maintains an ultra-low power budget. The power-trimmed internal heater can be used at three heating levels thus enabling sensor operation in demanding environments.
- The code for this library should work for 0x44 addressed SHT4x sensors - the SHT40, SHT41, and SHT45.
- Depends on the Adafruit SHT4x Library.
- Communicates via I2C
- There are versions of the SHT40, SHT40-AD1B with the I2C address 0x44 and SHT40-BD1B with the I2C address 0x45. This library only supports the 0x44 addressed sensor!
- The SHT41 and SHT45 only have one possible address, 0x44.
- Only 1 can be connected to a single I2C bus at a time
- Requires a 3.3 power source
Sensor Datasheet
Sensor Constructors
SensirionSHT4x:: SensirionSHT4x(int8_t powerPin,
bool useHeater = true,
uint8_t measurementsToAverage = 1) explicit
Construct a new SensirionSHT4x object using the primary hardware I2C instance.
Parameters | |
---|---|
powerPin | The pin on the mcu controlling power to the Sensirion SHT4x. Use -1 if it is continuously powered.
|
useHeater | Whether or not to run the internal heater of the SHT4x when shutting down the sensor; optional with a default value of true. The internal heater is designed to remove condensed water from the sensor - which will make the sensor stop responding to air humidity changes - and to allow creep-free operation in high humidity environments. The longest the internal heater can run at a time is 1s and the maximum duty load is 5%. Running only 1s per measurement cycle probably isn't enough to help with more than very minimal condensation, but it's probably the best we can easily do. |
measurementsToAverage | The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1. |
Because this is I2C and has only 1 possible address (0x44), we only need the power pin.
Example Code
The SHT40 is used in the menu a la carte example
Classes
- class SensirionSHT4x
- The Sensor sub-class for the Sensirion SHT4x.
- class SensirionSHT4x_Humidity
- The Variable sub-class used for the relative humidity output from an Sensirion SHT4x.
- class SensirionSHT4x_Temp
- The Variable sub-class used for the temperature output from an Sensirion SHTx0.
Sensor Variable Counts
The number of variables that can be returned by the SHT4x
- #define SHT4X_NUM_VARIABLES = 2
- Sensor::
_numReturnedValues; the SHT4x can report 2 values. - #define SHT4X_INC_CALC_VARIABLES = 0
- Sensor::
_incCalcValues; we don't calculate any additional values.
Sensor Timing
The sensor timing for an Sensirion SHT4x
- #define SHT4X_WARM_UP_TIME_MS = 1
- Sensor::
_warmUpTime_ms; SHT4x warms up in 0.3ms (typical) and soft-resets in 1ms (max). - #define SHT4X_STABILIZATION_TIME_MS = 0
- Sensor::
_stabilizationTime_ms; SHT4x is assumed to be immediately stable. - #define SHT4X_MEASUREMENT_TIME_MS = 9
- Sensor::
_measurementTime_ms; SHT4x takes 8.2ms (max) to complete a measurement at the highest precision. At medium precision measurement time is 4.5ms (max) and it is 1.7ms (max) at low precision.
Humidity
The humidity variable from an Sensirion SHT4x
- Range is 0 to 100% RH
- Accuracy is ± 1.8 % RH (typical)
SensirionSHT4x_ Humidity:: SensirionSHT4x_Humidity(SensirionSHT4x* parentSense,
const char* uuid = "",
const char* varCode = "SHT4xHumidity") explicit
Construct a new SensirionSHT4x_
Parameters | |
---|---|
parentSense | The parent SensirionSHT4x providing the result values. |
uuid | A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string. |
varCode | A short code to help identify the variable in files; optional with a default value of "SHT4xHumidity". |
- #define SHT4X_HUMIDITY_RESOLUTION = 2
- Decimals places in string representation; humidity should have 2 (0.01 % RH).
- #define SHT4X_HUMIDITY_VAR_NUM = 0
- Sensor variable number; humidity is stored in sensorValues[0].
- #define SHT4X_HUMIDITY_VAR_NAME = "relativeHumidity"
- Variable name in ODM2 controlled vocabulary; "relativeHumidity".
- #define SHT4X_HUMIDITY_UNIT_NAME = "percent"
- Variable unit name in ODM2 controlled vocabulary; "percent" (percent relative humidity)
- #define SHT4X_HUMIDITY_DEFAULT_CODE = "SHT4xHumidity"
- Default variable short code; "SHT4xHumidity".
Temperature
The temperature variable from an Sensirion SHT4x
- Range is -40°C to +125°C
- Accuracy is ±0.2°C
SensirionSHT4x_ Temp:: SensirionSHT4x_Temp(SensirionSHT4x* parentSense,
const char* uuid = "",
const char* varCode = "SHT4xTemp") explicit
Construct a new SensirionSHT4x_
Parameters | |
---|---|
parentSense | The parent SensirionSHT4x providing the result values. |
uuid | A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string. |
varCode | A short code to help identify the variable in files; optional with a default value of "SHT4xTemp". |
- #define SHT4X_TEMP_RESOLUTION = 2
- Decimals places in string representation; humidity should have 2 (0.01 °C).
- #define SHT4X_TEMP_VAR_NUM = 1
- Sensor variable number; temperature is stored in sensorValues[1].
- #define SHT4X_TEMP_VAR_NAME = "temperature"
- Variable name in ODM2 controlled vocabulary; "temperature".
- #define SHT4X_TEMP_UNIT_NAME = "degreeCelsius"
- Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
- #define SHT4X_TEMP_DEFAULT_CODE = "SHT4xTemp"
- Default variable short code; "SHT4xTemp".
Define documentation
#define SHT4X_NUM_VARIABLES = 2
#include <src/sensors/SensirionSHT4x.h>
Sensor::
#define SHT4X_INC_CALC_VARIABLES = 0
#include <src/sensors/SensirionSHT4x.h>
Sensor::
#define SHT4X_WARM_UP_TIME_MS = 1
#include <src/sensors/SensirionSHT4x.h>
Sensor::
#define SHT4X_STABILIZATION_TIME_MS = 0
#include <src/sensors/SensirionSHT4x.h>
Sensor::
#define SHT4X_MEASUREMENT_TIME_MS = 9
#include <src/sensors/SensirionSHT4x.h>
Sensor::
#define SHT4X_HUMIDITY_RESOLUTION = 2
#include <src/sensors/SensirionSHT4x.h>
Decimals places in string representation; humidity should have 2 (0.01 % RH).
#define SHT4X_HUMIDITY_VAR_NUM = 0
#include <src/sensors/SensirionSHT4x.h>
Sensor variable number; humidity is stored in sensorValues[0].
#define SHT4X_HUMIDITY_VAR_NAME = "relativeHumidity"
#include <src/sensors/SensirionSHT4x.h>
Variable name in ODM2 controlled vocabulary; "relativeHumidity".
#define SHT4X_HUMIDITY_UNIT_NAME = "percent"
#include <src/sensors/SensirionSHT4x.h>
Variable unit name in ODM2 controlled vocabulary; "percent" (percent relative humidity)
#define SHT4X_HUMIDITY_DEFAULT_CODE = "SHT4xHumidity"
#include <src/sensors/SensirionSHT4x.h>
Default variable short code; "SHT4xHumidity".
#define SHT4X_TEMP_RESOLUTION = 2
#include <src/sensors/SensirionSHT4x.h>
Decimals places in string representation; humidity should have 2 (0.01 °C).
#define SHT4X_TEMP_VAR_NUM = 1
#include <src/sensors/SensirionSHT4x.h>
Sensor variable number; temperature is stored in sensorValues[1].
#define SHT4X_TEMP_VAR_NAME = "temperature"
#include <src/sensors/SensirionSHT4x.h>
Variable name in ODM2 controlled vocabulary; "temperature".
#define SHT4X_TEMP_UNIT_NAME = "degreeCelsius"
#include <src/sensors/SensirionSHT4x.h>
Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
#define SHT4X_TEMP_DEFAULT_CODE = "SHT4xTemp"
#include <src/sensors/SensirionSHT4x.h>
Default variable short code; "SHT4xTemp".