upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
th02.hpp
1 /*
2  * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3  * Contributions: Jon Trulson <jtlulson@ics.com>
4  * Copyright (c) 2014 Intel Corporation.
5  *
6  * Credits to Seeed Studeo.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  */
27 #pragma once
28 
29 #include <string>
30 #include <mraa/i2c.hpp>
31 
32 #define TH02_ADDR 0x40 // device address
33 
34 #define TH02_REG_STATUS 0x00
35 #define TH02_REG_DATA_H 0x01
36 #define TH02_REG_DATA_L 0x02
37 #define TH02_REG_CONFIG 0x03
38 #define TH02_REG_ID 0x11
39 
40 #define TH02_STATUS_RDY_MASK 0x01
41 
42 #define TH02_CMD_MEASURE_HUMI 0x01
43 #define TH02_CMD_MEASURE_TEMP 0x11
44 
45 namespace upm {
46 
72 class TH02 {
73  public:
77  TH02 (int bus=0, uint8_t addr=TH02_ADDR);
78 
82  ~TH02 ();
83 
87  float getTemperature ();
88 
92  float getHumidity ();
93 
97  bool getStatus ();
98 
102  std::string name()
103  {
104  return m_name;
105  }
106 
107  private:
108  std::string m_name;
109  mraa::I2c m_i2c;
110  uint8_t m_addr;
111 };
112 
113 }
std::string name()
Definition: th02.hpp:102
bool getStatus()
Definition: th02.cxx:95
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
float getHumidity()
Definition: th02.cxx:74
~TH02()
Definition: th02.cxx:49
TH02(int bus=0, uint8_t addr=TH02_ADDR)
Definition: th02.cxx:38
float getTemperature()
Definition: th02.cxx:53
API for the TH02 Temperature & Humidity Sensor.
Definition: th02.hpp:72