Honeywell HumidIcon Digital Humidty/Temperature Sensor.

Dependents:   test_HIH6130 testSensor

Committer:
Rhyme
Date:
Sun Dec 13 08:34:46 2015 +0000
Revision:
0:8d7f06935726
Child:
1:1855077b0459
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:8d7f06935726 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
Rhyme 0:8d7f06935726 2 *
Rhyme 0:8d7f06935726 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Rhyme 0:8d7f06935726 4 * and associated documentation files (the "Software"), to deal in the Software without
Rhyme 0:8d7f06935726 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
Rhyme 0:8d7f06935726 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Rhyme 0:8d7f06935726 7 * Software is furnished to do so, subject to the following conditions:
Rhyme 0:8d7f06935726 8 *
Rhyme 0:8d7f06935726 9 * The above copyright notice and this permission notice shall be included in all copies or
Rhyme 0:8d7f06935726 10 * substantial portions of the Software.
Rhyme 0:8d7f06935726 11 *
Rhyme 0:8d7f06935726 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Rhyme 0:8d7f06935726 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Rhyme 0:8d7f06935726 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Rhyme 0:8d7f06935726 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Rhyme 0:8d7f06935726 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Rhyme 0:8d7f06935726 17 */
Rhyme 0:8d7f06935726 18
Rhyme 0:8d7f06935726 19 #ifndef HIH6130_H
Rhyme 0:8d7f06935726 20 #define HIH6130_H
Rhyme 0:8d7f06935726 21
Rhyme 0:8d7f06935726 22 #include "mbed.h"
Rhyme 0:8d7f06935726 23
Rhyme 0:8d7f06935726 24 /**
Rhyme 0:8d7f06935726 25 * Honeywell HumidIcon Digital Humidity/Temperature Sensors
Rhyme 0:8d7f06935726 26 *
Rhyme 0:8d7f06935726 27 * @code
Rhyme 0:8d7f06935726 28 * #include "mbed.h"
Rhyme 0:8d7f06935726 29 * #include "HIH6130.h"
Rhyme 0:8d7f06935726 30 *
Rhyme 0:8d7f06935726 31 * #define HIH6130_I2C_ADDRESS (0x27<<1)
Rhyme 0:8d7f06935726 32 *
Rhyme 0:8d7f06935726 33 * int main(void) {
Rhyme 0:8d7f06935726 34 *
Rhyme 0:8d7f06935726 35 * HIH6130 hih(P_E25, P_E24, MMA8451_I2C_ADDRESS);
Rhyme 0:8d7f06935726 36 *
Rhyme 0:8d7f06935726 37 * while (true) {
Rhyme 0:8d7f06935726 38 * hih.getHumidity() ;
Rhyme 0:8d7f06935726 39 * wait(0.1);
Rhyme 0:8d7f06935726 40 * }
Rhyme 0:8d7f06935726 41 * }
Rhyme 0:8d7f06935726 42 * @endcode
Rhyme 0:8d7f06935726 43 */
Rhyme 0:8d7f06935726 44 class HIH6130
Rhyme 0:8d7f06935726 45 {
Rhyme 0:8d7f06935726 46 public:
Rhyme 0:8d7f06935726 47 /**
Rhyme 0:8d7f06935726 48 * HIH6130 constructor
Rhyme 0:8d7f06935726 49 *
Rhyme 0:8d7f06935726 50 * @param sda SDA pin
Rhyme 0:8d7f06935726 51 * @param sdl SCL pin
Rhyme 0:8d7f06935726 52 * @param addr addr of the I2C peripheral
Rhyme 0:8d7f06935726 53 */
Rhyme 0:8d7f06935726 54 HIH6130(PinName sda, PinName scl, int addr);
Rhyme 0:8d7f06935726 55
Rhyme 0:8d7f06935726 56 /**
Rhyme 0:8d7f06935726 57 * HIH6130 destructor
Rhyme 0:8d7f06935726 58 */
Rhyme 0:8d7f06935726 59 ~HIH6130();
Rhyme 0:8d7f06935726 60
Rhyme 0:8d7f06935726 61 uint16_t getValue(float *humidity, float *temperature) ;
Rhyme 0:8d7f06935726 62
Rhyme 0:8d7f06935726 63 private:
Rhyme 0:8d7f06935726 64 I2C m_i2c;
Rhyme 0:8d7f06935726 65 int m_addr;
Rhyme 0:8d7f06935726 66 void readRegs(int addr, uint8_t * data, int len);
Rhyme 0:8d7f06935726 67 void writeRegs(uint8_t * data, int len);
Rhyme 0:8d7f06935726 68
Rhyme 0:8d7f06935726 69 };
Rhyme 0:8d7f06935726 70
Rhyme 0:8d7f06935726 71 #endif