2 * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3 * Copyright (c) 2014 Intel Corporation.
5 * Credits to Seeed Studeo.
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 #define ADDR 0x40 // device address
33 #define REG_STATUS 0x00
34 #define REG_DATA_H 0x01
35 #define REG_DATA_L 0x02
36 #define REG_CONFIG 0x03
39 #define STATUS_RDY_MASK 0x01
41 #define CMD_MEASURE_HUMI 0x01
42 #define CMD_MEASURE_TEMP 0x11
44 #define TH02_WR_REG_MODE 0xC0
45 #define TH02_RD_REG_MODE 0x80
53 * @brief C++ API for TH02 chip (Temperature and Humidity Sensor Pro)
55 * This file defines the TH02 C++ interface for libth02
57 * @snippet th02-example.cxx Interesting
63 * Instanciates a TH02 object
68 * TH02 object destructor, basicaly it close i2c connection.
73 * Get the temperature value from sensor.
75 float getTemperature ();
78 * Get the humidity value from sensor.
83 * Get the sensor's status.
88 * Return name of the component
96 mraa_i2c_context m_i2Ctx;
98 uint16_t i2cReadReg_N (int reg, unsigned int len, uint8_t * buffer);
99 mraa_result_t i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer);
100 mraa_result_t i2cWriteReg (uint8_t reg, uint8_t data);