mirror of
https://github.com/adafruit/Adafruit_BMP085_Unified.git
synced 2025-07-30 00:47:16 +02:00
Moved to actions, doxyified
This commit is contained in:
32
.github/workflows/githubci.yml
vendored
Normal file
32
.github/workflows/githubci.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
name: Arduino Library CI
|
||||||
|
|
||||||
|
on: [pull_request, push, repository_dispatch]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: adafruit/ci-arduino
|
||||||
|
path: ci
|
||||||
|
|
||||||
|
- name: pre-install
|
||||||
|
run: bash ci/actions_install.sh
|
||||||
|
|
||||||
|
- name: test platforms
|
||||||
|
run: python3 ci/build_platform.py main_platforms
|
||||||
|
|
||||||
|
- name: clang
|
||||||
|
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||||
|
|
||||||
|
- name: doxygen
|
||||||
|
env:
|
||||||
|
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||||
|
PRETTYNAME : "Adafruit BMP085 Unified"
|
||||||
|
run: bash ci/doxy_gen_and_deploy.sh
|
@ -1,41 +1,54 @@
|
|||||||
/***************************************************************************
|
/*!
|
||||||
This is a library for the BMP085 pressure sensor
|
* @file Adafruit_BMP085_U.cpp
|
||||||
|
*
|
||||||
|
* @mainpage Adafruit BMP085 Pressure Sensor
|
||||||
|
*
|
||||||
|
* @section intro_sec Introduction
|
||||||
|
*
|
||||||
|
* This is a library for the BMP085 pressure sensor
|
||||||
|
*
|
||||||
|
* Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout
|
||||||
|
* ----> http://www.adafruit.com/products/391
|
||||||
|
* ----> http://www.adafruit.com/products/1603
|
||||||
|
*
|
||||||
|
* These displays use I2C to communicate, 2 pins are required to interface.
|
||||||
|
*
|
||||||
|
* Adafruit invests time and resources providing this open source code,
|
||||||
|
* please support Adafruit andopen-source hardware by purchasing products
|
||||||
|
* from Adafruit!
|
||||||
|
*
|
||||||
|
* @section author Author
|
||||||
|
*
|
||||||
|
* Written by Kevin Townsend for Adafruit Industries.
|
||||||
|
*
|
||||||
|
* @section license License
|
||||||
|
* BSD license, all text above must be included in any redistribution
|
||||||
|
*/
|
||||||
|
|
||||||
Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout
|
|
||||||
----> http://www.adafruit.com/products/391
|
|
||||||
----> http://www.adafruit.com/products/1603
|
|
||||||
|
|
||||||
These displays use I2C to communicate, 2 pins are required to interface.
|
|
||||||
|
|
||||||
Adafruit invests time and resources providing this open source code,
|
|
||||||
please support Adafruit andopen-source hardware by purchasing products
|
|
||||||
from Adafruit!
|
|
||||||
|
|
||||||
Written by Kevin Townsend for Adafruit Industries.
|
|
||||||
BSD license, all text above must be included in any redistribution
|
|
||||||
***************************************************************************/
|
|
||||||
#if ARDUINO >= 100
|
#if ARDUINO >= 100
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#else
|
#else
|
||||||
#include "WProgram.h"
|
#include "WProgram.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __AVR_ATtiny85__
|
#ifdef __AVR_ATtiny85__
|
||||||
#include "TinyWireM.h"
|
#include "TinyWireM.h"
|
||||||
#define Wire TinyWireM
|
#define Wire TinyWireM
|
||||||
#else
|
#else
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "Adafruit_BMP085_U.h"
|
#include "Adafruit_BMP085_U.h"
|
||||||
|
|
||||||
static bmp085_calib_data _bmp085_coeffs; // Last read accelerometer data will be available here
|
static bmp085_calib_data
|
||||||
static uint8_t _bmp085Mode;
|
_bmp085_coeffs; // Last read accelerometer data will be available here
|
||||||
|
static uint8_t _bmp085Mode;
|
||||||
|
|
||||||
#define BMP085_USE_DATASHEET_VALS (0) /* Set to 1 for sanity check */
|
#define BMP085_USE_DATASHEET_VALS \
|
||||||
|
(0) //!< Set to 1 for sanity check, when true, will use values from datasheet
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
PRIVATE FUNCTIONS
|
PRIVATE FUNCTIONS
|
||||||
@ -46,16 +59,15 @@ static uint8_t _bmp085Mode;
|
|||||||
@brief Writes an 8 bit value over I2C
|
@brief Writes an 8 bit value over I2C
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
static void writeCommand(byte reg, byte value)
|
static void writeCommand(byte reg, byte value) {
|
||||||
{
|
|
||||||
Wire.beginTransmission((uint8_t)BMP085_ADDRESS);
|
Wire.beginTransmission((uint8_t)BMP085_ADDRESS);
|
||||||
#if ARDUINO >= 100
|
#if ARDUINO >= 100
|
||||||
Wire.write((uint8_t)reg);
|
Wire.write((uint8_t)reg);
|
||||||
Wire.write((uint8_t)value);
|
Wire.write((uint8_t)value);
|
||||||
#else
|
#else
|
||||||
Wire.send(reg);
|
Wire.send(reg);
|
||||||
Wire.send(value);
|
Wire.send(value);
|
||||||
#endif
|
#endif
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,21 +76,20 @@ static void writeCommand(byte reg, byte value)
|
|||||||
@brief Reads an 8 bit value over I2C
|
@brief Reads an 8 bit value over I2C
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
static void read8(byte reg, uint8_t *value)
|
static void read8(byte reg, uint8_t *value) {
|
||||||
{
|
|
||||||
Wire.beginTransmission((uint8_t)BMP085_ADDRESS);
|
Wire.beginTransmission((uint8_t)BMP085_ADDRESS);
|
||||||
#if ARDUINO >= 100
|
#if ARDUINO >= 100
|
||||||
Wire.write((uint8_t)reg);
|
Wire.write((uint8_t)reg);
|
||||||
#else
|
#else
|
||||||
Wire.send(reg);
|
Wire.send(reg);
|
||||||
#endif
|
#endif
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
Wire.requestFrom((uint8_t)BMP085_ADDRESS, (byte)1);
|
Wire.requestFrom((uint8_t)BMP085_ADDRESS, (byte)1);
|
||||||
#if ARDUINO >= 100
|
#if ARDUINO >= 100
|
||||||
*value = Wire.read();
|
*value = Wire.read();
|
||||||
#else
|
#else
|
||||||
*value = Wire.receive();
|
*value = Wire.receive();
|
||||||
#endif
|
#endif
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,21 +98,20 @@ static void read8(byte reg, uint8_t *value)
|
|||||||
@brief Reads a 16 bit value over I2C
|
@brief Reads a 16 bit value over I2C
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
static void read16(byte reg, uint16_t *value)
|
static void read16(byte reg, uint16_t *value) {
|
||||||
{
|
|
||||||
Wire.beginTransmission((uint8_t)BMP085_ADDRESS);
|
Wire.beginTransmission((uint8_t)BMP085_ADDRESS);
|
||||||
#if ARDUINO >= 100
|
#if ARDUINO >= 100
|
||||||
Wire.write((uint8_t)reg);
|
Wire.write((uint8_t)reg);
|
||||||
#else
|
#else
|
||||||
Wire.send(reg);
|
Wire.send(reg);
|
||||||
#endif
|
#endif
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
Wire.requestFrom((uint8_t)BMP085_ADDRESS, (byte)2);
|
Wire.requestFrom((uint8_t)BMP085_ADDRESS, (byte)2);
|
||||||
#if ARDUINO >= 100
|
#if ARDUINO >= 100
|
||||||
*value = (Wire.read() << 8) | Wire.read();
|
*value = (Wire.read() << 8) | Wire.read();
|
||||||
#else
|
#else
|
||||||
*value = (Wire.receive() << 8) | Wire.receive();
|
*value = (Wire.receive() << 8) | Wire.receive();
|
||||||
#endif
|
#endif
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +120,7 @@ static void read16(byte reg, uint16_t *value)
|
|||||||
@brief Reads a signed 16 bit value over I2C
|
@brief Reads a signed 16 bit value over I2C
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
static void readS16(byte reg, int16_t *value)
|
static void readS16(byte reg, int16_t *value) {
|
||||||
{
|
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
read16(reg, &i);
|
read16(reg, &i);
|
||||||
*value = (int16_t)i;
|
*value = (int16_t)i;
|
||||||
@ -122,34 +131,33 @@ static void readS16(byte reg, int16_t *value)
|
|||||||
@brief Reads the factory-set coefficients
|
@brief Reads the factory-set coefficients
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
static void readCoefficients(void)
|
static void readCoefficients(void) {
|
||||||
{
|
#if BMP085_USE_DATASHEET_VALS
|
||||||
#if BMP085_USE_DATASHEET_VALS
|
_bmp085_coeffs.ac1 = 408;
|
||||||
_bmp085_coeffs.ac1 = 408;
|
_bmp085_coeffs.ac2 = -72;
|
||||||
_bmp085_coeffs.ac2 = -72;
|
_bmp085_coeffs.ac3 = -14383;
|
||||||
_bmp085_coeffs.ac3 = -14383;
|
_bmp085_coeffs.ac4 = 32741;
|
||||||
_bmp085_coeffs.ac4 = 32741;
|
_bmp085_coeffs.ac5 = 32757;
|
||||||
_bmp085_coeffs.ac5 = 32757;
|
_bmp085_coeffs.ac6 = 23153;
|
||||||
_bmp085_coeffs.ac6 = 23153;
|
_bmp085_coeffs.b1 = 6190;
|
||||||
_bmp085_coeffs.b1 = 6190;
|
_bmp085_coeffs.b2 = 4;
|
||||||
_bmp085_coeffs.b2 = 4;
|
_bmp085_coeffs.mb = -32768;
|
||||||
_bmp085_coeffs.mb = -32768;
|
_bmp085_coeffs.mc = -8711;
|
||||||
_bmp085_coeffs.mc = -8711;
|
_bmp085_coeffs.md = 2868;
|
||||||
_bmp085_coeffs.md = 2868;
|
_bmp085Mode = 0;
|
||||||
_bmp085Mode = 0;
|
#else
|
||||||
#else
|
readS16(BMP085_REGISTER_CAL_AC1, &_bmp085_coeffs.ac1);
|
||||||
readS16(BMP085_REGISTER_CAL_AC1, &_bmp085_coeffs.ac1);
|
readS16(BMP085_REGISTER_CAL_AC2, &_bmp085_coeffs.ac2);
|
||||||
readS16(BMP085_REGISTER_CAL_AC2, &_bmp085_coeffs.ac2);
|
readS16(BMP085_REGISTER_CAL_AC3, &_bmp085_coeffs.ac3);
|
||||||
readS16(BMP085_REGISTER_CAL_AC3, &_bmp085_coeffs.ac3);
|
read16(BMP085_REGISTER_CAL_AC4, &_bmp085_coeffs.ac4);
|
||||||
read16(BMP085_REGISTER_CAL_AC4, &_bmp085_coeffs.ac4);
|
read16(BMP085_REGISTER_CAL_AC5, &_bmp085_coeffs.ac5);
|
||||||
read16(BMP085_REGISTER_CAL_AC5, &_bmp085_coeffs.ac5);
|
read16(BMP085_REGISTER_CAL_AC6, &_bmp085_coeffs.ac6);
|
||||||
read16(BMP085_REGISTER_CAL_AC6, &_bmp085_coeffs.ac6);
|
readS16(BMP085_REGISTER_CAL_B1, &_bmp085_coeffs.b1);
|
||||||
readS16(BMP085_REGISTER_CAL_B1, &_bmp085_coeffs.b1);
|
readS16(BMP085_REGISTER_CAL_B2, &_bmp085_coeffs.b2);
|
||||||
readS16(BMP085_REGISTER_CAL_B2, &_bmp085_coeffs.b2);
|
readS16(BMP085_REGISTER_CAL_MB, &_bmp085_coeffs.mb);
|
||||||
readS16(BMP085_REGISTER_CAL_MB, &_bmp085_coeffs.mb);
|
readS16(BMP085_REGISTER_CAL_MC, &_bmp085_coeffs.mc);
|
||||||
readS16(BMP085_REGISTER_CAL_MC, &_bmp085_coeffs.mc);
|
readS16(BMP085_REGISTER_CAL_MD, &_bmp085_coeffs.md);
|
||||||
readS16(BMP085_REGISTER_CAL_MD, &_bmp085_coeffs.md);
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
@ -157,59 +165,57 @@ static void readCoefficients(void)
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
static void readRawTemperature(int32_t *temperature)
|
static void readRawTemperature(int32_t *temperature) {
|
||||||
{
|
#if BMP085_USE_DATASHEET_VALS
|
||||||
#if BMP085_USE_DATASHEET_VALS
|
*temperature = 27898;
|
||||||
*temperature = 27898;
|
#else
|
||||||
#else
|
uint16_t t;
|
||||||
uint16_t t;
|
writeCommand(BMP085_REGISTER_CONTROL, BMP085_REGISTER_READTEMPCMD);
|
||||||
writeCommand(BMP085_REGISTER_CONTROL, BMP085_REGISTER_READTEMPCMD);
|
delay(5);
|
||||||
|
read16(BMP085_REGISTER_TEMPDATA, &t);
|
||||||
|
*temperature = t;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
static void readRawPressure(int32_t *pressure) {
|
||||||
|
#if BMP085_USE_DATASHEET_VALS
|
||||||
|
*pressure = 23843;
|
||||||
|
#else
|
||||||
|
uint8_t p8;
|
||||||
|
uint16_t p16;
|
||||||
|
int32_t p32;
|
||||||
|
|
||||||
|
writeCommand(BMP085_REGISTER_CONTROL,
|
||||||
|
BMP085_REGISTER_READPRESSURECMD + (_bmp085Mode << 6));
|
||||||
|
switch (_bmp085Mode) {
|
||||||
|
case BMP085_MODE_ULTRALOWPOWER:
|
||||||
delay(5);
|
delay(5);
|
||||||
read16(BMP085_REGISTER_TEMPDATA, &t);
|
break;
|
||||||
*temperature = t;
|
case BMP085_MODE_STANDARD:
|
||||||
#endif
|
delay(8);
|
||||||
}
|
break;
|
||||||
|
case BMP085_MODE_HIGHRES:
|
||||||
|
delay(14);
|
||||||
|
break;
|
||||||
|
case BMP085_MODE_ULTRAHIGHRES:
|
||||||
|
default:
|
||||||
|
delay(26);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
read16(BMP085_REGISTER_PRESSUREDATA, &p16);
|
||||||
/*!
|
p32 = (uint32_t)p16 << 8;
|
||||||
|
read8(BMP085_REGISTER_PRESSUREDATA + 2, &p8);
|
||||||
|
p32 += p8;
|
||||||
|
p32 >>= (8 - _bmp085Mode);
|
||||||
|
|
||||||
*/
|
*pressure = p32;
|
||||||
/**************************************************************************/
|
#endif
|
||||||
static void readRawPressure(int32_t *pressure)
|
|
||||||
{
|
|
||||||
#if BMP085_USE_DATASHEET_VALS
|
|
||||||
*pressure = 23843;
|
|
||||||
#else
|
|
||||||
uint8_t p8;
|
|
||||||
uint16_t p16;
|
|
||||||
int32_t p32;
|
|
||||||
|
|
||||||
writeCommand(BMP085_REGISTER_CONTROL, BMP085_REGISTER_READPRESSURECMD + (_bmp085Mode << 6));
|
|
||||||
switch(_bmp085Mode)
|
|
||||||
{
|
|
||||||
case BMP085_MODE_ULTRALOWPOWER:
|
|
||||||
delay(5);
|
|
||||||
break;
|
|
||||||
case BMP085_MODE_STANDARD:
|
|
||||||
delay(8);
|
|
||||||
break;
|
|
||||||
case BMP085_MODE_HIGHRES:
|
|
||||||
delay(14);
|
|
||||||
break;
|
|
||||||
case BMP085_MODE_ULTRAHIGHRES:
|
|
||||||
default:
|
|
||||||
delay(26);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
read16(BMP085_REGISTER_PRESSUREDATA, &p16);
|
|
||||||
p32 = (uint32_t)p16 << 8;
|
|
||||||
read8(BMP085_REGISTER_PRESSUREDATA+2, &p8);
|
|
||||||
p32 += p8;
|
|
||||||
p32 >>= (8 - _bmp085Mode);
|
|
||||||
|
|
||||||
*pressure = p32;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
@ -218,16 +224,17 @@ static void readRawPressure(int32_t *pressure)
|
|||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
int32_t Adafruit_BMP085_Unified::computeB5(int32_t ut) {
|
int32_t Adafruit_BMP085_Unified::computeB5(int32_t ut) {
|
||||||
int32_t X1 = (ut - (int32_t)_bmp085_coeffs.ac6) * ((int32_t)_bmp085_coeffs.ac5) >> 15;
|
int32_t X1 =
|
||||||
int32_t X2 = ((int32_t)_bmp085_coeffs.mc << 11) / (X1+(int32_t)_bmp085_coeffs.md);
|
(ut - (int32_t)_bmp085_coeffs.ac6) * ((int32_t)_bmp085_coeffs.ac5) >> 15;
|
||||||
|
int32_t X2 =
|
||||||
|
((int32_t)_bmp085_coeffs.mc << 11) / (X1 + (int32_t)_bmp085_coeffs.md);
|
||||||
return X1 + X2;
|
return X1 + X2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
CONSTRUCTOR
|
CONSTRUCTOR
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Instantiates a new Adafruit_BMP085_Unified class
|
@brief Instantiates a new Adafruit_BMP085_Unified class
|
||||||
@ -240,28 +247,25 @@ Adafruit_BMP085_Unified::Adafruit_BMP085_Unified(int32_t sensorID) {
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
PUBLIC FUNCTIONS
|
PUBLIC FUNCTIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Setups the HW
|
@brief Setups the HW
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
bool Adafruit_BMP085_Unified::begin(bmp085_mode_t mode)
|
bool Adafruit_BMP085_Unified::begin(bmp085_mode_t mode) {
|
||||||
{
|
|
||||||
// Enable I2C
|
// Enable I2C
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
/* Mode boundary check */
|
/* Mode boundary check */
|
||||||
if ((mode > BMP085_MODE_ULTRAHIGHRES) || (mode < 0))
|
if ((mode > BMP085_MODE_ULTRAHIGHRES) || (mode < 0)) {
|
||||||
{
|
|
||||||
mode = BMP085_MODE_ULTRAHIGHRES;
|
mode = BMP085_MODE_ULTRAHIGHRES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we have the right device */
|
/* Make sure we have the right device */
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
read8(BMP085_REGISTER_CHIPID, &id);
|
read8(BMP085_REGISTER_CHIPID, &id);
|
||||||
if(id != 0x55)
|
if (id != 0x55) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +274,7 @@ bool Adafruit_BMP085_Unified::begin(bmp085_mode_t mode)
|
|||||||
|
|
||||||
/* Coefficients need to be read once */
|
/* Coefficients need to be read once */
|
||||||
readCoefficients();
|
readCoefficients();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,10 +283,9 @@ bool Adafruit_BMP085_Unified::begin(bmp085_mode_t mode)
|
|||||||
@brief Gets the compensated pressure level in kPa
|
@brief Gets the compensated pressure level in kPa
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
void Adafruit_BMP085_Unified::getPressure(float *pressure)
|
void Adafruit_BMP085_Unified::getPressure(float *pressure) {
|
||||||
{
|
int32_t ut = 0, up = 0, compp = 0;
|
||||||
int32_t ut = 0, up = 0, compp = 0;
|
int32_t x1, x2, b5, b6, x3, b3, p;
|
||||||
int32_t x1, x2, b5, b6, x3, b3, p;
|
|
||||||
uint32_t b4, b7;
|
uint32_t b4, b7;
|
||||||
|
|
||||||
/* Get the raw pressure and temperature values */
|
/* Get the raw pressure and temperature values */
|
||||||
@ -297,19 +300,16 @@ void Adafruit_BMP085_Unified::getPressure(float *pressure)
|
|||||||
x1 = (_bmp085_coeffs.b2 * ((b6 * b6) >> 12)) >> 11;
|
x1 = (_bmp085_coeffs.b2 * ((b6 * b6) >> 12)) >> 11;
|
||||||
x2 = (_bmp085_coeffs.ac2 * b6) >> 11;
|
x2 = (_bmp085_coeffs.ac2 * b6) >> 11;
|
||||||
x3 = x1 + x2;
|
x3 = x1 + x2;
|
||||||
b3 = (((((int32_t) _bmp085_coeffs.ac1) * 4 + x3) << _bmp085Mode) + 2) >> 2;
|
b3 = (((((int32_t)_bmp085_coeffs.ac1) * 4 + x3) << _bmp085Mode) + 2) >> 2;
|
||||||
x1 = (_bmp085_coeffs.ac3 * b6) >> 13;
|
x1 = (_bmp085_coeffs.ac3 * b6) >> 13;
|
||||||
x2 = (_bmp085_coeffs.b1 * ((b6 * b6) >> 12)) >> 16;
|
x2 = (_bmp085_coeffs.b1 * ((b6 * b6) >> 12)) >> 16;
|
||||||
x3 = ((x1 + x2) + 2) >> 2;
|
x3 = ((x1 + x2) + 2) >> 2;
|
||||||
b4 = (_bmp085_coeffs.ac4 * (uint32_t) (x3 + 32768)) >> 15;
|
b4 = (_bmp085_coeffs.ac4 * (uint32_t)(x3 + 32768)) >> 15;
|
||||||
b7 = ((uint32_t) (up - b3) * (50000 >> _bmp085Mode));
|
b7 = ((uint32_t)(up - b3) * (50000 >> _bmp085Mode));
|
||||||
|
|
||||||
if (b7 < 0x80000000)
|
if (b7 < 0x80000000) {
|
||||||
{
|
|
||||||
p = (b7 << 1) / b4;
|
p = (b7 << 1) / b4;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
p = (b7 / b4) << 1;
|
p = (b7 / b4) << 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,24 +327,23 @@ void Adafruit_BMP085_Unified::getPressure(float *pressure)
|
|||||||
@brief Reads the temperatures in degrees Celsius
|
@brief Reads the temperatures in degrees Celsius
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
void Adafruit_BMP085_Unified::getTemperature(float *temp)
|
void Adafruit_BMP085_Unified::getTemperature(float *temp) {
|
||||||
{
|
int32_t UT, B5; // following ds convention
|
||||||
int32_t UT, B5; // following ds convention
|
|
||||||
float t;
|
float t;
|
||||||
|
|
||||||
readRawTemperature(&UT);
|
readRawTemperature(&UT);
|
||||||
|
|
||||||
#if BMP085_USE_DATASHEET_VALS
|
#if BMP085_USE_DATASHEET_VALS
|
||||||
// use datasheet numbers!
|
// use datasheet numbers!
|
||||||
UT = 27898;
|
UT = 27898;
|
||||||
_bmp085_coeffs.ac6 = 23153;
|
_bmp085_coeffs.ac6 = 23153;
|
||||||
_bmp085_coeffs.ac5 = 32757;
|
_bmp085_coeffs.ac5 = 32757;
|
||||||
_bmp085_coeffs.mc = -8711;
|
_bmp085_coeffs.mc = -8711;
|
||||||
_bmp085_coeffs.md = 2868;
|
_bmp085_coeffs.md = 2868;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
B5 = computeB5(UT);
|
B5 = computeB5(UT);
|
||||||
t = (B5+8) >> 4;
|
t = (B5 + 8) >> 4;
|
||||||
t /= 10;
|
t /= 10;
|
||||||
|
|
||||||
*temp = t;
|
*temp = t;
|
||||||
@ -359,15 +358,15 @@ void Adafruit_BMP085_Unified::getTemperature(float *temp)
|
|||||||
@param atmospheric Atmospheric pressure in hPa
|
@param atmospheric Atmospheric pressure in hPa
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
float Adafruit_BMP085_Unified::pressureToAltitude(float seaLevel, float atmospheric)
|
float Adafruit_BMP085_Unified::pressureToAltitude(float seaLevel,
|
||||||
{
|
float atmospheric) {
|
||||||
// Equation taken from BMP180 datasheet (page 16):
|
// Equation taken from BMP180 datasheet (page 16):
|
||||||
// http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
|
// http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
|
||||||
|
|
||||||
// Note that using the equation from wikipedia can give bad results
|
// Note that using the equation from wikipedia can give bad results
|
||||||
// at high altitude. See this thread for more information:
|
// at high altitude. See this thread for more information:
|
||||||
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
|
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
|
||||||
|
|
||||||
return 44330.0 * (1.0 - pow(atmospheric / seaLevel, 0.1903));
|
return 44330.0 * (1.0 - pow(atmospheric / seaLevel, 0.1903));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,35 +386,36 @@ float Adafruit_BMP085_Unified::pressureToAltitude(float seaLevel, float atmosphe
|
|||||||
@param temp Temperature in degrees Celsius
|
@param temp Temperature in degrees Celsius
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
float Adafruit_BMP085_Unified::pressureToAltitude(float seaLevel, float atmospheric, float temp)
|
float Adafruit_BMP085_Unified::pressureToAltitude(float seaLevel,
|
||||||
{
|
float atmospheric,
|
||||||
|
float temp) {
|
||||||
return pressureToAltitude(seaLevel, atmospheric);
|
return pressureToAltitude(seaLevel, atmospheric);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
Calculates the pressure at sea level (in hPa) from the specified altitude
|
Calculates the pressure at sea level (in hPa) from the specified altitude
|
||||||
(in meters), and atmospheric pressure (in hPa).
|
(in meters), and atmospheric pressure (in hPa).
|
||||||
|
|
||||||
@param altitude Altitude in meters
|
@param altitude Altitude in meters
|
||||||
@param atmospheric Atmospheric pressure in hPa
|
@param atmospheric Atmospheric pressure in hPa
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
float Adafruit_BMP085_Unified::seaLevelForAltitude(float altitude, float atmospheric)
|
float Adafruit_BMP085_Unified::seaLevelForAltitude(float altitude,
|
||||||
{
|
float atmospheric) {
|
||||||
// Equation taken from BMP180 datasheet (page 17):
|
// Equation taken from BMP180 datasheet (page 17):
|
||||||
// http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
|
// http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
|
||||||
|
|
||||||
// Note that using the equation from wikipedia can give bad results
|
// Note that using the equation from wikipedia can give bad results
|
||||||
// at high altitude. See this thread for more information:
|
// at high altitude. See this thread for more information:
|
||||||
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
|
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
|
||||||
|
|
||||||
return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
|
return atmospheric / pow(1.0 - (altitude / 44330.0), 5.255);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
Calculates the pressure at sea level (in hPa) from the specified altitude
|
Calculates the pressure at sea level (in hPa) from the specified altitude
|
||||||
(in meters), and atmospheric pressure (in hPa). Note that this
|
(in meters), and atmospheric pressure (in hPa). Note that this
|
||||||
function just calls the overload of seaLevelForAltitude which takes
|
function just calls the overload of seaLevelForAltitude which takes
|
||||||
altitude and atmospheric pressure--temperature is ignored. The original
|
altitude and atmospheric pressure--temperature is ignored. The original
|
||||||
@ -429,33 +429,31 @@ float Adafruit_BMP085_Unified::seaLevelForAltitude(float altitude, float atmosph
|
|||||||
@param temp Temperature in degrees Celsius
|
@param temp Temperature in degrees Celsius
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
float Adafruit_BMP085_Unified::seaLevelForAltitude(float altitude, float atmospheric, float temp)
|
float Adafruit_BMP085_Unified::seaLevelForAltitude(float altitude,
|
||||||
{
|
float atmospheric,
|
||||||
|
float temp) {
|
||||||
return seaLevelForAltitude(altitude, atmospheric);
|
return seaLevelForAltitude(altitude, atmospheric);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Provides the sensor_t data for this sensor
|
@brief Provides the sensor_t data for this sensor
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
void Adafruit_BMP085_Unified::getSensor(sensor_t *sensor)
|
void Adafruit_BMP085_Unified::getSensor(sensor_t *sensor) {
|
||||||
{
|
|
||||||
/* Clear the sensor_t object */
|
/* Clear the sensor_t object */
|
||||||
memset(sensor, 0, sizeof(sensor_t));
|
memset(sensor, 0, sizeof(sensor_t));
|
||||||
|
|
||||||
/* Insert the sensor name in the fixed length char array */
|
/* Insert the sensor name in the fixed length char array */
|
||||||
strncpy (sensor->name, "BMP085", sizeof(sensor->name) - 1);
|
strncpy(sensor->name, "BMP085", sizeof(sensor->name) - 1);
|
||||||
sensor->name[sizeof(sensor->name)- 1] = 0;
|
sensor->name[sizeof(sensor->name) - 1] = 0;
|
||||||
sensor->version = 1;
|
sensor->version = 1;
|
||||||
sensor->sensor_id = _sensorID;
|
sensor->sensor_id = _sensorID;
|
||||||
sensor->type = SENSOR_TYPE_PRESSURE;
|
sensor->type = SENSOR_TYPE_PRESSURE;
|
||||||
sensor->min_delay = 0;
|
sensor->min_delay = 0;
|
||||||
sensor->max_value = 1100.0F; // 300..1100 hPa
|
sensor->max_value = 1100.0F; // 300..1100 hPa
|
||||||
sensor->min_value = 300.0F;
|
sensor->min_value = 300.0F;
|
||||||
sensor->resolution = 0.01F; // Datasheet states 0.01 hPa resolution
|
sensor->resolution = 0.01F; // Datasheet states 0.01 hPa resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
@ -463,19 +461,18 @@ void Adafruit_BMP085_Unified::getSensor(sensor_t *sensor)
|
|||||||
@brief Reads the sensor and returns the data as a sensors_event_t
|
@brief Reads the sensor and returns the data as a sensors_event_t
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
bool Adafruit_BMP085_Unified::getEvent(sensors_event_t *event)
|
bool Adafruit_BMP085_Unified::getEvent(sensors_event_t *event) {
|
||||||
{
|
|
||||||
float pressure_kPa;
|
float pressure_kPa;
|
||||||
|
|
||||||
/* Clear the event */
|
/* Clear the event */
|
||||||
memset(event, 0, sizeof(sensors_event_t));
|
memset(event, 0, sizeof(sensors_event_t));
|
||||||
|
|
||||||
event->version = sizeof(sensors_event_t);
|
event->version = sizeof(sensors_event_t);
|
||||||
event->sensor_id = _sensorID;
|
event->sensor_id = _sensorID;
|
||||||
event->type = SENSOR_TYPE_PRESSURE;
|
event->type = SENSOR_TYPE_PRESSURE;
|
||||||
event->timestamp = 0;
|
event->timestamp = 0;
|
||||||
getPressure(&pressure_kPa);
|
getPressure(&pressure_kPa);
|
||||||
event->pressure = pressure_kPa / 100.0F;
|
event->pressure = pressure_kPa / 100.0F;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,122 +1,154 @@
|
|||||||
/***************************************************************************
|
/*!
|
||||||
This is a library for the BMP085 pressure sensor
|
* @file Adafruit_BMP085_U.h
|
||||||
|
*/
|
||||||
|
|
||||||
Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout
|
|
||||||
----> http://www.adafruit.com/products/391
|
|
||||||
----> http://www.adafruit.com/products/1603
|
|
||||||
|
|
||||||
These displays use I2C to communicate, 2 pins are required to interface.
|
|
||||||
|
|
||||||
Adafruit invests time and resources providing this open source code,
|
|
||||||
please support Adafruit andopen-source hardware by purchasing products
|
|
||||||
from Adafruit!
|
|
||||||
|
|
||||||
Written by Kevin Townsend for Adafruit Industries.
|
|
||||||
BSD license, all text above must be included in any redistribution
|
|
||||||
***************************************************************************/
|
|
||||||
#ifndef __BMP085_H__
|
#ifndef __BMP085_H__
|
||||||
#define __BMP085_H__
|
#define __BMP085_H__
|
||||||
|
|
||||||
#if (ARDUINO >= 100)
|
#if (ARDUINO >= 100)
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#else
|
#else
|
||||||
#include "WProgram.h"
|
#include "WProgram.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Adafruit_Sensor.h>
|
#include <Adafruit_Sensor.h>
|
||||||
|
|
||||||
#ifdef __AVR_ATtiny85__
|
#ifdef __AVR_ATtiny85__
|
||||||
#include "TinyWireM.h"
|
#include "TinyWireM.h"
|
||||||
#define Wire TinyWireM
|
#define Wire TinyWireM
|
||||||
#else
|
#else
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*=========================================================================
|
/*!
|
||||||
I2C ADDRESS/BITS
|
* @brief BMP085 I2C address/bits
|
||||||
-----------------------------------------------------------------------*/
|
*/
|
||||||
#define BMP085_ADDRESS (0x77)
|
#define BMP085_ADDRESS (0x77)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief BMP085 I2C registers
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
BMP085_REGISTER_CAL_AC1 = 0xAA, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_AC2 = 0xAC, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_AC3 = 0xAE, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_AC4 = 0xB0, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_AC5 = 0xB2, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_AC6 = 0xB4, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_B1 = 0xB6, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_B2 = 0xB8, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_MB = 0xBA, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_MC = 0xBC, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CAL_MD = 0xBE, //!< R Calibration data (16 bits)
|
||||||
|
BMP085_REGISTER_CHIPID = 0xD0, //!< Register that contains the chip ID
|
||||||
|
BMP085_REGISTER_VERSION = 0xD1, //!< Register that contains the chip version
|
||||||
|
BMP085_REGISTER_SOFTRESET = 0xE0, //!< Register for doing a soft reset
|
||||||
|
BMP085_REGISTER_CONTROL = 0xF4, //!< Control register
|
||||||
|
BMP085_REGISTER_TEMPDATA = 0xF6, //!< Temperature data register
|
||||||
|
BMP085_REGISTER_PRESSUREDATA = 0xF6, //!< Pressure data register
|
||||||
|
BMP085_REGISTER_READTEMPCMD =
|
||||||
|
0x2E, //!< Read temperature control register value
|
||||||
|
BMP085_REGISTER_READPRESSURECMD =
|
||||||
|
0x34 //!< Read pressure control register value
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief BMP085 mode settings
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
BMP085_MODE_ULTRALOWPOWER = 0,
|
||||||
|
BMP085_MODE_STANDARD = 1,
|
||||||
|
BMP085_MODE_HIGHRES = 2,
|
||||||
|
BMP085_MODE_ULTRAHIGHRES = 3
|
||||||
|
} bmp085_mode_t;
|
||||||
/*=========================================================================*/
|
/*=========================================================================*/
|
||||||
|
|
||||||
/*=========================================================================
|
/*!
|
||||||
REGISTERS
|
* @brief Calibration data
|
||||||
-----------------------------------------------------------------------*/
|
*/
|
||||||
enum
|
typedef struct {
|
||||||
{
|
int16_t ac1; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_AC1 = 0xAA, // R Calibration data (16 bits)
|
int16_t ac2; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_AC2 = 0xAC, // R Calibration data (16 bits)
|
int16_t ac3; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_AC3 = 0xAE, // R Calibration data (16 bits)
|
uint16_t ac4; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_AC4 = 0xB0, // R Calibration data (16 bits)
|
uint16_t ac5; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_AC5 = 0xB2, // R Calibration data (16 bits)
|
uint16_t ac6; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_AC6 = 0xB4, // R Calibration data (16 bits)
|
int16_t b1; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_B1 = 0xB6, // R Calibration data (16 bits)
|
int16_t b2; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_B2 = 0xB8, // R Calibration data (16 bits)
|
int16_t mb; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_MB = 0xBA, // R Calibration data (16 bits)
|
int16_t mc; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_MC = 0xBC, // R Calibration data (16 bits)
|
int16_t md; //!< R calibration coefficient (16-bits)
|
||||||
BMP085_REGISTER_CAL_MD = 0xBE, // R Calibration data (16 bits)
|
} bmp085_calib_data;
|
||||||
BMP085_REGISTER_CHIPID = 0xD0,
|
|
||||||
BMP085_REGISTER_VERSION = 0xD1,
|
|
||||||
BMP085_REGISTER_SOFTRESET = 0xE0,
|
|
||||||
BMP085_REGISTER_CONTROL = 0xF4,
|
|
||||||
BMP085_REGISTER_TEMPDATA = 0xF6,
|
|
||||||
BMP085_REGISTER_PRESSUREDATA = 0xF6,
|
|
||||||
BMP085_REGISTER_READTEMPCMD = 0x2E,
|
|
||||||
BMP085_REGISTER_READPRESSURECMD = 0x34
|
|
||||||
};
|
|
||||||
/*=========================================================================*/
|
|
||||||
|
|
||||||
/*=========================================================================
|
/*!
|
||||||
MODE SETTINGS
|
* @brief Class that stores state and functions for interacting with BMP183
|
||||||
-----------------------------------------------------------------------*/
|
*/
|
||||||
typedef enum
|
class Adafruit_BMP085_Unified : public Adafruit_Sensor {
|
||||||
{
|
public:
|
||||||
BMP085_MODE_ULTRALOWPOWER = 0,
|
Adafruit_BMP085_Unified(
|
||||||
BMP085_MODE_STANDARD = 1,
|
int32_t sensorID = -1); //!< @param sensorID ID of the BMP085 sensor
|
||||||
BMP085_MODE_HIGHRES = 2,
|
|
||||||
BMP085_MODE_ULTRAHIGHRES = 3
|
|
||||||
} bmp085_mode_t;
|
|
||||||
/*=========================================================================*/
|
|
||||||
|
|
||||||
/*=========================================================================
|
/*!
|
||||||
CALIBRATION DATA
|
* @brief Starts I2C connection
|
||||||
-----------------------------------------------------------------------*/
|
* @param mode Mode to set, ultra high-res by default
|
||||||
typedef struct
|
* @return Returns true if successful
|
||||||
{
|
*/
|
||||||
int16_t ac1;
|
bool begin(bmp085_mode_t mode = BMP085_MODE_ULTRAHIGHRES);
|
||||||
int16_t ac2;
|
/*!
|
||||||
int16_t ac3;
|
* @brief Gets the temperature over I2C from the BMP085
|
||||||
uint16_t ac4;
|
* @param temp Temperature
|
||||||
uint16_t ac5;
|
* @return Returns the temperature
|
||||||
uint16_t ac6;
|
*/
|
||||||
int16_t b1;
|
void getTemperature(float *temp);
|
||||||
int16_t b2;
|
/*!
|
||||||
int16_t mb;
|
* @brief Gets the pressure over I2C from the BMP085
|
||||||
int16_t mc;
|
* @param pressure Pressure
|
||||||
int16_t md;
|
* @return Returns the pressure
|
||||||
} bmp085_calib_data;
|
*/
|
||||||
/*=========================================================================*/
|
void getPressure(float *pressure);
|
||||||
|
/*!
|
||||||
|
* @brief Calculates absolute pressure
|
||||||
|
* @param seaLevel Pressure at sea level
|
||||||
|
* @param atmospheric measured pressure
|
||||||
|
* @return Absolute altitude
|
||||||
|
*/
|
||||||
|
float pressureToAltitude(float seaLevel, float atmospheric);
|
||||||
|
/*!
|
||||||
|
* @brief Calculates pressure at sea level
|
||||||
|
* @param altitude Altitude
|
||||||
|
* @param atmospheric measured pressure
|
||||||
|
* @return Pressure at sea level
|
||||||
|
*/
|
||||||
|
float seaLevelForAltitude(float altitude, float atmospheric);
|
||||||
|
// Note that the next two functions are just for compatibility with old
|
||||||
|
// code that passed the temperature as a third parameter. A newer
|
||||||
|
// calculation is used which does not need temperature.
|
||||||
|
/*!
|
||||||
|
* @brief Calculates absolute pressure
|
||||||
|
* @param seaLevel Pressure at sea level
|
||||||
|
* @param atmospheric Measured pressure
|
||||||
|
* @param temp Temperature
|
||||||
|
* @return Absolute altitude
|
||||||
|
*/
|
||||||
|
float pressureToAltitude(float seaLevel, float atmospheric, float temp);
|
||||||
|
/*!
|
||||||
|
* @brief Calculates pressure at sea level
|
||||||
|
* @param altitude Altitude
|
||||||
|
* @param atmospheric measured pressure
|
||||||
|
* @param temp Temperature
|
||||||
|
* @return Pressure at sea level
|
||||||
|
*/
|
||||||
|
float seaLevelForAltitude(float altitude, float atmospheric, float temp);
|
||||||
|
/*!
|
||||||
|
* @brief Used to read the sensor
|
||||||
|
* @return Returns an event
|
||||||
|
*/
|
||||||
|
bool getEvent(sensors_event_t *);
|
||||||
|
void getSensor(sensor_t *);
|
||||||
|
|
||||||
class Adafruit_BMP085_Unified : public Adafruit_Sensor
|
private:
|
||||||
{
|
int32_t computeB5(int32_t ut);
|
||||||
public:
|
int32_t _sensorID;
|
||||||
Adafruit_BMP085_Unified(int32_t sensorID = -1);
|
|
||||||
|
|
||||||
bool begin(bmp085_mode_t mode = BMP085_MODE_ULTRAHIGHRES);
|
|
||||||
void getTemperature(float *temp);
|
|
||||||
void getPressure(float *pressure);
|
|
||||||
float pressureToAltitude(float seaLevel, float atmospheric);
|
|
||||||
float seaLevelForAltitude(float altitude, float atmospheric);
|
|
||||||
// Note that the next two functions are just for compatibility with old
|
|
||||||
// code that passed the temperature as a third parameter. A newer
|
|
||||||
// calculation is used which does not need temperature.
|
|
||||||
float pressureToAltitude(float seaLevel, float atmospheric, float temp);
|
|
||||||
float seaLevelForAltitude(float altitude, float atmospheric, float temp);
|
|
||||||
bool getEvent(sensors_event_t*);
|
|
||||||
void getSensor(sensor_t*);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int32_t computeB5(int32_t ut);
|
|
||||||
int32_t _sensorID;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Adafruit Unified BMP085/BMP180 Driver (Barometric Pressure Sensor) #
|
# Adafruit Unified BMP085/BMP180 Driver (Barometric Pressure Sensor) [](https://github.com/adafruit/Adafruit_BMP085_Unified/actions)[](http://adafruit.github.io/Adafruit_BMP085_Unified/html/index.html)
|
||||||
|
|
||||||
This driver is for the Adafruit BMP085 Breakout (http://www.adafruit.com/products/391) or BMP180 breakout (http://www.adafruit.com/products/1603), and is based on Adafruit's Unified Sensor Library (Adafruit_Sensor).
|
This driver is for the Adafruit BMP085 Breakout (http://www.adafruit.com/products/391) or BMP180 breakout (http://www.adafruit.com/products/1603), and is based on Adafruit's Unified Sensor Library (Adafruit_Sensor).
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=Adafruit BMP085 Unified
|
name=Adafruit BMP085 Unified
|
||||||
version=1.0.1
|
version=1.1.0
|
||||||
author=Adafruit
|
author=Adafruit
|
||||||
maintainer=Adafruit <info@adafruit.com>
|
maintainer=Adafruit <info@adafruit.com>
|
||||||
sentence=Unified sensor driver for Adafruit's BMP085 & BMP180 breakouts
|
sentence=Unified sensor driver for Adafruit's BMP085 & BMP180 breakouts
|
||||||
|
Reference in New Issue
Block a user