si70xx.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Bas Stottelaar <basstottelaar@gmail.com>
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 
21 #ifndef SI70XX_H
22 #define SI70XX_H
23 
24 #include "periph/i2c.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
34 #define SI70XX_ADDRESS_SI7006 (0x80)
35 #define SI70XX_ADDRESS_SI7013 (0x80)
36 #define SI70XX_ADDRESS_SI7013_ALT (0x81)
37 #define SI70XX_ADDRESS_SI7020 (0x80)
38 #define SI70XX_ADDRESS_SI7021 (0x80)
39 
45 #define SI70XX_MEASURE_RH_HOLD (0xE5)
46 #define SI70XX_MEASURE_RH (0xF5)
47 #define SI70XX_MEASURE_TEMP_HOLD (0xE3)
48 #define SI70XX_MEASURE_TEMP (0xF3)
49 #define SI70XX_MEASURE_TEMP_PREV (0xE0)
50 #define SI70XX_RESET (0xFE)
51 #define SI70XX_WRITE_USER_REG (0xE6)
52 #define SI70XX_READ_USER_REG (0xE7)
53 #define SI70XX_WRITE_HEATER_REG (0x51)
54 #define SI70XX_READ_HEATER_REG (0x11)
55 #define SI70XX_READ_ID_FIRST_A (0xFA)
56 #define SI70XX_READ_ID_FIRST_B (0x0F)
57 #define SI70XX_READ_ID_SECOND_A (0xFC)
58 #define SI70XX_READ_ID_SECOND_B (0xC9)
59 #define SI70XX_READ_REVISION_A (0x84)
60 #define SI70XX_READ_REVISION_B (0xB8)
61 
67 #define SI70XX_ID_SI7006 (0x06)
68 #define SI70XX_ID_SI7013 (0x0D)
69 #define SI70XX_ID_SI7020 (0x14)
70 #define SI70XX_ID_SI7021 (0x15)
71 
72 #define SI70XX_REVISION_1 (0xFF)
73 #define SI70XX_REVISION_2 (0x20)
74 
79 typedef struct {
81  uint8_t address;
82 } si70xx_t;
83 
87 typedef struct {
89  uint8_t address;
91 
99 int si70xx_test(const si70xx_t *dev);
100 
110 int si70xx_init(si70xx_t *dev, i2c_t i2c_dev, uint8_t address);
111 
118 uint16_t si70xx_get_relative_humidity(const si70xx_t *dev);
119 
127 int16_t si70xx_get_temperature(const si70xx_t *dev);
128 
137 void si70xx_get_both(const si70xx_t *dev, uint16_t *humidity, int16_t *temperature);
138 
145 uint64_t si70xx_get_serial(const si70xx_t *dev);
146 
153 uint8_t si70xx_get_id(const si70xx_t *dev);
154 
161 uint8_t si70xx_get_revision(const si70xx_t *dev);
162 
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif /* SI70XX_H */
168 
int16_t si70xx_get_temperature(const si70xx_t *dev)
Read the current temperature from the sensor.
uint64_t si70xx_get_serial(const si70xx_t *dev)
Read the sensor serial number.
uint8_t si70xx_get_id(const si70xx_t *dev)
Read the sensor id, to identifier the sensor variant.
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:108
i2c_t i2c_dev
I2C bus the sensors is connected to.
Definition: si70xx.h:80
Si70xx device descriptor.
Definition: si70xx.h:79
void si70xx_get_both(const si70xx_t *dev, uint16_t *humidity, int16_t *temperature)
Read the relative humidity and temperature from the sensor.
int si70xx_test(const si70xx_t *dev)
Test if the device id and revision number are as expected.
uint8_t si70xx_get_revision(const si70xx_t *dev)
Read the firmware revision of the sensor.
i2c_t i2c_dev
I2C bus the sensor is connected to.
Definition: si70xx.h:88
uint8_t address
sensor address
Definition: si70xx.h:89
uint8_t address
sensor address
Definition: si70xx.h:81
Device initialization parameters.
Definition: si70xx.h:87
uint16_t si70xx_get_relative_humidity(const si70xx_t *dev)
Read the relative humidity from the sensor.
int si70xx_init(si70xx_t *dev, i2c_t i2c_dev, uint8_t address)
Initialize and reset the sensor.
Low-level I2C peripheral driver interface definition.