HTU21D Class
- ID: htu21d
- Name: Digital Relative Humidity Sensor with Temperature
- Category: temp
- Manufacturer: seeed adafruit sparkfun
- Link: http://www.meas-spec.com/downloads/HTU21D.pdf
- Connection: i2c
HTU21D by Measurement Specialties is a digital humidity sensor with temperature output. RH reports between 0 and 100%, and the temperature range is -40 to +125 degC. Note: getCompRH is the preferred function below (passing true to cause a measurement cycle). If actual values used for the compensated ready are necessary, use the getHumidity(false) and getTemperature(false) functions following the getCompRH call. Also note the sensor should not perform more than a couple of measurements per second to limit the heating of the sensor.
Item Index
Methods
HTU21D
-
bus
-
devAddr
Instantiates an HTU21D object
Parameters:
-
bus
NumberNumber of the used bus
-
devAddr
NumberAddress of the used I2C device
Returns:
sampleData
()
Number
Initiates a temperature/pressure mesasurement and waits to complete. The humidity and temperature registers can be read after this call.
Returns:
getHumidity
-
bSampleData
Gets the current measured humidity [RH]
Parameters:
-
bSampleData
NumberFlag to sample sensor (default false)
Returns:
Relative humidity in RH
getTemperature
-
bSampleData
Gets the humidity cell temperature [degC]
Parameters:
-
bSampleData
NumberFlag to sample sensor (default false)
Returns:
Temperature in degC
getCompRH
-
bSampleData
Using the current humidity and temperature, the function calculates the compensated RH using the equation from the datasheet.
Parameters:
-
bSampleData
NumberFlag to sample sensor (default false)
Returns:
Compensated relative humidity in RH
getDewPoint
-
bSampleData
Using the current humidity and temperature the function will calculate the dew point in degreeC based on equation from the datasheet.
Parameters:
-
bSampleData
NumberFlag to sample sensor (default false)
Returns:
Dew point in degC
getHumidityData
-
fHum
-
fHumTemp
-
fDewPt
Function will attempt to get the best measurement for humidity using the heater in cases where humidity is high to keep the sesnsor dry. The heater setting is returned
Parameters:
-
fHum
Float *pointer to float for relative humidity RH
-
fHumTemp
Float *pointer to float for temperature degC
-
fDewPt
Float *pointer to float for calculated dew point degC
Returns:
0 if success or 1 if sensor is not functioning
setHeater
-
bEnable
Sets the heater state. The heater is used to test the sensor functionality since the temperature should increase 0.5 to 1.5 degC, and the humidity should decrease. The testSensor() function below uses the heater.
Parameters:
-
bEnable
NumberSets to non-zero to turn the heater on
Returns:
0 on success
resetSensor
()
Performs a soft reset of the MPL3115A2 device to ensure it is in a known state. This function can be used to reset the min/max temperature and pressure values.
testSensor
()
Number
Tests the device and verifies it is operating correctly.
Returns:
0 on success or error code
i2cWriteReg
-
reg
-
value
Writes to a one-byte register
Parameters:
-
reg
NumberAddress of the register
-
value
NumberByte to be written
Returns:
i2cReadReg_16
-
reg
Reads a two-byte register. Note: byte ordering is hardware specific.
Parameters:
-
reg
NumberAddress of the register
Returns:
Value returned from register
i2cReadReg_8
-
reg
Reads a one-byte register
Parameters:
-
reg
NumberAddress of the register
Returns:
Value returned from register