Contiki-NG
Files | Functions

Due to the time required for the sensor to startup, this driver is meant to be used in an asynchronous fashion. More...

Files

file  hdc-1000-sensor.c
 Driver for the Sensortag HDC sensor.
 
file  hdc-1000-sensor.h
 Header file for the Sensortag TI HDC1000 sensor.
 

Functions

static bool sensor_init (void)
 Initialise the humidity sensor driver. More...
 
static void start (void)
 Start measurement.
 
static bool read_data ()
 Take readings from the sensor. More...
 
static void convert (float *temp, float *hum)
 Convert raw data to temperature and humidity. More...
 
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...
 

HDC1000 driver states

#define HDC_1000_SENSOR_STATUS_DISABLED   0
 Not initialised.
 
#define HDC_1000_SENSOR_STATUS_INITIALISED   1
 Initialised but idle.
 
#define HDC_1000_SENSOR_STATUS_TAKING_READINGS   2
 Readings in progress.
 
#define HDC_1000_SENSOR_STATUS_READINGS_READY   3
 Both readings ready.
 

Detailed Description

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().

Function Documentation

◆ configure()

static int configure ( int  type,
int  enable 
)
static

Configuration function for the HDC1000 sensor.

Parameters
typeActivate, enable or disable the sensor. See below
enableWhen 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 252 of file hdc-1000-sensor.c.

◆ convert()

static void convert ( float *  temp,
float *  hum 
)
static

Convert raw data to temperature and humidity.

Parameters
temp- converted temperature
hum- converted humidity

Definition at line 186 of file hdc-1000-sensor.c.

◆ read_data()

static bool read_data ( )
static

Take readings from the sensor.

Returns
true of I2C operations successful

Definition at line 157 of file hdc-1000-sensor.c.

◆ sensor_init()

static bool sensor_init ( void  )
static

Initialise the humidity sensor driver.

Returns
True if I2C operation successful

Definition at line 123 of file hdc-1000-sensor.c.

◆ status()

static int status ( int  type)
static

Returns the status of the sensor.

Parameters
typeSENSORS_ACTIVE or SENSORS_READY
Returns
One of the SENSOR_STATUS_xyz defines

Definition at line 289 of file hdc-1000-sensor.c.

◆ value()

static int value ( int  type)
static

Returns a reading from the sensor.

Parameters
typeHDC_1000_SENSOR_TYPE_TEMP or HDC_1000_SENSOR_TYPE_HUMID
Returns
Temperature (centi degrees C) or Humidity (centi RH)

Definition at line 212 of file hdc-1000-sensor.c.