upm  0.6.2
Sensor/Actuator repository for libmraa (v0.10.1)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bmp180.h
1 /*
2  * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3  * Contributions: Jon Trulson <jtrulson@ics.com>
4  * Copyright (c) 2014 Intel Corporation.
5  *
6  * Credits to Adafruit.
7  * Based on Adafruit BMP180 library.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  */
28 #pragma once
29 
30 #include <string>
31 #include <mraa/i2c.hpp>
32 #include "upm/iPressureSensor.h"
33 #include "upm/iTemperatureSensor.h"
34 
35 #define BMP180_ADDR 0x77 // device address
36 
37 /* MODES */
38 #define BMP180_ULTRALOWPOWER 0
39 #define BMP180_STANDARD 1
40 #define BMP180_HIGHRES 2
41 #define BMP180_ULTRAHIGHRES 3
42 
43 
44 namespace upm {
45 
71 class BMP180 : public IPressureSensor, public ITemperatureSensor {
72  public:
80  BMP180 (int bus, int devAddr=BMP180_ADDR, uint8_t mode=BMP180_ULTRAHIGHRES);
81 
85  ~BMP180 ();
86 
90  uint32_t getPressureRaw();
91 
95  int getPressurePa();
96 
97  uint16_t getTemperatureRaw();
101  int getTemperatureCelcius();
102 
106  bool isAvailable();
107  const char* getModuleName() { return m_name.c_str(); }
108 
109  private:
110  std::string m_name;
111 
112  int m_controlAddr;
113  int m_bus;
114  mraa::I2c* m_i2c;
115  mraa::Result status;
116 
117  uint8_t oversampling;
118  int16_t ac1, ac2, ac3, b1, b2, mb, mc, md;
119  uint16_t ac4, ac5, ac6;
120 
121  int32_t b5;
122 
123  bool getCalibrationData();
124 };
125 
126 }
BMP180(int bus, int devAddr=BMP180_ADDR, uint8_t mode=BMP180_ULTRAHIGHRES)
Definition: bmp180.cxx:97
bool isAvailable()
Definition: bmp180.cxx:278
int getTemperatureCelcius()
Definition: bmp180.cxx:168
Interface for Temperature Sensors.
Definition: iTemperatureSensor.h:34
uint32_t getPressureRaw()
Definition: bmp180.cxx:189
~BMP180()
Definition: bmp180.cxx:117
int getPressurePa()
Definition: bmp180.cxx:122
const char * getModuleName()
Definition: bmp180.h:107
API for Bosch BMP180 Pressure Sensor.
Definition: bmp180.h:71
Interface for Pressue Sensors.
Definition: iPressureSensor.h:38