upm  0.8.0
Sensor/Actuator repository for libmraa (v1.1.1)
 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 
62 class SI7005 : public ITemperatureSensor, public IHumiditySensor {
63  public:
71  SI7005 (int bus, int pin);
72 
76  ~SI7005 ();
77 
81  uint16_t getTemperatureRaw ();
82 
86  int getTemperatureCelsius ();
87 
91  uint16_t getHumidityRaw ();
92 
96  int getHumidityRelative ();
97 
101  const char* getModuleName() { return "si7005"; }
102 
106  bool isAvailable();
107 
111  void enableHeater();
112 
116  void disableHeater();
117 
122 
127 
128  private:
129  int m_controlAddr;
130  int m_bus;
131  int m_pin;
132  mraa::I2c* m_i2c;
133  mraa::Result status;
134  uint8_t config_reg;
135  float last_temperature;
136 
137  uint16_t getMeasurement(uint8_t configValue);
138 };
139 
140 }
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
const char * getModuleName()
Definition: si7005.hpp:101
void enableFastConversionMode()
Definition: si7005.cxx:194
SI7005(int bus, int pin)
Definition: si7005.cxx:72
Definition: si7005.hpp:62
int getHumidityRelative()
Definition: si7005.cxx:111
Interface for Humidity Sensors.
Definition: iHumiditySensor.hpp:34
int getTemperatureCelsius()
Definition: si7005.cxx:98