HS4xxx Temperature/Humidity Sensor API.
More...
|
| file | hs4xxx.h |
| | HS4xxx sensor declarations.
|
| |
HS4xxx Temperature/Humidity Sensor API.
HS4xxx is a series of highly accurate, fully calibrated automotive-grade relative humidity and temperature sensors. HS4xxx sensors provide a CRC checksum for communication integrity checking and have different modes of operation.
The HS4xxx API provides convenient access to the sensor's temperature & humidity measurement capabilities.
◆ HS4xxx_ErrorCodes_t
Error code definitions specific for the HS4xxx API.
| Enumerator |
|---|
| hteHS4xxxCRCError | Result CRC error
|
◆ HS4xxx_Init()
Initialize the sensor object.
This function tries accessing the HS4xxx I2C address using hal as hardware interface. On success, the sensor object is initialized and can be used afterwards. Otherwise, an error code is returned and the sensor object is not usable.
- Note
- The HS4xxx API requires that the HAL interface object has the Interface_t::i2cRead and Interface_t::i2cWrite members defined. In addition, HS4xxx_Measure() requires the Interface_t::msSleep member.
- Parameters
-
| sensor | Pointer to sensor object to be initialized |
| hal | Pointer to HAL object providing physical communication |
- Returns
- int Error code
- Return values
-
| 0 | On success |
| other | On error |
◆ HS4xxx_Measure()
Perform a temperature/humidity measurement cycle.
This function starts a measurement cycle in non-hold mode, waits for the result to be available and reads it. If the checksum computation is correct the result is stored in the results data structure. Otherwise the contents of results is left unmodified and an error code is returned.
- Note
- Although the HS4xxx is able to perform the requested measurement with a single I2C transaction (refer to HS4xxx_MeasureHold), this function uses the HS4xxx_MeasureStart() and HS4xxx_MeasureRead() functions together with the Interface_t::msSleep function. This is to allow operation on a wider variety of I2C interfaces. HS4xxx_MeasureHold() requires a minimum of 200kHz I2C clock frequency which is not supported by all interfaces.
- Parameters
-
| sensor | Pointer to an initialized sensor object |
| results | Pointer to a data structure, to store results in |
- Returns
- int Error code
- Return values
-
| 0 | On success |
| other | On error |
◆ HS4xxx_MeasureHold()
Perform a temperature/humidity measurement cycle using hold mode.
This function performs temperature/humidity measurements in hold mode and reads the results form the sensor. If the checksum computation is correct the result is stored in the results data structure. Otherwise the contents of results is left unmodified and an error code is returned.
- Note
- For hold measurements, the I2C clock frequency must be at least 200kHz. Otherwise the result readout is unreliable.
- Parameters
-
| sensor | Pointer to an initialized sensor object |
| results | Pointer to a data structure, to store results in |
- Returns
- int Error code
- Return values
-
| 0 | On success |
| other | On error |
◆ HS4xxx_MeasureRead()
Read temperature/humidity results in non-hold mode.
This function reads the temperature/humidity results from a measurement that has been started through HS4xxx_MeasureStart() previously. If the checksum computation is correct the result is stored in the results data structure. Otherwise the contents of results is left unmodified and an error code is returned.
- Parameters
-
| sensor | Pointer to an initialized sensor object |
| results | Pointer to a data structure, to store results in |
- Returns
- int Error code
- Return values
-
| 0 | On success |
| other | On error |
◆ HS4xxx_MeasureStart()
| int HS4xxx_MeasureStart |
( |
HSxxxx_t * |
sensor | ) |
|
Start a temperature/humidity measurement cycle in non-hold mode.
- Parameters
-
| sensor | Pointer to an initialized sensor object |
- Returns
- int Error code
- Return values
-
| 0 | On success |
| other | On error |
◆ HS4xxx_ReadID()
| int HS4xxx_ReadID |
( |
HSxxxx_t * |
sensor, |
|
|
uint32_t * |
id |
|
) |
| |
Read the unique sensor ID of the HS4xxx.
- Parameters
-
| sensor | Pointer to an initialized sensor object |
| id | Pointer buffer to store the ID |
- Returns
- int Error code
- Return values
-
| 0 | On success |
| other | On error |