Class Sht3x
A Sensirion SHT3x-DIS humidity and temperature sensor. Every call goes straight to the pamoja C ABI, which decodes exactly what the manufacturer's datasheet specifies.
public static class Sht3x
- Inheritance
-
Sht3x
- Inherited Members
Methods
Celsius(ushort)
Converts a raw SHT3x temperature word to degrees Celsius.
public static float Celsius(ushort raw)
Parameters
rawushortThe raw.
Returns
- float
The value the C ABI computes.
Crc(ReadOnlySpan<byte>)
Computes the CRC-8 an SHT3x appends to every data word.
public static byte Crc(ReadOnlySpan<byte> data)
Parameters
dataReadOnlySpan<byte>The data.
Returns
- byte
The value the C ABI computes.
Fahrenheit(ushort)
Converts a raw SHT3x temperature word to degrees Fahrenheit.
public static float Fahrenheit(ushort raw)
Parameters
rawushortThe raw.
Returns
- float
The value the C ABI computes.
HumidityRawFromMilliPercent(uint)
Builds the SHT3x humidity word that decodes to a relative humidity.
public static ushort HumidityRawFromMilliPercent(uint milliPercent)
Parameters
milliPercentuintThe milli percent.
Returns
- ushort
The value the C ABI computes.
HumidityRawFromRelativeHumidity(float)
Builds the SHT3x humidity word that decodes to a relative humidity percentage.
public static ushort HumidityRawFromRelativeHumidity(float percent)
Parameters
percentfloatThe percent.
Returns
- ushort
The value the C ABI computes.
IntervalMicros(byte)
Returns the gap between SHT3x periodic measurements at a rate.
public static uint IntervalMicros(byte rate)
Parameters
ratebyteThe rate.
Returns
- uint
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
MaxMeasurementMicros(byte)
Returns how long an SHT3x measurement may take at a repeatability.
public static uint MaxMeasurementMicros(byte repeatability)
Parameters
repeatabilitybyteThe repeatability.
Returns
- uint
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
MeasurementBytes(ushort, ushort)
Builds the six bytes an SHT3x sends for a pair of raw words.
public static byte[] MeasurementBytes(ushort temperatureRaw, ushort humidityRaw)
Parameters
Returns
- byte[]
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
MilliCelsius(ushort)
Converts a raw SHT3x temperature word to milli-degrees Celsius.
public static int MilliCelsius(ushort raw)
Parameters
rawushortThe raw.
Returns
- int
The value the C ABI computes.
MilliFahrenheit(ushort)
Converts a raw SHT3x temperature word to milli-degrees Fahrenheit.
public static int MilliFahrenheit(ushort raw)
Parameters
rawushortThe raw.
Returns
- int
The value the C ABI computes.
MilliPercent(ushort)
Converts a raw SHT3x humidity word to milli-percent.
public static uint MilliPercent(ushort raw)
Parameters
rawushortThe raw.
Returns
- uint
The value the C ABI computes.
ParseMeasurement(ReadOnlySpan<byte>)
Parses and CRC-checks a six-byte SHT3x measurement frame.
public static PamojaSht3xMeasurement ParseMeasurement(ReadOnlySpan<byte> frame)
Parameters
frameReadOnlySpan<byte>The frame.
Returns
- PamojaSht3xMeasurement
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
ParseStatus(ReadOnlySpan<byte>)
Parses and CRC-checks a three-byte SHT3x status frame.
public static PamojaSht3xStatus ParseStatus(ReadOnlySpan<byte> frame)
Parameters
frameReadOnlySpan<byte>The frame.
Returns
- PamojaSht3xStatus
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
Periodic(byte, byte)
Returns the SHT3x periodic-mode command for a repeatability and rate.
public static ushort Periodic(byte repeatability, byte rate)
Parameters
Returns
- ushort
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
RelativeHumidity(ushort)
Converts a raw SHT3x humidity word to a relative humidity percentage.
public static float RelativeHumidity(ushort raw)
Parameters
rawushortThe raw.
Returns
- float
The value the C ABI computes.
SingleShot(byte, bool)
Returns the SHT3x single-shot command for a repeatability and clock mode.
public static ushort SingleShot(byte repeatability, bool clockStretching)
Parameters
Returns
- ushort
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
StatusBytes(ushort)
Builds the three bytes an SHT3x sends for a status word, CRC last.
public static byte[] StatusBytes(ushort bits)
Parameters
bitsushortThe bits.
Returns
- byte[]
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
StatusFromBits(ushort)
Splits an SHT3x status word into its flags.
public static PamojaSht3xStatus StatusFromBits(ushort bits)
Parameters
bitsushortThe bits.
Returns
- PamojaSht3xStatus
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
TemperatureRawFromCelsius(float)
Builds the SHT3x temperature word that decodes to a temperature in Celsius.
public static ushort TemperatureRawFromCelsius(float celsius)
Parameters
celsiusfloatThe celsius.
Returns
- ushort
The value the C ABI computes.
TemperatureRawFromMilliCelsius(int)
Builds the SHT3x temperature word that decodes to a temperature.
public static ushort TemperatureRawFromMilliCelsius(int milliCelsius)
Parameters
milliCelsiusintThe milli celsius.
Returns
- ushort
The value the C ABI computes.
TemperatureRawFromMilliFahrenheit(int)
Builds the SHT3x temperature word that decodes to a temperature in Fahrenheit.
public static ushort TemperatureRawFromMilliFahrenheit(int milliFahrenheit)
Parameters
milliFahrenheitintThe milli fahrenheit.
Returns
- ushort
The value the C ABI computes.
TypicalMeasurementMicros(byte)
Returns how long an SHT3x measurement typically takes at a repeatability.
public static uint TypicalMeasurementMicros(byte repeatability)
Parameters
repeatabilitybyteThe repeatability.
Returns
- uint
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
Word(ReadOnlySpan<byte>)
Reads a CRC-checked three-byte SHT3x word frame.
public static ushort Word(ReadOnlySpan<byte> frame)
Parameters
frameReadOnlySpan<byte>The frame.
Returns
- ushort
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
WordBytes(ushort)
Builds the three bytes an SHT3x sends for a word: the word then its CRC.
public static byte[] WordBytes(ushort value)
Parameters
valueushortThe value.
Returns
- byte[]
The decoded value.
Exceptions
- PamojaException
The device data is not valid.