hello

Dependents:   sht31_II ina-hack-test rapidtouchscreenprototype EMBEDDED_SYSTEM_PROJECT_GROUP_9 ... more

Committer:
GeofferyOmlette
Date:
Thu Jul 21 15:31:08 2016 +0000
Revision:
1:756e26f0b067
Parent:
0:c90aa4f69539
hello

Who changed what in which revision?

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