sht1x.h
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Freie Universitaet Berlin (FUB)
3  * 2018 Otto-von-Guericke-Universität Magdeburg
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
23 #ifndef SHT1X_H
24 #define SHT1X_H
25 
26 #include <stdint.h>
27 #include <periph/gpio.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
38 typedef enum {
47 } sht1x_conf_t;
48 
52 typedef enum {
53  SHT1X_VDD_5_0V = 0,
54  SHT1X_VDD_4_0V = 1,
55  SHT1X_VDD_3_5V = 2,
56  SHT1X_VDD_3_0V = 3,
57  SHT1X_VDD_2_5V = 4,
58 } sht1x_vdd_t;
59 
63 typedef struct {
64  gpio_t clk;
65  gpio_t data;
66  int16_t temp_off;
67  int16_t hum_off;
68  uint8_t conf;
69  uint8_t vdd;
70 } sht1x_dev_t;
71 
75 typedef struct {
76  gpio_t clk;
77  gpio_t data;
80 
91 int sht1x_init(sht1x_dev_t *dev, const sht1x_params_t *params);
92 
103 int16_t sht1x_temperature(const sht1x_dev_t *dev, uint16_t raw);
104 
117 int16_t sht1x_humidity(const sht1x_dev_t *dev, uint16_t raw, int16_t temp);
118 
140 int sht1x_read(const sht1x_dev_t *dev, int16_t *temp, int16_t *hum);
141 
156 
169 int sht1x_read_status(sht1x_dev_t *dev, uint8_t *status);
170 
181 int sht1x_reset(sht1x_dev_t *dev);
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* SHT1X_H */
188 
sht1x_vdd_t
sht1x_vdd_t
Possible values for Vdd (measured temperature depends on it)
Definition: sht1x.h:52
sht1x_reset
int sht1x_reset(sht1x_dev_t *dev)
Reset the sensor's configuration to default values.
sht1x_dev_t::vdd
uint8_t vdd
Supply voltage of the SHT1X (as sht1x_vdd_t)
Definition: sht1x.h:69
SHT1X_CONF_SKIP_CALIBRATION
@ SHT1X_CONF_SKIP_CALIBRATION
Don't upload calibration data to register to safe 10 millisec.
Definition: sht1x.h:42
sht1x_dev_t::clk
gpio_t clk
GPIO connected to the clock pin of the SHT1X.
Definition: sht1x.h:64
sht1x_params_t
Parameters required to set up the SHT10/11/15 device driver.
Definition: sht1x.h:75
sht1x_read
int sht1x_read(const sht1x_dev_t *dev, int16_t *temp, int16_t *hum)
Read the current temperature.
sht1x_params_t::vdd
sht1x_vdd_t vdd
The supply voltage of the SHT1X.
Definition: sht1x.h:78
sht1x_configure
int sht1x_configure(sht1x_dev_t *dev, sht1x_conf_t conf)
Apply the given configuration (= status byte) to.
sht1x_params_t::clk
gpio_t clk
GPIO connected to the clock pin of the SHT1X.
Definition: sht1x.h:76
SHT1X_CONF_ENABLE_HEATER
@ SHT1X_CONF_ENABLE_HEATER
Waste 8mA at 5V to increase the sensor temperature up to 10°C.
Definition: sht1x.h:44
sht1x_humidity
int16_t sht1x_humidity(const sht1x_dev_t *dev, uint16_t raw, int16_t temp)
Calculate the relative humidity from the raw input.
sht1x_dev_t::temp_off
int16_t temp_off
Offset to add to the measured temperature.
Definition: sht1x.h:66
sht1x_params_t::data
gpio_t data
GPIO connected to the data pin of the SHT1X.
Definition: sht1x.h:77
sht1x_dev_t
SHT10/11/15 temperature humidity sensor.
Definition: sht1x.h:63
SHT1X_CONF_LOW_RESOLUTION
@ SHT1X_CONF_LOW_RESOLUTION
Use 8/12 bit resolution instead of 12/14 bit for temp/hum.
Definition: sht1x.h:40
SHT1X_CONF_SKIP_CRC
@ SHT1X_CONF_SKIP_CRC
Skip the CRC check (and reading the CRC byte) to safe time.
Definition: sht1x.h:46
gpio.h
Low-level GPIO peripheral driver interface definitions.
sht1x_dev_t::hum_off
int16_t hum_off
Offset to add to the measured humidity.
Definition: sht1x.h:67
sht1x_init
int sht1x_init(sht1x_dev_t *dev, const sht1x_params_t *params)
Initialize the SHT10/11/15 sensor.
sht1x_temperature
int16_t sht1x_temperature(const sht1x_dev_t *dev, uint16_t raw)
Calculate the temperature from the raw input.
sht1x_read_status
int sht1x_read_status(sht1x_dev_t *dev, uint8_t *status)
Read the status byte of an SHT1X sensor.
sht1x_dev_t::conf
uint8_t conf
Status byte (containing configuration) of the SHT1X.
Definition: sht1x.h:68
sht1x_conf_t
sht1x_conf_t
Possible configuration (=status byte) values of the SHT10/11/15.
Definition: sht1x.h:38
sht1x_dev_t::data
gpio_t data
GPIO connected to the data pin of the SHT1X.
Definition: sht1x.h:65