Contiki-NG
|
Humidity Sensor. More...
Files | |
file | hdc-1000-sensor.c |
Driver for the Sensortag HDC1000 sensor. | |
file | hdc-1000-sensor.h |
Header file for the Sensortag HDC1000 sensor. | |
Functions | |
static bool | i2c_write_read (void *wbuf, size_t wcount, void *rbuf, size_t rcount) |
Setup and peform an I2C transaction. More... | |
static bool | i2c_write (void *wbuf, size_t wcount) |
Peform a write only I2C transaction. More... | |
static bool | i2c_read (void *rbuf, size_t rcount) |
Peform a read only I2C transaction. More... | |
static bool | sensor_init (void) |
Initialize the HDC-1000 sensor driver. More... | |
static bool | start (void) |
Start measurement. More... | |
static void | convert (int32_t *temp, int32_t *hum) |
Convert raw data to temperature and humidity. More... | |
static void | notify_ready (void *unused) |
Callback when sensor is ready to read data from. | |
static int | value (int type) |
Returns a reading from the sensor. More... | |
static int | configure (int type, int enable) |
Configuration function for the HDC1000 sensor. More... | |
static int | status (int type) |
Returns the status of the sensor. More... | |
Humidity Sensor.
Due to the time required for the sensor to startup, this driver is meant to be used in an asynchronous fashion. The caller must first activate the sensor by calling SENSORS_ACTIVATE(). This will trigger the sensor's startup sequence, but the call will not wait for it to complete so that the CPU can perform other tasks or drop to a low power mode. Once the sensor has taken readings, it will automatically go back to low power mode.
Once the sensor is stable, the driver will retrieve readings from the sensor and latch them. It will then generate a sensors_changed event.
The user can then retrieve readings by calling .value() and by passing either HDC_1000_SENSOR_TYPE_TEMP or HDC_1000_SENSOR_TYPE_HUMID as the argument. Multiple calls to value() will not trigger new readings, they will simply return the most recent latched values.
The user can query the sensor's status by calling status().
To get a fresh reading, the user must trigger a new reading cycle by calling SENSORS_ACTIVATE().
Definition at line 87 of file hdc-1000-sensor.h.
|
static |
Configuration function for the HDC1000 sensor.
type | Activate, enable or disable the sensor. See below. |
enable | Either enable or disable the sensor. When type == SENSORS_HW_INIT we turn on the hardware. When type == SENSORS_ACTIVE and enable==1 we enable the sensor. When type == SENSORS_ACTIVE and enable==0 we disable the sensor. |
Definition at line 294 of file hdc-1000-sensor.c.
|
static |
Convert raw data to temperature and humidity.
temp | Output variable to store converted temperature. |
hum | Output variable to store converted humidity. |
Definition at line 219 of file hdc-1000-sensor.c.
|
inlinestatic |
Peform a read only I2C transaction.
rbuf | Input buffer during the I2C transation. |
rcount | How many bytes to read into rbuf. |
Definition at line 168 of file hdc-1000-sensor.c.
References i2c_write_read().
Referenced by notify_ready().
|
inlinestatic |
Peform a write only I2C transaction.
wbuf | Output buffer during the I2C transation. |
wcount | How many bytes in the wbuf. |
Definition at line 156 of file hdc-1000-sensor.c.
References i2c_write_read().
|
static |
Setup and peform an I2C transaction.
wbuf | Output buffer during the I2C transation. |
wcount | How many bytes in the wbuf. |
rbuf | Input buffer during the I2C transation. |
rcount | How many bytes to read into rbuf. |
Definition at line 136 of file hdc-1000-sensor.c.
Referenced by i2c_read(), and i2c_write().
|
static |
Initialize the HDC-1000 sensor driver.
Definition at line 178 of file hdc-1000-sensor.c.
|
static |
Start measurement.
Definition at line 206 of file hdc-1000-sensor.c.
|
static |
Returns the status of the sensor.
type | SENSORS_ACTIVE or SENSORS_READY. |
Definition at line 338 of file hdc-1000-sensor.c.
|
static |
Returns a reading from the sensor.
type | HDC_1000_SENSOR_TYPE_TEMP or HDC_1000_SENSOR_TYPE_HUMID. |
Definition at line 255 of file hdc-1000-sensor.c.