This module abstracts away an external humidity sensor, and provides a high level API to easily measure the humidity. The API ensures an easy way to instruct the humidity sensor to gauge the current humidity. The API is non-blocking, enabling parallel sensing of multiple environmental factors. See HUMID_RESET_WAIT_TIME and HUMID_MEASURE_WAIT_TIME
- Note
- The module is prepared to allow to change the type of the external humidity sensor without affecting its API or functionality. The chosen external humidity sensors would then be selected as a diversity setting. This is currently not implemented: only once external humidity sensor is currently supported: see HUMID_CHIP_HTU21D.
- Warning
- This module assumes it is the only block accessing the external humidity sensor. Any other access through other unrelated code, both during, before or after the use of this module, may result in unpredictable behavior.
- Diversity
- This module supports diversity, such as the choice between the supported humidity sensors, and the bus interface selection - which allows a more flexible layout, as the humidity sensor can be connected to any two available pins. Check Diversity settings for all diversity parameters.
◆ HUMID_RESET_WAIT_TIME
#define HUMID_RESET_WAIT_TIME 15 /* ms. The maximum time per the datasheet to reach the idle state. */ |
The time to wait after calling Humid_Init, in milli-seconds, to ensure the humidity sensor is ready to use.
◆ HUMID_MEASURE_WAIT_TIME
#define HUMID_MEASURE_WAIT_TIME 16 /* ms. The maximum measuring time per the datasheet at maximum resolution. */ |
◆ Humid_Init()
This function must be the first function to call in this module after going to deep power down or power-off power save mode. Not calling this function will result in a hang.
- Precondition
- The I2C driver is not in use: Chip_I2C_Init has not yet been called, or Chip_I2C_DeInit was the last call to this driver.
- Postcondition
- The I2C driver is in exclusive use by the humid module
-
When this call returns, HUMID_RESET_WAIT_TIME ms must be waited before any other call may be attempted. This is not checked for.
◆ Humid_DeInit()
void Humid_DeInit |
( |
void |
| ) |
|
De-initializes the humidity sensor and the I2C driver.
- Postcondition
- The I2C driver is not claimed anymore.
-
All pins listed in HUMID_PULLUPS as reconfigured as output, outputting low.
-
The humidity sensor is powered off.
◆ Humid_Reset()
void Humid_Reset |
( |
void |
| ) |
|
Soft-resets the humidity sensor.
- Postcondition
- When this call returns, HUMID_RESET_WAIT_TIME ms must be waited before any other call may be attempted. This is not checked for.
◆ Humid_Measure()
void Humid_Measure |
( |
void |
| ) |
|
Start a humidity measurement.
- Postcondition
- When this call returns, HUMID_MEASURE_WAIT_TIME ms must be waited before the result can be retrieved via Humid_Get - this is not checked for.
◆ Humid_Get()
unsigned int Humid_Get |
( |
void |
| ) |
|
- Precondition
- Humid_Measure has been called HUMID_MEASURE_WAIT_TIME ms or longer ago. Read out the measured humidity data.
- Returns
- the relative humidity in deci-percentages. e.g. 548 to indicate a relative humidity of 54.8%