upm  0.7.1
Sensor/Actuator repository for libmraa (v1.0.0)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
si7005.hpp
1 /*
2  * Author: Scott Ware <scott.r.ware@intel.com>
3  * Copyright (c) 2014 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <mraa/i2c.hpp>
27 
28 #include "upm/iTemperatureSensor.hpp"
29 #include "upm/iHumiditySensor.hpp"
30 
31 /* ADDRESS AND NOT_FOUND VALUE */
32 #define SI7005_ADDRESS ( 0x40 )
33 #define SI7005_NOT_FOUND ( 0x00 )
34 
35 
36 namespace upm {
37 
61 class SI7005 : public ITemperatureSensor, public IHumiditySensor {
62  public:
70  SI7005 (int bus, int pin);
71 
75  ~SI7005 ();
76 
80  uint16_t getTemperatureRaw ();
81 
85  int getTemperatureCelcius ();
86 
90  uint16_t getHumidityRaw ();
91 
95  int getHumidityRelative ();
96 
100  const char* getModuleName() { return "si7005"; }
101 
105  bool isAvailable();
106 
110  void enableHeater();
111 
115  void disableHeater();
116 
121 
126 
127  private:
128  int m_controlAddr;
129  int m_bus;
130  int m_pin;
131  mraa::I2c* m_i2c;
132  mraa::Result status;
133  uint8_t config_reg;
134  float last_temperature;
135 
136  uint16_t getMeasurement(uint8_t configValue);
137 };
138 
139 }
void disableFastConversionMode()
Definition: si7005.cxx:200
bool isAvailable()
Definition: si7005.cxx:163
void enableHeater()
Definition: si7005.cxx:182
uint16_t getHumidityRaw()
Definition: si7005.cxx:106
void disableHeater()
Definition: si7005.cxx:188
uint16_t getTemperatureRaw()
Definition: si7005.cxx:93
Interface for Temperature Sensors.
Definition: iTemperatureSensor.hpp:34
~SI7005()
Definition: si7005.cxx:88
int getTemperatureCelcius()
Definition: si7005.cxx:98
const char * getModuleName()
Definition: si7005.hpp:100
void enableFastConversionMode()
Definition: si7005.cxx:194
SI7005(int bus, int pin)
Definition: si7005.cxx:72
C++ API for SI7005 sensor (Humidity And Temperature Sensor)
Definition: si7005.hpp:61
int getHumidityRelative()
Definition: si7005.cxx:111
Interface for Humidity Sensors.
Definition: iHumiditySensor.hpp:34