Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-os-example_2threads_RAK811
Sht31.h
00001 /*************************************************** 00002 This is a library for the SHT31 Digital Humidity & Temp Sht31 00003 00004 Designed specifically to work with the SHT31 Digital Sht31 from Adafruit 00005 ----> https://www.adafruit.com/products/2857 00006 00007 These displays use I2C to communicate, 2 pins are required to 00008 interface 00009 Adafruit invests time and resources providing this open source code, 00010 please support Adafruit and open-source hardware by purchasing 00011 products from Adafruit! 00012 00013 Written by Limor Fried/Ladyada for Adafruit Industries. 00014 BSD license, all text above must be included in any redistribution 00015 ****************************************************/ 00016 00017 #ifndef Sht31_H 00018 #define Sht31_H 00019 00020 #include "mbed.h" 00021 00022 #define SHT31_DEFAULT_ADDR 0x45 00023 #define SHT31_MEAS_HIGHREP_STRETCH 0x2C06 00024 #define SHT31_MEAS_MEDREP_STRETCH 0x2C0D 00025 #define SHT31_MEAS_LOWREP_STRETCH 0x2C10 00026 #define SHT31_MEAS_HIGHREP 0x2400 00027 #define SHT31_MEAS_MEDREP 0x240B 00028 #define SHT31_MEAS_LOWREP 0x2416 00029 #define SHT31_READSTATUS 0xF32D 00030 #define SHT31_CLEARSTATUS 0x3041 00031 #define SHT31_SOFTRESET 0x30A2 00032 #define SHT31_HEATEREN 0x306D 00033 #define SHT31_HEATERDIS 0x3066 00034 00035 class Sht31 { 00036 public: 00037 Sht31(PinName sda, PinName scl); 00038 float readTemperature(void); 00039 float readHumidity(void); 00040 00041 private: 00042 void reset(void); 00043 uint16_t readStatus(void); 00044 void writeCommand(uint16_t cmd); 00045 bool readTempHum(void); 00046 uint8_t crc8(const uint8_t *data, int len); 00047 00048 I2C _i2c; 00049 int _i2caddr; 00050 float humidity, temp; 00051 }; 00052 00053 #endif
Generated on Sun Oct 30 2022 14:03:26 by
1.7.2