IoT Drivers  v3.3.0 (S2022)
Engineering in Software Technology
Quick start guide for HIH8120 Temperature and Humidity Driver

This is the quick start guide for the HIH8120 Temperature and Humidity Driver, with step-by-step instructions on how to configure and use the driver in a selection of use cases.

The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.

HIH8120 Driver use cases

Initialise the driver

The following must be added to the project:

Add to application initialization:

  • Initialise the driver:
    {
    // Driver initialised OK
    // Always check what hih8120_initialise() returns
    }
Note
If used from FreeRTOS: The driver must be initialised hih8120_initialise before the FreeRTOS sheduler is started!!

How to perform a new measuring with the sensor

In this use case, the steps to perform a measuring is shown.

Note
The driver must be initialised Initialise the driver before a measuring is possible.

In this example these two variables will be used to store the results in

float humidity = 0.0;
float temperature = 0.0;

Perform the measuring

The following must be added to the application code and executed for each new measuring:

  1. Wake up the sensor from power down:

    {
    // Something went wrong
    // Investigate the return code further
    }
    Note
    After the hih8120_wakeup() call the sensor will need minimum 50 ms to be ready!
  2. Poll the sensor for the results:

    {
    // Something went wrong
    // Investigate the return code further
    }
    Note
    After the hih8120_measure() call the two wire inteface (TWI) will need minimum 1 ms to fetch the results from the sensor!
  3. Get the results: The result can now be retrieved by calling one of these methods hih8120_getHumidityPercent_x10(), hih8120_getTemperature_x10(), hih8120_getHumidity() or hih8120_getTemperature().

A small example

humidity = hih8120_getHumidity();
temperature = hih8120_getTemperature();
hih8120_getHumidity
float hih8120_getHumidity(void)
Get latest measured relative humidity percent.
hih8120_getTemperature
float hih8120_getTemperature(void)
Get latest measured temperature in C.
hih8120_measure
hih8120_driverReturnCode_t hih8120_measure(void)
Fetch the latest results from the HIH8180 sensor.
hih8120_initialise
hih8120_driverReturnCode_t hih8120_initialise(void)
Initialise the HIH8120 driver.
hih8120.h
Driver to Honeywell HIH8120 Temperature and Humidity sensor found on the VIA ARDUINO MEGA2560 Shield ...
HIH8120_OK
@ HIH8120_OK
Definition: hih8120.h:41
hih8120_wakeup
hih8120_driverReturnCode_t hih8120_wakeup(void)
Wakes up the HIH8180 sensor.