SP1 vers 3

Dependents:   SoufflerieSP1-vers2

Committer:
petit
Date:
Tue Jun 08 10:37:36 2021 +0000
Revision:
0:86f8e66e04fc
SP1 vers 3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
petit 0:86f8e66e04fc 1 /***************************************************
petit 0:86f8e66e04fc 2 This is a library for the SHT31 Digital Humidity & Temp Sht31
petit 0:86f8e66e04fc 3
petit 0:86f8e66e04fc 4 Designed specifically to work with the SHT31 Digital Sht31 from Adafruit
petit 0:86f8e66e04fc 5 ----> https://www.adafruit.com/products/2857
petit 0:86f8e66e04fc 6
petit 0:86f8e66e04fc 7 These displays use I2C to communicate, 2 pins are required to
petit 0:86f8e66e04fc 8 interface
petit 0:86f8e66e04fc 9 Adafruit invests time and resources providing this open source code,
petit 0:86f8e66e04fc 10 please support Adafruit and open-source hardware by purchasing
petit 0:86f8e66e04fc 11 products from Adafruit!
petit 0:86f8e66e04fc 12
petit 0:86f8e66e04fc 13 Written by Limor Fried/Ladyada for Adafruit Industries.
petit 0:86f8e66e04fc 14 BSD license, all text above must be included in any redistribution
petit 0:86f8e66e04fc 15 ****************************************************/
petit 0:86f8e66e04fc 16
petit 0:86f8e66e04fc 17 #ifndef Sht31_H
petit 0:86f8e66e04fc 18 #define Sht31_H
petit 0:86f8e66e04fc 19
petit 0:86f8e66e04fc 20 #include "mbed.h"
petit 0:86f8e66e04fc 21
petit 0:86f8e66e04fc 22 #define SHT31_DEFAULT_ADDR 0x44
petit 0:86f8e66e04fc 23 #define SHT31_MEAS_HIGHREP_STRETCH 0x2C06
petit 0:86f8e66e04fc 24 #define SHT31_MEAS_MEDREP_STRETCH 0x2C0D
petit 0:86f8e66e04fc 25 #define SHT31_MEAS_LOWREP_STRETCH 0x2C10
petit 0:86f8e66e04fc 26 #define SHT31_MEAS_HIGHREP 0x2400
petit 0:86f8e66e04fc 27 #define SHT31_MEAS_MEDREP 0x240B
petit 0:86f8e66e04fc 28 #define SHT31_MEAS_LOWREP 0x2416
petit 0:86f8e66e04fc 29 #define SHT31_READSTATUS 0xF32D
petit 0:86f8e66e04fc 30 #define SHT31_CLEARSTATUS 0x3041
petit 0:86f8e66e04fc 31 #define SHT31_SOFTRESET 0x30A2
petit 0:86f8e66e04fc 32 #define SHT31_HEATEREN 0x306D
petit 0:86f8e66e04fc 33 #define SHT31_HEATERDIS 0x3066
petit 0:86f8e66e04fc 34
petit 0:86f8e66e04fc 35 class Sht31 {
petit 0:86f8e66e04fc 36 public:
petit 0:86f8e66e04fc 37 Sht31(PinName sda, PinName scl);
petit 0:86f8e66e04fc 38 int readTemperature(void);
petit 0:86f8e66e04fc 39 int readHumidity(void);
petit 0:86f8e66e04fc 40
petit 0:86f8e66e04fc 41 private:
petit 0:86f8e66e04fc 42 void reset(void);
petit 0:86f8e66e04fc 43 uint16_t readStatus(void);
petit 0:86f8e66e04fc 44 void writeCommand(uint16_t cmd);
petit 0:86f8e66e04fc 45 bool readTempHum(void);
petit 0:86f8e66e04fc 46 uint8_t crc8(const uint8_t *data, int len);
petit 0:86f8e66e04fc 47
petit 0:86f8e66e04fc 48 I2C _i2c;
petit 0:86f8e66e04fc 49 int _i2caddr;
petit 0:86f8e66e04fc 50 int humidity, temp;
petit 0:86f8e66e04fc 51 };
petit 0:86f8e66e04fc 52
petit 0:86f8e66e04fc 53 #endif