test code for hdc1080 humidity sensor
Fork of Nucleo-F303K8-SSD1306_OLED by
hdc_1080.h.txt@5:3c91772b714e, 2016-09-14 (annotated)
- Committer:
- joeata2wh
- Date:
- Wed Sep 14 02:36:12 2016 +0000
- Revision:
- 5:3c91772b714e
- Parent:
- 4:53d68b18bd43
working version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joeata2wh | 4:53d68b18bd43 | 1 | /* |
joeata2wh | 4:53d68b18bd43 | 2 | Arduino Library for Texas Instruments HDC1080 Digital Humidity and Temperature Sensor |
joeata2wh | 4:53d68b18bd43 | 3 | Written by AA for ClosedCube |
joeata2wh | 4:53d68b18bd43 | 4 | --- |
joeata2wh | 4:53d68b18bd43 | 5 | The MIT License (MIT) |
joeata2wh | 4:53d68b18bd43 | 6 | Copyright (c) 2016 ClosedCube Limited |
joeata2wh | 4:53d68b18bd43 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy |
joeata2wh | 4:53d68b18bd43 | 8 | of this software and associated documentation files (the "Software"), to deal |
joeata2wh | 4:53d68b18bd43 | 9 | in the Software without restriction, including without limitation the rights |
joeata2wh | 4:53d68b18bd43 | 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
joeata2wh | 4:53d68b18bd43 | 11 | copies of the Software, and to permit persons to whom the Software is |
joeata2wh | 4:53d68b18bd43 | 12 | furnished to do so, subject to the following conditions: |
joeata2wh | 4:53d68b18bd43 | 13 | The above copyright notice and this permission notice shall be included in |
joeata2wh | 4:53d68b18bd43 | 14 | all copies or substantial portions of the Software. |
joeata2wh | 4:53d68b18bd43 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
joeata2wh | 4:53d68b18bd43 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
joeata2wh | 4:53d68b18bd43 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
joeata2wh | 4:53d68b18bd43 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
joeata2wh | 4:53d68b18bd43 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
joeata2wh | 4:53d68b18bd43 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
joeata2wh | 4:53d68b18bd43 | 21 | THE SOFTWARE. |
joeata2wh | 4:53d68b18bd43 | 22 | */ |
joeata2wh | 4:53d68b18bd43 | 23 | |
joeata2wh | 4:53d68b18bd43 | 24 | #ifndef _CLOSEDCUBE_HDC1080_h |
joeata2wh | 4:53d68b18bd43 | 25 | #define _CLOSEDCUBE_HDC1080_h |
joeata2wh | 4:53d68b18bd43 | 26 | #include "mbed.h" |
joeata2wh | 4:53d68b18bd43 | 27 | |
joeata2wh | 4:53d68b18bd43 | 28 | I2C i2chdc(I2C_SDA,I2C_SCL); |
joeata2wh | 4:53d68b18bd43 | 29 | |
joeata2wh | 4:53d68b18bd43 | 30 | typedef enum { |
joeata2wh | 4:53d68b18bd43 | 31 | TEMPERATURE = 0x00, |
joeata2wh | 4:53d68b18bd43 | 32 | HUMIDITY = 0x01, |
joeata2wh | 4:53d68b18bd43 | 33 | CONFIGURATION = 0x02, |
joeata2wh | 4:53d68b18bd43 | 34 | MANUFACTURER_ID = 0xFE, |
joeata2wh | 4:53d68b18bd43 | 35 | DEVICE_ID = 0xFF, |
joeata2wh | 4:53d68b18bd43 | 36 | SERIAL_ID_FIRST = 0xFB, |
joeata2wh | 4:53d68b18bd43 | 37 | SERIAL_ID_MID = 0xFC, |
joeata2wh | 4:53d68b18bd43 | 38 | SERIAL_ID_LAST = 0xFD, |
joeata2wh | 4:53d68b18bd43 | 39 | } HDC1080_Pointers; |
joeata2wh | 4:53d68b18bd43 | 40 | |
joeata2wh | 4:53d68b18bd43 | 41 | class ClosedCube_HDC1080 { |
joeata2wh | 4:53d68b18bd43 | 42 | public: |
joeata2wh | 4:53d68b18bd43 | 43 | ClosedCube_HDC1080(); |
joeata2wh | 4:53d68b18bd43 | 44 | |
joeata2wh | 4:53d68b18bd43 | 45 | void begin(uint8_t address); |
joeata2wh | 4:53d68b18bd43 | 46 | uint16_t readManufacturerId(); // 0x5449 ID of Texas Instruments |
joeata2wh | 4:53d68b18bd43 | 47 | uint16_t readDeviceId(); // 0x1050 ID of the device |
joeata2wh | 4:53d68b18bd43 | 48 | |
joeata2wh | 4:53d68b18bd43 | 49 | float readTemperature(); |
joeata2wh | 4:53d68b18bd43 | 50 | float readHumidity(); |
joeata2wh | 4:53d68b18bd43 | 51 | |
joeata2wh | 4:53d68b18bd43 | 52 | float readT(); // short-cut for readTemperature |
joeata2wh | 4:53d68b18bd43 | 53 | float readH(); // short-cut for readHumidity |
joeata2wh | 4:53d68b18bd43 | 54 | |
joeata2wh | 4:53d68b18bd43 | 55 | private: |
joeata2wh | 4:53d68b18bd43 | 56 | uint8_t _address; |
joeata2wh | 4:53d68b18bd43 | 57 | uint16_t readData(uint8_t pointer); |
joeata2wh | 4:53d68b18bd43 | 58 | |
joeata2wh | 4:53d68b18bd43 | 59 | }; |
joeata2wh | 4:53d68b18bd43 | 60 | |
joeata2wh | 4:53d68b18bd43 | 61 | #endif |