shtc1.h File Reference

Device driver interface for the SHTC1 Temperature and humidity sensor. More...

Detailed Description

Device driver interface for the SHTC1 Temperature and humidity sensor.

Author
Steffen Robertz steff.nosp@m.en.r.nosp@m.obert.nosp@m.z@rw.nosp@m.th-aa.nosp@m.chen.nosp@m..de
Josua Arndt jarnd.nosp@m.t@ia.nosp@m.s.rwt.nosp@m.h-aa.nosp@m.chen..nosp@m.de

Definition in file shtc1.h.

#include <stdint.h>
#include "saul.h"
#include "periph/i2c.h"
+ Include dependency graph for shtc1.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  shtc1_params_t
 settings struct with all relevant parameters More...
 
struct  shtc1_t
 device descriptor for the SHTC1 More...
 

Macros

#define SHTC1_I2C_ADDRESS   (0x70)
 SHTC1 Default Address. More...
 

Enumerations

enum  { SHTC1_OK, SHTC1_ERROR_BUS, SHTC1_ERROR_CRC, SHTC1_ERROR }
 

Functions

int8_t shtc1_init (shtc1_t *const dev, const shtc1_params_t *params)
 Initializes the sensor and I2C. More...
 
int8_t shtc1_read (const shtc1_t *dev, uint16_t *rel_humidity, int16_t *temperature)
 Reads all register values from the device. More...
 
int8_t shtc1_id (const shtc1_t *dev, uint16_t *id)
 Reads the ID and saves it in the device descriptor. More...
 
int8_t shtc1_reset (const shtc1_t *dev)
 Resets sensor. More...
 

Macro Definition Documentation

◆ SHTC1_I2C_ADDRESS

#define SHTC1_I2C_ADDRESS   (0x70)

SHTC1 Default Address.

Definition at line 39 of file shtc1.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SHTC1_OK 

Success, no error.

SHTC1_ERROR_BUS 

I2C bus error.

SHTC1_ERROR_CRC 

CRC error.

SHTC1_ERROR 

General error.

Definition at line 61 of file shtc1.h.

Function Documentation

◆ shtc1_id()

int8_t shtc1_id ( const shtc1_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
SHTC1_OK on everything done.
SHTC1_ERROR_BUS on error.

◆ shtc1_init()

int8_t shtc1_init ( shtc1_t *const  dev,
const shtc1_params_t params 
)

Initializes the sensor and I2C.

Parameters
[in]devI2C device descriptor.
[in]paramsSHTC1 parameters to be used.
Returns
SHTC1_OK on a working initialization.
SHTC1_ERROR_BUS Reading I2C failed.
SHTC1_ERROR_CRC Wrong ID.

◆ shtc1_read()

int8_t shtc1_read ( const shtc1_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 reveived.

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

◆ shtc1_reset()

int8_t shtc1_reset ( const shtc1_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
SHTC1_OK on everything done.
SHTC1_ERROR_BUS on error.