Loading...
Searching...
No Matches
SHTCX Temperature and humidity sensor

Driver for the Sensirion SHTCX sensor. More...

Detailed Description

Driver for the Sensirion SHTCX sensor.

Files

file  shtcx.h
 Device driver interface for the SHTCX Temperature and humidity sensor.
 
file  shtcx_params.h
 Default parameters for the SHTCX Temperature and humidity sensor.
 
file  shtcx_regs.h
 Register definitions for SHTCX devices.
 

Data Structures

struct  shtcx_params_t
 settings struct with all relevant parameters More...
 
struct  shtcx_t
 device descriptor for the SHTCX More...
 

Macros

#define SHTCX_I2C_ADDRESS   (0x70)
 SHTCX Default Address.
 

Enumerations

enum  { SHTCX_OK , SHTCX_ERROR_BUS , SHTCX_ERROR_CRC , SHTCX_ERROR }
 

Functions

int8_t shtcx_init (shtcx_t *const dev, const shtcx_params_t *params)
 Initializes the sensor and I2C.
 
int8_t shtcx_read (const shtcx_t *dev, uint16_t *rel_humidity, int16_t *temperature)
 Reads all register values from the device.
 
int8_t shtcx_id (const shtcx_t *dev, uint16_t *id)
 Reads the ID and saves it in the device descriptor.
 
int8_t shtcx_reset (const shtcx_t *dev)
 Resets sensor.
 

Macro Definition Documentation

◆ SHTCX_I2C_ADDRESS

#define SHTCX_I2C_ADDRESS   (0x70)

SHTCX Default Address.

Definition at line 41 of file shtcx.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SHTCX_OK 

Success, no error.

SHTCX_ERROR_BUS 

I2C bus error.

SHTCX_ERROR_CRC 

CRC error.

SHTCX_ERROR 

General error.

Definition at line 63 of file shtcx.h.

Function Documentation

◆ shtcx_id()

int8_t shtcx_id ( const shtcx_t dev,
uint16_t *  id 
)

Reads the ID and saves it in the device descriptor.

When working correctly ID should equal xxxx'xxxx'xx00'0111 where x is unspecified.

Parameters
[in]devThe I2C device descriptor.
[in]idID of the device.
Returns
SHTCX_OK on everything done.
SHTCX_ERROR_BUS on error.

◆ shtcx_init()

int8_t shtcx_init ( shtcx_t *const  dev,
const shtcx_params_t params 
)

Initializes the sensor and I2C.

Parameters
[in]devI2C device descriptor.
[in]paramsSHTCX parameters to be used.
Returns
SHTCX_OK on a working initialization.
SHTCX_ERROR_BUS Reading I2C failed.
SHTCX_ERROR_CRC Wrong ID.

◆ shtcx_read()

int8_t shtcx_read ( const shtcx_t dev,
uint16_t *  rel_humidity,
int16_t *  temperature 
)

Reads all register values from the device.

The values as raw data will be saved into received.

Parameters
[in]devThe I2C device descriptor.
[in]rel_humidityHumidity in centi %.
[in]temperatureTemperature in centi °C.
Returns
SHTCX_OK if a measurement completed.
SHTCX_ERROR_BUS reading I2C failed.
SHTCX_ERROR_CRC on checksum error.

◆ shtcx_reset()

int8_t shtcx_reset ( const shtcx_t dev)

Resets sensor.

This will reset all internal state machines and reload calibration data from the memory.

Parameters
[in]devThe I2C device descriptor.
Returns
SHTCX_OK on everything done.
SHTCX_ERROR_BUS on error.