sht3x.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Gunar Schorcht
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
17 #ifndef SHT3X_H
18 #define SHT3X_H
19 
20 #include <stdint.h>
21 #include <stdbool.h>
22 
23 #include "periph/i2c.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
30 #define SHT3X_I2C_ADDR_1 (0x44)
31 #define SHT3X_I2C_ADDR_2 (0x45)
36 typedef enum {
43 
47 typedef enum {
54 } sht3x_mode_t;
55 
56 
75 typedef enum {
76  SHT3X_HIGH = 0,
80 
81 
85 typedef struct {
87  uint8_t i2c_addr;
91 
95 typedef struct {
96 
98  uint8_t i2c_addr;
104  uint32_t meas_start_time;
105  uint32_t meas_duration;
107 } sht3x_dev_t;
108 
109 
127 int sht3x_init (sht3x_dev_t *dev, const sht3x_params_t *params);
128 
163 int sht3x_read (sht3x_dev_t* dev, int16_t* temp, int16_t* hum);
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif /* SHT3X_H */
170 
SHT3X_ERROR_STATUS
@ SHT3X_ERROR_STATUS
sensor has wrong status
Definition: sht3x.h:40
SHT3X_ERROR_MEASURE_CMD_INV
@ SHT3X_ERROR_MEASURE_CMD_INV
measurement command not executed
Definition: sht3x.h:41
sht3x_dev_t::meas_started
bool meas_started
indicates whether measurement is started
Definition: sht3x.h:103
SHT3X_PERIODIC_10_MPS
@ SHT3X_PERIODIC_10_MPS
periodic with 10 measurements per second (mps)
Definition: sht3x.h:53
sht3x_init
int sht3x_init(sht3x_dev_t *dev, const sht3x_params_t *params)
Initialize the SHT3x sensor device.
sht3x_repeat_t
sht3x_repeat_t
SHT3x repeatability levels.
Definition: sht3x.h:75
sht3x_params_t::repeat
sht3x_repeat_t repeat
repeatability level used
Definition: sht3x.h:89
SHT3X_HIGH
@ SHT3X_HIGH
high repeatability
Definition: sht3x.h:76
SHT3X_PERIODIC_1_MPS
@ SHT3X_PERIODIC_1_MPS
periodic with 1 measurements per second (mps)
Definition: sht3x.h:50
sht3x_dev_t::i2c_dev
i2c_t i2c_dev
I2C device
Definition: sht3x.h:97
SHT3X_LOW
@ SHT3X_LOW
low repeatability
Definition: sht3x.h:78
sht3x_dev_t::meas_start_time
uint32_t meas_start_time
start time of current measurement in us
Definition: sht3x.h:104
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
SHT3X_PERIODIC_0_5_MPS
@ SHT3X_PERIODIC_0_5_MPS
periodic with 0.5 measurements per second (mps)
Definition: sht3x.h:49
sht3x_params_t::i2c_addr
uint8_t i2c_addr
I2C address
Definition: sht3x.h:87
sht3x_read
int sht3x_read(sht3x_dev_t *dev, int16_t *temp, int16_t *hum)
Read SHT3x measurement results (temperature and humidity)
sht3x_mode_t
sht3x_mode_t
SHT3x measurement modes.
Definition: sht3x.h:47
SHT3X_ERROR_I2C
@ SHT3X_ERROR_I2C
I2C communication failure.
Definition: sht3x.h:38
SHT3X_SINGLE_SHOT
@ SHT3X_SINGLE_SHOT
single shot measurement
Definition: sht3x.h:48
sht3x_params_t::i2c_dev
i2c_t i2c_dev
I2C device
Definition: sht3x.h:86
sht3x_dev_t::mode
sht3x_mode_t mode
measurement mode used
Definition: sht3x.h:100
sht3x_dev_t::meas_duration
uint32_t meas_duration
time in us until the results of the current measurement become available
Definition: sht3x.h:105
SHT3X_MEDIUM
@ SHT3X_MEDIUM
medium repeatability
Definition: sht3x.h:77
sht3x_dev_t
SHT3x sensor device data structure.
Definition: sht3x.h:95
sht3x_dev_t::repeat
sht3x_repeat_t repeat
repeatability level used
Definition: sht3x.h:101
SHT3X_ERROR_CRC
@ SHT3X_ERROR_CRC
CRC check failed.
Definition: sht3x.h:39
sht3x_dev_t::i2c_addr
uint8_t i2c_addr
I2C address.
Definition: sht3x.h:98
SHT3X_OK
@ SHT3X_OK
no error
Definition: sht3x.h:37
sht3x_params_t
SHT3x device initialization parameters.
Definition: sht3x.h:85
SHT3X_PERIODIC_2_MPS
@ SHT3X_PERIODIC_2_MPS
periodic with 2 measurements per second (mps)
Definition: sht3x.h:51
sht3x_params_t::mode
sht3x_mode_t mode
measurement mode used
Definition: sht3x.h:88
sht3x_error_codes
sht3x_error_codes
Driver error codes (returned as negative values)
Definition: sht3x.h:36
SHT3X_PERIODIC_4_MPS
@ SHT3X_PERIODIC_4_MPS
periodic with 4 measurements per second (mps)
Definition: sht3x.h:52
i2c.h
Low-level I2C peripheral driver interface definition.