upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
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 "interfaces/iTemperatureSensor.hpp"
29 #include "interfaces/iHumiditySensor.hpp"
30 
31 /* ADDRESS AND NOT_FOUND VALUE */
32 #define SI7005_ADDRESS ( 0x40 )
33 #define SI7005_NOT_FOUND ( 0x00 )
34 
35 namespace upm {
36 
62 class SI7005 : public ITemperatureSensor, public IHumiditySensor {
63  public:
70  SI7005 (int bus, int pin);
71 
75  ~SI7005 ();
76 
80  uint16_t getTemperatureRaw ();
81 
85  int getTemperatureCelsius ();
86 
90  uint16_t getHumidityRaw ();
91 
95  int getHumidityRelative ();
96 
100  virtual const char* getModuleName() { return "si7005"; }
101 
105  bool isAvailable();
106 
110  void enableHeater();
111 
115  void disableHeater();
116 
121 
126 
127  private:
128  /* Disable implicit copy and assignment operators */
129  SI7005(const SI7005&) = delete;
130  SI7005 &operator=(const SI7005&) = delete;
131 
132  int m_controlAddr;
133  int m_bus;
134  int m_pin;
135  mraa::I2c* m_i2c;
136  mraa::Result status;
137  uint8_t config_reg;
138  float last_temperature;
139 
140  uint16_t getMeasurement(uint8_t configValue);
141 };
142 
143 }
void disableFastConversionMode()
Definition: si7005.cxx:198
bool isAvailable()
Definition: si7005.cxx:162
void enableHeater()
Definition: si7005.cxx:180
uint16_t getHumidityRaw()
Definition: si7005.cxx:106
void disableHeater()
Definition: si7005.cxx:186
uint16_t getTemperatureRaw()
Definition: si7005.cxx:93
Interface for Temperature Sensors.
Definition: iTemperatureSensor.hpp:34
~SI7005()
Definition: si7005.cxx:88
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void enableFastConversionMode()
Definition: si7005.cxx:192
SI7005(int bus, int pin)
Definition: si7005.cxx:72
Definition: si7005.hpp:62
virtual const char * getModuleName()
Definition: si7005.hpp:100
int getHumidityRelative()
Definition: si7005.cxx:111
Interface for Humidity Sensors.
Definition: iHumiditySensor.hpp:34
int getTemperatureCelsius()
Definition: si7005.cxx:98