AWS IoT demonstration using the Avnet Shield (AT&T LTE) and the FRDM-K64F target board.
Dependencies: K64F_FATFileSystem
Fork of mbed-os-example-tls-tls-client by
Sensors/Temperature/HTS221.h@25:91d771247ac8, 2016-12-19 (annotated)
- Committer:
- ampembeng
- Date:
- Mon Dec 19 20:52:28 2016 +0000
- Revision:
- 25:91d771247ac8
- Parent:
- 20:ee34856ae510
Updated the look/feel of the Python GUI to match the AT&T locker demo S3 page. Added "assets" folder to support this. Updated the README.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ampembeng | 20:ee34856ae510 | 1 | |
ampembeng | 20:ee34856ae510 | 2 | #ifndef HTS221_H_ |
ampembeng | 20:ee34856ae510 | 3 | #define HTS221_H_ |
ampembeng | 20:ee34856ae510 | 4 | |
ampembeng | 20:ee34856ae510 | 5 | class HTS221 { |
ampembeng | 20:ee34856ae510 | 6 | public: |
ampembeng | 20:ee34856ae510 | 7 | HTS221(void); |
ampembeng | 20:ee34856ae510 | 8 | int begin(void); |
ampembeng | 20:ee34856ae510 | 9 | int activate(void); |
ampembeng | 20:ee34856ae510 | 10 | int deactivate(void); |
ampembeng | 20:ee34856ae510 | 11 | |
ampembeng | 20:ee34856ae510 | 12 | int bduActivate(void); |
ampembeng | 20:ee34856ae510 | 13 | int bduDeactivate(void); |
ampembeng | 20:ee34856ae510 | 14 | |
ampembeng | 20:ee34856ae510 | 15 | int readHumidity(void); |
ampembeng | 20:ee34856ae510 | 16 | double readTemperature(void); |
ampembeng | 20:ee34856ae510 | 17 | private: |
ampembeng | 20:ee34856ae510 | 18 | int storeCalibration(void); |
ampembeng | 20:ee34856ae510 | 19 | unsigned char _h0_rH, _h1_rH; |
ampembeng | 20:ee34856ae510 | 20 | unsigned int _T0_degC, _T1_degC; |
ampembeng | 20:ee34856ae510 | 21 | unsigned int _H0_T0, _H1_T0; |
ampembeng | 20:ee34856ae510 | 22 | unsigned int _T0_OUT, _T1_OUT; |
ampembeng | 20:ee34856ae510 | 23 | double _temperature; |
ampembeng | 20:ee34856ae510 | 24 | int _humidity; |
ampembeng | 20:ee34856ae510 | 25 | unsigned char _address; |
ampembeng | 20:ee34856ae510 | 26 | |
ampembeng | 20:ee34856ae510 | 27 | unsigned char readRegister(unsigned char slaveAddress, unsigned char regToRead); |
ampembeng | 20:ee34856ae510 | 28 | int writeRegister(unsigned char slaveAddress, unsigned char regToWrite, unsigned char dataToWrite); |
ampembeng | 20:ee34856ae510 | 29 | }; |
ampembeng | 20:ee34856ae510 | 30 | |
ampembeng | 20:ee34856ae510 | 31 | #define HTS221_ADDRESS 0xBF |
ampembeng | 20:ee34856ae510 | 32 | |
ampembeng | 20:ee34856ae510 | 33 | //Define a few of the registers that we will be accessing on the HTS221 |
ampembeng | 20:ee34856ae510 | 34 | #define WHO_AM_I 0x0F |
ampembeng | 20:ee34856ae510 | 35 | #define WHO_AM_I_RETURN 0xBC //This read-only register contains the device identifier, set to BCh |
ampembeng | 20:ee34856ae510 | 36 | |
ampembeng | 20:ee34856ae510 | 37 | #define AVERAGE_REG 0x10 // To configure humidity/temperature average. |
ampembeng | 20:ee34856ae510 | 38 | #define AVERAGE_DEFAULT 0x1B |
ampembeng | 20:ee34856ae510 | 39 | |
ampembeng | 20:ee34856ae510 | 40 | /* |
ampembeng | 20:ee34856ae510 | 41 | * [7] PD: power down control |
ampembeng | 20:ee34856ae510 | 42 | * (0: power-down mode; 1: active mode) |
ampembeng | 20:ee34856ae510 | 43 | * |
ampembeng | 20:ee34856ae510 | 44 | * [6:3] Reserved |
ampembeng | 20:ee34856ae510 | 45 | * |
ampembeng | 20:ee34856ae510 | 46 | * [2] BDU: block data update |
ampembeng | 20:ee34856ae510 | 47 | * (0: continuous update; 1: output registers not updated until MSB and LSB reading) |
ampembeng | 20:ee34856ae510 | 48 | The BDU bit is used to inhibit the output register update between the reading of the upper |
ampembeng | 20:ee34856ae510 | 49 | and lower register parts. In default mode (BDU = ?0?), the lower and upper register parts are |
ampembeng | 20:ee34856ae510 | 50 | updated continuously. If it is not certain whether the read will be faster than output data rate, |
ampembeng | 20:ee34856ae510 | 51 | it is recommended to set the BDU bit to ?1?. In this way, after the reading of the lower (upper) |
ampembeng | 20:ee34856ae510 | 52 | register part, the content of that output register is not updated until the upper (lower) part is |
ampembeng | 20:ee34856ae510 | 53 | read also. |
ampembeng | 20:ee34856ae510 | 54 | * |
ampembeng | 20:ee34856ae510 | 55 | * [1:0] ODR1, ODR0: output data rate selection (see table 17) |
ampembeng | 20:ee34856ae510 | 56 | */ |
ampembeng | 20:ee34856ae510 | 57 | #define CTRL_REG1 0x20 |
ampembeng | 20:ee34856ae510 | 58 | #define POWER_UP 0x80 |
ampembeng | 20:ee34856ae510 | 59 | #define BDU_SET 0x4 |
ampembeng | 20:ee34856ae510 | 60 | #define ODR0_SET 0x1 // setting sensor reading period 1Hz |
ampembeng | 20:ee34856ae510 | 61 | |
ampembeng | 20:ee34856ae510 | 62 | #define CTRL_REG2 0x21 |
ampembeng | 20:ee34856ae510 | 63 | #define CTRL_REG3 0x22 |
ampembeng | 20:ee34856ae510 | 64 | #define REG_DEFAULT 0x00 |
ampembeng | 20:ee34856ae510 | 65 | |
ampembeng | 20:ee34856ae510 | 66 | #define STATUS_REG 0x27 |
ampembeng | 20:ee34856ae510 | 67 | #define TEMPERATURE_READY 0x1 |
ampembeng | 20:ee34856ae510 | 68 | #define HUMIDITY_READY 0x2 |
ampembeng | 20:ee34856ae510 | 69 | |
ampembeng | 20:ee34856ae510 | 70 | #define HUMIDITY_L_REG 0x28 |
ampembeng | 20:ee34856ae510 | 71 | #define HUMIDITY_H_REG 0x29 |
ampembeng | 20:ee34856ae510 | 72 | #define TEMP_L_REG 0x2A |
ampembeng | 20:ee34856ae510 | 73 | #define TEMP_H_REG 0x2B |
ampembeng | 20:ee34856ae510 | 74 | /* |
ampembeng | 20:ee34856ae510 | 75 | * calibration registry should be read for temperature and humidity calculation. |
ampembeng | 20:ee34856ae510 | 76 | * Before the first calculation of temperature and humidity, |
ampembeng | 20:ee34856ae510 | 77 | * the master reads out the calibration coefficients. |
ampembeng | 20:ee34856ae510 | 78 | * will do at init phase |
ampembeng | 20:ee34856ae510 | 79 | */ |
ampembeng | 20:ee34856ae510 | 80 | #define CALIB_START 0x30 |
ampembeng | 20:ee34856ae510 | 81 | #define CALIB_END 0x3F |
ampembeng | 20:ee34856ae510 | 82 | /* |
ampembeng | 20:ee34856ae510 | 83 | #define CALIB_T0_DEGC_X8 0x32 |
ampembeng | 20:ee34856ae510 | 84 | #define CALIB_T1_DEGC_X8 0x33 |
ampembeng | 20:ee34856ae510 | 85 | #define CALIB_T1_T0_MSB 0x35 |
ampembeng | 20:ee34856ae510 | 86 | #define CALIB_T0_OUT_L 0x3C |
ampembeng | 20:ee34856ae510 | 87 | #define CALIB_T0_OUT_H 0x3D |
ampembeng | 20:ee34856ae510 | 88 | #define CALIB_T1_OUT_L 0x3E |
ampembeng | 20:ee34856ae510 | 89 | #define CALIB_T1_OUT_H 0x3F |
ampembeng | 20:ee34856ae510 | 90 | */ |
ampembeng | 20:ee34856ae510 | 91 | |
ampembeng | 20:ee34856ae510 | 92 | #endif |
ampembeng | 20:ee34856ae510 | 93 |