libraries / BMP180_Breakout_Arduino_Library-master / src / SFE_BMP180.hon commit Added link to project report (97a3ba0)
   1/*
   2        SFE_BMP180.h
   3        Bosch BMP180 pressure sensor library for the Arduino microcontroller
   4        Mike Grusin, SparkFun Electronics
   5
   6        Uses floating-point equations from the Weather Station Data Logger project
   7        http://wmrx00.sourceforge.net/
   8        http://wmrx00.sourceforge.net/Arduino/BMP085-Calcs.pdf
   9
  10        Forked from BMP085 library by M.Grusin
  11
  12        version 1.0 2013/09/20 initial version
  13        Verison 1.1.2 - Updated for Arduino 1.6.4 5/2015
  14        
  15        Our example code uses the "beerware" license. You can do anything
  16        you like with this code. No really, anything. If you find it useful,
  17        buy me a (root) beer someday.
  18*/
  19
  20#ifndef SFE_BMP180_h
  21#define SFE_BMP180_h
  22
  23#if defined(ARDUINO) && ARDUINO >= 100
  24#include "Arduino.h"
  25#else
  26#include "WProgram.h"
  27#endif
  28
  29class SFE_BMP180
  30{
  31        public:
  32                SFE_BMP180(); // base type
  33
  34                char begin();
  35                        // call pressure.begin() to initialize BMP180 before use
  36                        // returns 1 if success, 0 if failure (bad component or I2C bus shorted?)
  37                
  38                char startTemperature(void);
  39                        // command BMP180 to start a temperature measurement
  40                        // returns (number of ms to wait) for success, 0 for fail
  41
  42                char getTemperature(double &T);
  43                        // return temperature measurement from previous startTemperature command
  44                        // places returned value in T variable (deg C)
  45                        // returns 1 for success, 0 for fail
  46
  47                char startPressure(char oversampling);
  48                        // command BMP180 to start a pressure measurement
  49                        // oversampling: 0 - 3 for oversampling value
  50                        // returns (number of ms to wait) for success, 0 for fail
  51
  52                char getPressure(double &P, double &T);
  53                        // return absolute pressure measurement from previous startPressure command
  54                        // note: requires previous temperature measurement in variable T
  55                        // places returned value in P variable (mbar)
  56                        // returns 1 for success, 0 for fail
  57
  58                double sealevel(double P, double A);
  59                        // convert absolute pressure to sea-level pressure (as used in weather data)
  60                        // P: absolute pressure (mbar)
  61                        // A: current altitude (meters)
  62                        // returns sealevel pressure in mbar
  63
  64                double altitude(double P, double P0);
  65                        // convert absolute pressure to altitude (given baseline pressure; sea-level, runway, etc.)
  66                        // P: absolute pressure (mbar)
  67                        // P0: fixed baseline pressure (mbar)
  68                        // returns signed altitude in meters
  69
  70                char getError(void);
  71                        // If any library command fails, you can retrieve an extended
  72                        // error code using this command. Errors are from the wire library: 
  73                        // 0 = Success
  74                        // 1 = Data too long to fit in transmit buffer
  75                        // 2 = Received NACK on transmit of address
  76                        // 3 = Received NACK on transmit of data
  77                        // 4 = Other error
  78
  79        private:
  80        
  81                char readInt(char address, int16_t &value);
  82                        // read an signed int (16 bits) from a BMP180 register
  83                        // address: BMP180 register address
  84                        // value: external signed int for returned value (16 bits)
  85                        // returns 1 for success, 0 for fail, with result in value
  86
  87                char readUInt(char address, uint16_t &value);
  88                        // read an unsigned int (16 bits) from a BMP180 register
  89                        // address: BMP180 register address
  90                        // value: external unsigned int for returned value (16 bits)
  91                        // returns 1 for success, 0 for fail, with result in value
  92
  93                char readBytes(unsigned char *values, char length);
  94                        // read a number of bytes from a BMP180 register
  95                        // values: array of char with register address in first location [0]
  96                        // length: number of bytes to read back
  97                        // returns 1 for success, 0 for fail, with read bytes in values[] array
  98                        
  99                char writeBytes(unsigned char *values, char length);
 100                        // write a number of bytes to a BMP180 register (and consecutive subsequent registers)
 101                        // values: array of char with register address in first location [0]
 102                        // length: number of bytes to write
 103                        // returns 1 for success, 0 for fail
 104                        
 105                int16_t AC1,AC2,AC3,VB1,VB2,MB,MC,MD;
 106                uint16_t AC4,AC5,AC6; 
 107                double c5,c6,mc,md,x0,x1,x2,y0,y1,y2,p0,p1,p2;
 108                char _error;
 109};
 110
 111#define BMP180_ADDR 0x77 // 7-bit address
 112
 113#define BMP180_REG_CONTROL 0xF4
 114#define BMP180_REG_RESULT 0xF6
 115
 116#define BMP180_COMMAND_TEMPERATURE 0x2E
 117#define BMP180_COMMAND_PRESSURE0 0x34
 118#define BMP180_COMMAND_PRESSURE1 0x74
 119#define BMP180_COMMAND_PRESSURE2 0xB4
 120#define BMP180_COMMAND_PRESSURE3 0xF4
 121
 122#endif