barometric pressure sensor BMP085 http://mbed.org/users/okini3939/notebook/barometric-pressure-sensor-bmp085/ http://mbed.org/users/okini3939/notebook/weatherduino-on-mbed/

Dependents:   WeatherPlatform_20110408 WeatherPlatform ENVLogger WeatherStation ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BMP085.h Source File

BMP085.h

Go to the documentation of this file.
00001 /*
00002  * mbed library to use a Bosch Sensortec BMP085/BMP180 sensor
00003  * Copyright (c) 2010 Hiroshi Suga
00004  * Released under the MIT License: http://mbed.org/license/mit
00005  */
00006  
00007 /** @file BMP085.h
00008  * @brief mbed library to use a Bosch Sensortec BMP085/BMP180 sensor
00009  * barometric pressure sensor BMP085/BMP180 (Bosch Sensortec)
00010  * interface: I2C digital
00011  */
00012  
00013 #ifndef BMP085_H
00014 #define BMP085_H
00015 
00016 #include "mbed.h"
00017 
00018 /**
00019  * @brief over sampling setting
00020  */
00021 enum BMP085_oss {
00022     BMP085_oss1 = 0, ///< ultra low power (1 time)
00023     BMP085_oss2 = 1, ///< standard (2 times)
00024     BMP085_oss4 = 2, ///< high resolution (4 times)
00025     BMP085_oss8 = 3  ///< ultra high resolution (8 times)
00026 };
00027 
00028 /**
00029  * @brief BMP085 class
00030  */
00031 class BMP085 {
00032 public:
00033     BMP085(PinName p_sda, PinName p_scl, BMP085_oss p_oss = BMP085_oss1);
00034     BMP085(I2C& p_i2c, BMP085_oss p_oss = BMP085_oss1);
00035 
00036     float get_temperature();
00037     float get_pressure();
00038     void update();
00039 
00040 protected:
00041     void init(BMP085_oss);
00042     unsigned short twi_readshort (int, int);
00043     unsigned long twi_readlong (int, int);
00044     void twi_writechar (int, int, int);
00045 
00046     I2C i2c;
00047     float temperature;
00048     float pressure;
00049 
00050 private:
00051 
00052     short ac1, ac2, ac3, b1, b2, mb, mc, md, oss;
00053     unsigned short ac4, ac5, ac6;
00054 };
00055 
00056 #endif