upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
hdc1000.hpp
1 /*
2  * Author: Norbert Wesp <nwesp@phytec.de>
3  * Copyright (c) 2017 Phytec Messtechnik GmbH.
4  *
5  * based on: RIOT-driver hdc1000 by Johann Fischer <j.fischer@phytec.de>
6  *
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:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
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.
25  */
26 
27 #pragma once
28 
29 #include <string>
30 #include <mraa/i2c.hpp>
31 #include <math.h>
32 
33 #define HDC1000_NAME "hdc1000"
34 #define HDC1000_i2C_ADDRESS 0x43
35 #define HDC1000_MANUFACTURER_ID 0x5449 /* ID of Texas Instruments */
36 #define HDC1000_DEVICE_ID 0x1000 /* ID of HDC1000 device */
37 
38 /* HDC1000 Register Map */
39 #define HDC1000_TEMPERATURE 0x00
40 #define HDC1000_HUMIDITY 0x01
41 #define HDC1000_CONFIGURATION 0x02
42 #define HDC1000_MANUFACTURER_ID_REG 0xFE
43 #define HDC1000_DEVICE_ID_REG 0xFF
44 
45 /* HDC1000 configuration register bitmap */
46 #define HDC1000_RST_SOFT 0x8000
47 #define HDC1000_HEAT (1 << 13)
48 #define HDC1000_SEQ_MODE (1 << 12)
49 #define HDC1000_BTST_LOW (1 << 11)
50 #define HDC1000_TRES_14 (0)
51 #define HDC1000_TRES_11 (1 << 10)
52 #define HDC1000_HRES_14 (0)
53 #define HDC1000_HRES_11 (1 << 8)
54 #define HDC1000_HRES_8 (1 << 9)
55 
56 #define SLEEP_SEC (1000*1000)
57 
58 namespace upm {
59 
90 class HDC1000 {
91  public:
98  HDC1000 (int bus, int devAddr=HDC1000_i2C_ADDRESS);
99 
106  int checkID(void);
107 
112  void resetSensor(void);
113 
118  void sampleData(void);
119 
126  float getHumidity(int bSampleData = false);
127 
134  float getTemperature(int bSampleData = false);
135 
136  private:
137 
138  std::string m_name;
139 
140  int m_controlAddr;
141  int m_bus;
142  mraa::I2c m_i2ControlCtx;
143 
144  int32_t m_temperature;
145  int32_t m_humidity;
146 };
147 
148 }
HDC1000(int bus, int devAddr=HDC1000_i2C_ADDRESS)
Definition: hdc1000.cpp:39
void sampleData(void)
Definition: hdc1000.cpp:97
int checkID(void)
Definition: hdc1000.cpp:64
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
API for the HDC1000 Temperature & Humidity Sensor.
Definition: hdc1000.hpp:90
float getHumidity(int bSampleData=false)
Definition: hdc1000.cpp:129
void resetSensor(void)
Definition: hdc1000.cpp:86
float getTemperature(int bSampleData=false)
Definition: hdc1000.cpp:120