Loading...
Searching...
No Matches
sht2x.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016,2017,2018 Kees Bakker, SODAQ
3 * Copyright (C) 2017 George Psimenos
4 * Copyright (C) 2018 Steffen Robertz
5 *
6 * This file is subject to the terms and conditions of the GNU Lesser
7 * General Public License v2.1. See the file LICENSE in the top level
8 * directory for more details.
9 */
10
26#ifndef SHT2X_H
27#define SHT2X_H
28
29#include <stdint.h>
30#include <stdbool.h>
31#include "periph/i2c.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
40enum {
51};
52
64
72
79#define SHT2X_USER_RESOLUTION_MASK 0x81
80#define SHT2X_USER_EOB_MASK 0x40
81#define SHT2X_USER_HEATER_MASK 0x04
82#define SHT2X_USER_RESERVED_MASK 0x38
83#define SHT2X_USER_OTP_MASK 0x02
96
100typedef struct {
102} sht2x_t;
103
116int sht2x_init(sht2x_t* dev, const sht2x_params_t* params);
117
127
140int16_t sht2x_read_temperature(const sht2x_t* dev);
141
154uint16_t sht2x_read_humidity(const sht2x_t *dev);
155
167int sht2x_read_ident(const sht2x_t *dev, uint8_t *buffer, size_t buflen);
168
179int sht2x_read_userreg(const sht2x_t *dev, uint8_t *userreg);
180
190int sht2x_write_userreg(const sht2x_t *dev, uint8_t userreg);
191
192#ifdef __cplusplus
193}
194#endif
195
196#endif /* SHT2X_H */
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
sht2x_measure_mode_t
Available Measuring modes.
Definition sht2x.h:68
int16_t sht2x_read_temperature(const sht2x_t *dev)
Read temperature value from the given SHT2X device, returned in centi °C.
int sht2x_read_userreg(const sht2x_t *dev, uint8_t *userreg)
Read User Register from the given SHT2X device.
uint16_t sht2x_read_humidity(const sht2x_t *dev)
Read humidity value from the given SHT2X device, returned in centi RH.
sht2x_res_t
Available resolutions.
Definition sht2x.h:58
int sht2x_write_userreg(const sht2x_t *dev, uint8_t userreg)
Write User Register to the given SHT2X device.
int sht2x_reset(sht2x_t *dev)
Reset the SHT2X device.
int sht2x_read_ident(const sht2x_t *dev, uint8_t *buffer, size_t buflen)
Read identification code from the given SHT2X device.
int sht2x_init(sht2x_t *dev, const sht2x_params_t *params)
Initialize the given SHT2X device.
@ SHT2X_MEASURE_MODE_HOLD
trigger measurement, hold master
Definition sht2x.h:69
@ SHT2X_MEASURE_MODE_NO_HOLD
trigger measurement, no hold master (i.e.
Definition sht2x.h:70
@ SHT2X_RES_8_12BIT
RH= 8bit, T=12bit.
Definition sht2x.h:60
@ SHT2X_RES_12_14BIT
RH=12bit, T=14bit.
Definition sht2x.h:59
@ SHT2X_RES_11_11BIT
RH=11bit, T=11bit.
Definition sht2x.h:62
@ SHT2X_RES_10_13BIT
RH=10bit, T=13bit.
Definition sht2x.h:61
@ SHT2X_ERR_USERREG
cannot write User Reg
Definition sht2x.h:48
@ SHT2X_OK
everything was fine
Definition sht2x.h:41
@ SHT2X_ERR_OTHER
fatal error
Definition sht2x.h:50
@ SHT2X_ERR_I2C_READ
I2C read error.
Definition sht2x.h:45
@ SHT2X_ERR_RES
invalid resolution
Definition sht2x.h:49
@ SHT2X_ERR_NOCAL
could not read calibration data
Definition sht2x.h:44
@ SHT2X_ERR_CRC
CRC error.
Definition sht2x.h:47
@ SHT2X_ERR_NODEV
did not detect SHT2x
Definition sht2x.h:43
@ SHT2X_ERR_I2C
error initializing the I2C bus
Definition sht2x.h:42
@ SHT2X_ERR_TIMEDOUT
timed out
Definition sht2x.h:46
Low-level I2C peripheral driver interface definition.
Device initialization parameters.
Definition sht2x.h:89
sht2x_measure_mode_t measure_mode
measurement mode used
Definition sht2x.h:93
bool is_crc_enabled
do CRC or not
Definition sht2x.h:94
i2c_t i2c_dev
I2C device
Definition sht2x.h:90
uint8_t i2c_addr
I2C address
Definition sht2x.h:91
sht2x_res_t resolution
resolution bits RH/temp
Definition sht2x.h:92
Device descriptor for the SHT2X sensor.
Definition sht2x.h:100
sht2x_params_t params
Device Parameters.
Definition sht2x.h:101