The friendly Operating System for the Internet of Things
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 
33 #define SI70XX_ADDRESS_SI7006 (0x80)
34 #define SI70XX_ADDRESS_SI7013 (0x80)
35 #define SI70XX_ADDRESS_SI7013_ALT (0x81)
36 #define SI70XX_ADDRESS_SI7020 (0x80)
37 #define SI70XX_ADDRESS_SI7021 (0x80)
38 
43 #define SI70XX_MEASURE_RH_HOLD (0xE5)
44 #define SI70XX_MEASURE_RH (0xF5)
45 #define SI70XX_MEASURE_TEMP_HOLD (0xE3)
46 #define SI70XX_MEASURE_TEMP (0xF3)
47 #define SI70XX_MEASURE_TEMP_PREV (0xE0)
48 #define SI70XX_RESET (0xFE)
49 #define SI70XX_WRITE_USER_REG (0xE6)
50 #define SI70XX_READ_USER_REG (0xE7)
51 #define SI70XX_WRITE_HEATER_REG (0x51)
52 #define SI70XX_READ_HEATER_REG (0x11)
53 #define SI70XX_READ_ID_FIRST_A (0xFA)
54 #define SI70XX_READ_ID_FIRST_B (0x0F)
55 #define SI70XX_READ_ID_SECOND_A (0xFC)
56 #define SI70XX_READ_ID_SECOND_B (0xC9)
57 #define SI70XX_READ_REVISION_A (0x84)
58 #define SI70XX_READ_REVISION_B (0xB8)
59 
65 #define SI70XX_ID_SI7006 (0x06)
66 #define SI70XX_ID_SI7013 (0x0D)
67 #define SI70XX_ID_SI7020 (0x14)
68 #define SI70XX_ID_SI7021 (0x15)
69 
70 #define SI70XX_REVISION_1 (0xFF)
71 #define SI70XX_REVISION_2 (0x20)
72 
77 typedef struct {
79  uint8_t address;
80 } si70xx_t;
81 
85 typedef struct {
87  uint8_t address;
89 
97 int si70xx_test(si70xx_t *dev);
98 
108 int si70xx_init(si70xx_t *dev, i2c_t i2c_dev, uint8_t address);
109 
117 
125 int16_t si70xx_get_temperature(si70xx_t *dev);
126 
135 void si70xx_get_both(si70xx_t *dev, uint16_t *humidity, int16_t *temperature);
136 
143 uint64_t si70xx_get_serial(si70xx_t *dev);
144 
151 uint8_t si70xx_get_id(si70xx_t *dev);
152 
159 uint8_t si70xx_get_revision(si70xx_t *dev);
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif /* SI70XX_H */
166 
void si70xx_get_both(si70xx_t *dev, uint16_t *humidity, int16_t *temperature)
Read the relative humidity and temperature from the sensor.
uint16_t si70xx_get_relative_humidity(si70xx_t *dev)
Read the relative humidity from the sensor.
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
int si70xx_init(si70xx_t *dev, i2c_t i2c_dev, uint8_t address)
Initialize and reset the sensor.
uint64_t si70xx_get_serial(si70xx_t *dev)
Read the sensor serial number.
i2c_t i2c_dev
I2C bus the sensors is connected to.
Definition: si70xx.h:78
uint8_t si70xx_get_revision(si70xx_t *dev)
Read the firmware revision of the sensor.
Si70xx device descriptor.
Definition: si70xx.h:77
int16_t si70xx_get_temperature(si70xx_t *dev)
Read the current temperature from the sensor.
int si70xx_test(si70xx_t *dev)
Test if the device id and revision number are as expected.
i2c_t i2c_dev
I2C bus the sensor is connected to.
Definition: si70xx.h:86
uint8_t address
sensor address
Definition: si70xx.h:87
uint8_t address
sensor address
Definition: si70xx.h:79
Device initialization parameters.
Definition: si70xx.h:85
uint8_t si70xx_get_id(si70xx_t *dev)
Read the sensor id, to identifier the sensor variant.
Low-level I2C peripheral driver interface definition.