1/*************************************************************************** 2 This is a library for the BMP085 pressure sensor 3 4 Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout 5 ----> http://www.adafruit.com/products/391 6 ----> http://www.adafruit.com/products/1603 7 8 These displays use I2C to communicate, 2 pins are required to interface. 9 10 Adafruit invests time and resources providing this open source code, 11 please support Adafruit andopen-source hardware by purchasing products 12 from Adafruit! 13 14 Written by Kevin Townsend for Adafruit Industries. 15 BSD license, all text above must be included in any redistribution 16 ***************************************************************************/ 17#ifndef __BMP085_H__ 18#define __BMP085_H__ 19 20#if (ARDUINO >= 100) 21#include"Arduino.h" 22#else 23#include"WProgram.h" 24#endif 25 26#include <Adafruit_Sensor.h> 27 28#ifdef __AVR_ATtiny85__ 29#include"TinyWireM.h" 30#define Wire TinyWireM 31#else 32#include <Wire.h> 33#endif 34 35/*========================================================================= 36 I2C ADDRESS/BITS 37 -----------------------------------------------------------------------*/ 38#define BMP085_ADDRESS (0x77) 39/*=========================================================================*/ 40 41/*========================================================================= 42 REGISTERS 43 -----------------------------------------------------------------------*/ 44enum 45{ 46 BMP085_REGISTER_CAL_AC1 =0xAA,// R Calibration data (16 bits) 47 BMP085_REGISTER_CAL_AC2 =0xAC,// R Calibration data (16 bits) 48 BMP085_REGISTER_CAL_AC3 =0xAE,// R Calibration data (16 bits) 49 BMP085_REGISTER_CAL_AC4 =0xB0,// R Calibration data (16 bits) 50 BMP085_REGISTER_CAL_AC5 =0xB2,// R Calibration data (16 bits) 51 BMP085_REGISTER_CAL_AC6 =0xB4,// R Calibration data (16 bits) 52 BMP085_REGISTER_CAL_B1 =0xB6,// R Calibration data (16 bits) 53 BMP085_REGISTER_CAL_B2 =0xB8,// R Calibration data (16 bits) 54 BMP085_REGISTER_CAL_MB =0xBA,// R Calibration data (16 bits) 55 BMP085_REGISTER_CAL_MC =0xBC,// R Calibration data (16 bits) 56 BMP085_REGISTER_CAL_MD =0xBE,// R Calibration data (16 bits) 57 BMP085_REGISTER_CHIPID =0xD0, 58 BMP085_REGISTER_VERSION =0xD1, 59 BMP085_REGISTER_SOFTRESET =0xE0, 60 BMP085_REGISTER_CONTROL =0xF4, 61 BMP085_REGISTER_TEMPDATA =0xF6, 62 BMP085_REGISTER_PRESSUREDATA =0xF6, 63 BMP085_REGISTER_READTEMPCMD =0x2E, 64 BMP085_REGISTER_READPRESSURECMD =0x34 65}; 66/*=========================================================================*/ 67 68/*========================================================================= 69 MODE SETTINGS 70 -----------------------------------------------------------------------*/ 71typedefenum 72{ 73 BMP085_MODE_ULTRALOWPOWER =0, 74 BMP085_MODE_STANDARD =1, 75 BMP085_MODE_HIGHRES =2, 76 BMP085_MODE_ULTRAHIGHRES =3 77} bmp085_mode_t; 78/*=========================================================================*/ 79 80/*========================================================================= 81 CALIBRATION DATA 82 -----------------------------------------------------------------------*/ 83typedefstruct 84{ 85int16_t ac1; 86int16_t ac2; 87int16_t ac3; 88uint16_t ac4; 89uint16_t ac5; 90uint16_t ac6; 91int16_t b1; 92int16_t b2; 93int16_t mb; 94int16_t mc; 95int16_t md; 96} bmp085_calib_data; 97/*=========================================================================*/ 98 99class Adafruit_BMP085_Unified :public Adafruit_Sensor 100{ 101public: 102Adafruit_BMP085_Unified(int32_t sensorID = -1); 103 104boolbegin(bmp085_mode_t mode = BMP085_MODE_ULTRAHIGHRES); 105voidgetTemperature(float*temp); 106voidgetPressure(float*pressure); 107floatpressureToAltitude(float seaLvel,float atmospheric); 108floatseaLevelForAltitude(float altitude,float atmospheric); 109// Note that the next two functions are just for compatibility with old 110// code that passed the temperature as a third parameter. A newer 111// calculation is used which does not need temperature. 112floatpressureToAltitude(float seaLevel,float atmospheric,float temp); 113floatseaLevelForAltitude(float altitude,float atmospheric,float temp); 114boolgetEvent(sensors_event_t*); 115voidgetSensor(sensor_t*); 116 117private: 118int32_tcomputeB5(int32_t ut); 119int32_t _sensorID; 120}; 121 122#endif