bugfix use bmp280 and not bme280
This commit is contained in:
parent
85f3814f67
commit
6677fac2ab
17 changed files with 1115 additions and 1861 deletions
46
examples/osd/arduino-bmp280/Adafruit_BMP280_Library-master/.github/ISSUE_TEMPLATE.md
vendored
Normal file
46
examples/osd/arduino-bmp280/Adafruit_BMP280_Library-master/.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
26
examples/osd/arduino-bmp280/Adafruit_BMP280_Library-master/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
26
examples/osd/arduino-bmp280/Adafruit_BMP280_Library-master/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
|
@ -0,0 +1,325 @@
|
|||
/***************************************************************************
|
||||
This is a library for the BMP280 pressure sensor
|
||||
|
||||
Designed specifically to work with the Adafruit BMP280 Breakout
|
||||
----> http://www.adafruit.com/products/2651
|
||||
|
||||
These sensors 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
|
||||
***************************************************************************/
|
||||
#include "Arduino.h"
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "Adafruit_BMP280.h"
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
PRIVATE FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
Adafruit_BMP280::Adafruit_BMP280()
|
||||
: _cs(-1), _mosi(-1), _miso(-1), _sck(-1)
|
||||
{ }
|
||||
|
||||
Adafruit_BMP280::Adafruit_BMP280(int8_t cspin)
|
||||
: _cs(cspin), _mosi(-1), _miso(-1), _sck(-1)
|
||||
{ }
|
||||
|
||||
Adafruit_BMP280::Adafruit_BMP280(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin)
|
||||
: _cs(cspin), _mosi(mosipin), _miso(misopin), _sck(sckpin)
|
||||
{ }
|
||||
|
||||
|
||||
bool Adafruit_BMP280::begin(uint8_t a, uint8_t chipid) {
|
||||
_i2caddr = a;
|
||||
|
||||
if (_cs == -1) {
|
||||
// i2c
|
||||
Wire.begin();
|
||||
} else {
|
||||
digitalWrite(_cs, HIGH);
|
||||
pinMode(_cs, OUTPUT);
|
||||
|
||||
if (_sck == -1) {
|
||||
// hardware SPI
|
||||
SPI.begin();
|
||||
} else {
|
||||
// software SPI
|
||||
pinMode(_sck, OUTPUT);
|
||||
pinMode(_mosi, OUTPUT);
|
||||
pinMode(_miso, INPUT);
|
||||
}
|
||||
}
|
||||
|
||||
if (read8(BMP280_REGISTER_CHIPID) != chipid)
|
||||
return false;
|
||||
|
||||
readCoefficients();
|
||||
write8(BMP280_REGISTER_CONTROL, 0x3F);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t Adafruit_BMP280::spixfer(uint8_t x) {
|
||||
if (_sck == -1)
|
||||
return SPI.transfer(x);
|
||||
|
||||
// software spi
|
||||
//Serial.println("Software SPI");
|
||||
uint8_t reply = 0;
|
||||
for (int i=7; i>=0; i--) {
|
||||
reply <<= 1;
|
||||
digitalWrite(_sck, LOW);
|
||||
digitalWrite(_mosi, x & (1<<i));
|
||||
digitalWrite(_sck, HIGH);
|
||||
if (digitalRead(_miso))
|
||||
reply |= 1;
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Writes an 8 bit value over I2C/SPI
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_BMP280::write8(byte reg, byte value)
|
||||
{
|
||||
if (_cs == -1) {
|
||||
Wire.beginTransmission((uint8_t)_i2caddr);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.write((uint8_t)value);
|
||||
Wire.endTransmission();
|
||||
} else {
|
||||
if (_sck == -1)
|
||||
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
|
||||
digitalWrite(_cs, LOW);
|
||||
spixfer(reg & ~0x80); // write, bit 7 low
|
||||
spixfer(value);
|
||||
digitalWrite(_cs, HIGH);
|
||||
if (_sck == -1)
|
||||
SPI.endTransaction(); // release the SPI bus
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Reads an 8 bit value over I2C/SPI
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_BMP280::read8(byte reg)
|
||||
{
|
||||
uint8_t value;
|
||||
|
||||
if (_cs == -1) {
|
||||
Wire.beginTransmission((uint8_t)_i2caddr);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom((uint8_t)_i2caddr, (byte)1);
|
||||
value = Wire.read();
|
||||
|
||||
} else {
|
||||
if (_sck == -1)
|
||||
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
|
||||
digitalWrite(_cs, LOW);
|
||||
spixfer(reg | 0x80); // read, bit 7 high
|
||||
value = spixfer(0);
|
||||
digitalWrite(_cs, HIGH);
|
||||
if (_sck == -1)
|
||||
SPI.endTransaction(); // release the SPI bus
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Reads a 16 bit value over I2C/SPI
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint16_t Adafruit_BMP280::read16(byte reg)
|
||||
{
|
||||
uint16_t value;
|
||||
|
||||
if (_cs == -1) {
|
||||
Wire.beginTransmission((uint8_t)_i2caddr);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom((uint8_t)_i2caddr, (byte)2);
|
||||
value = (Wire.read() << 8) | Wire.read();
|
||||
|
||||
} else {
|
||||
if (_sck == -1)
|
||||
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
|
||||
digitalWrite(_cs, LOW);
|
||||
spixfer(reg | 0x80); // read, bit 7 high
|
||||
value = (spixfer(0) << 8) | spixfer(0);
|
||||
digitalWrite(_cs, HIGH);
|
||||
if (_sck == -1)
|
||||
SPI.endTransaction(); // release the SPI bus
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
uint16_t Adafruit_BMP280::read16_LE(byte reg) {
|
||||
uint16_t temp = read16(reg);
|
||||
return (temp >> 8) | (temp << 8);
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Reads a signed 16 bit value over I2C/SPI
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int16_t Adafruit_BMP280::readS16(byte reg)
|
||||
{
|
||||
return (int16_t)read16(reg);
|
||||
|
||||
}
|
||||
|
||||
int16_t Adafruit_BMP280::readS16_LE(byte reg)
|
||||
{
|
||||
return (int16_t)read16_LE(reg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Reads a 24 bit value over I2C/SPI
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint32_t Adafruit_BMP280::read24(byte reg)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
if (_cs == -1) {
|
||||
Wire.beginTransmission((uint8_t)_i2caddr);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom((uint8_t)_i2caddr, (byte)3);
|
||||
|
||||
value = Wire.read();
|
||||
value <<= 8;
|
||||
value |= Wire.read();
|
||||
value <<= 8;
|
||||
value |= Wire.read();
|
||||
|
||||
} else {
|
||||
if (_sck == -1)
|
||||
SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0));
|
||||
digitalWrite(_cs, LOW);
|
||||
spixfer(reg | 0x80); // read, bit 7 high
|
||||
|
||||
value = spixfer(0);
|
||||
value <<= 8;
|
||||
value |= spixfer(0);
|
||||
value <<= 8;
|
||||
value |= spixfer(0);
|
||||
|
||||
digitalWrite(_cs, HIGH);
|
||||
if (_sck == -1)
|
||||
SPI.endTransaction(); // release the SPI bus
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Reads the factory-set coefficients
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_BMP280::readCoefficients(void)
|
||||
{
|
||||
_bmp280_calib.dig_T1 = read16_LE(BMP280_REGISTER_DIG_T1);
|
||||
_bmp280_calib.dig_T2 = readS16_LE(BMP280_REGISTER_DIG_T2);
|
||||
_bmp280_calib.dig_T3 = readS16_LE(BMP280_REGISTER_DIG_T3);
|
||||
|
||||
_bmp280_calib.dig_P1 = read16_LE(BMP280_REGISTER_DIG_P1);
|
||||
_bmp280_calib.dig_P2 = readS16_LE(BMP280_REGISTER_DIG_P2);
|
||||
_bmp280_calib.dig_P3 = readS16_LE(BMP280_REGISTER_DIG_P3);
|
||||
_bmp280_calib.dig_P4 = readS16_LE(BMP280_REGISTER_DIG_P4);
|
||||
_bmp280_calib.dig_P5 = readS16_LE(BMP280_REGISTER_DIG_P5);
|
||||
_bmp280_calib.dig_P6 = readS16_LE(BMP280_REGISTER_DIG_P6);
|
||||
_bmp280_calib.dig_P7 = readS16_LE(BMP280_REGISTER_DIG_P7);
|
||||
_bmp280_calib.dig_P8 = readS16_LE(BMP280_REGISTER_DIG_P8);
|
||||
_bmp280_calib.dig_P9 = readS16_LE(BMP280_REGISTER_DIG_P9);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
||||
*/
|
||||
/**************************************************************************/
|
||||
float Adafruit_BMP280::readTemperature(void)
|
||||
{
|
||||
int32_t var1, var2;
|
||||
|
||||
int32_t adc_T = read24(BMP280_REGISTER_TEMPDATA);
|
||||
adc_T >>= 4;
|
||||
|
||||
var1 = ((((adc_T>>3) - ((int32_t)_bmp280_calib.dig_T1 <<1))) *
|
||||
((int32_t)_bmp280_calib.dig_T2)) >> 11;
|
||||
|
||||
var2 = (((((adc_T>>4) - ((int32_t)_bmp280_calib.dig_T1)) *
|
||||
((adc_T>>4) - ((int32_t)_bmp280_calib.dig_T1))) >> 12) *
|
||||
((int32_t)_bmp280_calib.dig_T3)) >> 14;
|
||||
|
||||
t_fine = var1 + var2;
|
||||
|
||||
float T = (t_fine * 5 + 128) >> 8;
|
||||
return T/100;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
||||
*/
|
||||
/**************************************************************************/
|
||||
float Adafruit_BMP280::readPressure(void) {
|
||||
int64_t var1, var2, p;
|
||||
|
||||
// Must be done first to get the t_fine variable set up
|
||||
readTemperature();
|
||||
|
||||
int32_t adc_P = read24(BMP280_REGISTER_PRESSUREDATA);
|
||||
adc_P >>= 4;
|
||||
|
||||
var1 = ((int64_t)t_fine) - 128000;
|
||||
var2 = var1 * var1 * (int64_t)_bmp280_calib.dig_P6;
|
||||
var2 = var2 + ((var1*(int64_t)_bmp280_calib.dig_P5)<<17);
|
||||
var2 = var2 + (((int64_t)_bmp280_calib.dig_P4)<<35);
|
||||
var1 = ((var1 * var1 * (int64_t)_bmp280_calib.dig_P3)>>8) +
|
||||
((var1 * (int64_t)_bmp280_calib.dig_P2)<<12);
|
||||
var1 = (((((int64_t)1)<<47)+var1))*((int64_t)_bmp280_calib.dig_P1)>>33;
|
||||
|
||||
if (var1 == 0) {
|
||||
return 0; // avoid exception caused by division by zero
|
||||
}
|
||||
p = 1048576 - adc_P;
|
||||
p = (((p<<31) - var2)*3125) / var1;
|
||||
var1 = (((int64_t)_bmp280_calib.dig_P9) * (p>>13) * (p>>13)) >> 25;
|
||||
var2 = (((int64_t)_bmp280_calib.dig_P8) * p) >> 19;
|
||||
|
||||
p = ((p + var1 + var2) >> 8) + (((int64_t)_bmp280_calib.dig_P7)<<4);
|
||||
return (float)p/256;
|
||||
}
|
||||
|
||||
float Adafruit_BMP280::readAltitude(float seaLevelhPa) {
|
||||
float altitude;
|
||||
|
||||
float pressure = readPressure(); // in Si units for Pascal
|
||||
pressure /= 100;
|
||||
|
||||
altitude = 44330 * (1.0 - pow(pressure / seaLevelhPa, 0.1903));
|
||||
|
||||
return altitude;
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
/***************************************************************************
|
||||
This is a library for the BMP280 pressure sensor
|
||||
|
||||
Designed specifically to work with the Adafruit BMP280 Breakout
|
||||
----> http://www.adafruit.com/products/2651
|
||||
|
||||
These sensors 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 __BMP280_H__
|
||||
#define __BMP280_H__
|
||||
|
||||
#if (ARDUINO >= 100)
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#include <Adafruit_Sensor.h>
|
||||
|
||||
#ifdef __AVR_ATtiny85__
|
||||
#include "TinyWireM.h"
|
||||
#define Wire TinyWireM
|
||||
#else
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
/*=========================================================================
|
||||
I2C ADDRESS/BITS/SETTINGS
|
||||
-----------------------------------------------------------------------*/
|
||||
#define BMP280_ADDRESS (0x77)
|
||||
#define BMP280_CHIPID (0x58)
|
||||
/*=========================================================================*/
|
||||
|
||||
/*=========================================================================
|
||||
REGISTERS
|
||||
-----------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
BMP280_REGISTER_DIG_T1 = 0x88,
|
||||
BMP280_REGISTER_DIG_T2 = 0x8A,
|
||||
BMP280_REGISTER_DIG_T3 = 0x8C,
|
||||
|
||||
BMP280_REGISTER_DIG_P1 = 0x8E,
|
||||
BMP280_REGISTER_DIG_P2 = 0x90,
|
||||
BMP280_REGISTER_DIG_P3 = 0x92,
|
||||
BMP280_REGISTER_DIG_P4 = 0x94,
|
||||
BMP280_REGISTER_DIG_P5 = 0x96,
|
||||
BMP280_REGISTER_DIG_P6 = 0x98,
|
||||
BMP280_REGISTER_DIG_P7 = 0x9A,
|
||||
BMP280_REGISTER_DIG_P8 = 0x9C,
|
||||
BMP280_REGISTER_DIG_P9 = 0x9E,
|
||||
|
||||
BMP280_REGISTER_CHIPID = 0xD0,
|
||||
BMP280_REGISTER_VERSION = 0xD1,
|
||||
BMP280_REGISTER_SOFTRESET = 0xE0,
|
||||
|
||||
BMP280_REGISTER_CAL26 = 0xE1, // R calibration stored in 0xE1-0xF0
|
||||
|
||||
BMP280_REGISTER_CONTROL = 0xF4,
|
||||
BMP280_REGISTER_CONFIG = 0xF5,
|
||||
BMP280_REGISTER_PRESSUREDATA = 0xF7,
|
||||
BMP280_REGISTER_TEMPDATA = 0xFA,
|
||||
};
|
||||
|
||||
/*=========================================================================*/
|
||||
|
||||
/*=========================================================================
|
||||
CALIBRATION DATA
|
||||
-----------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t dig_T1;
|
||||
int16_t dig_T2;
|
||||
int16_t dig_T3;
|
||||
|
||||
uint16_t dig_P1;
|
||||
int16_t dig_P2;
|
||||
int16_t dig_P3;
|
||||
int16_t dig_P4;
|
||||
int16_t dig_P5;
|
||||
int16_t dig_P6;
|
||||
int16_t dig_P7;
|
||||
int16_t dig_P8;
|
||||
int16_t dig_P9;
|
||||
|
||||
uint8_t dig_H1;
|
||||
int16_t dig_H2;
|
||||
uint8_t dig_H3;
|
||||
int16_t dig_H4;
|
||||
int16_t dig_H5;
|
||||
int8_t dig_H6;
|
||||
} bmp280_calib_data;
|
||||
/*=========================================================================*/
|
||||
|
||||
/*
|
||||
class Adafruit_BMP280_Unified : public Adafruit_Sensor
|
||||
{
|
||||
public:
|
||||
Adafruit_BMP280_Unified(int32_t sensorID = -1);
|
||||
|
||||
bool begin(uint8_t addr = BMP280_ADDRESS, uint8_t chipid = BMP280_CHIPID);
|
||||
void getTemperature(float *temp);
|
||||
void getPressure(float *pressure);
|
||||
float pressureToAltitude(float seaLevel, float atmospheric, float temp);
|
||||
float seaLevelForAltitude(float altitude, float atmospheric, float temp);
|
||||
void getEvent(sensors_event_t*);
|
||||
void getSensor(sensor_t*);
|
||||
|
||||
private:
|
||||
uint8_t _i2c_addr;
|
||||
int32_t _sensorID;
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
class Adafruit_BMP280
|
||||
{
|
||||
public:
|
||||
Adafruit_BMP280();
|
||||
Adafruit_BMP280(int8_t cspin);
|
||||
Adafruit_BMP280(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin);
|
||||
|
||||
bool begin(uint8_t addr = BMP280_ADDRESS, uint8_t chipid = BMP280_CHIPID);
|
||||
float readTemperature(void);
|
||||
float readPressure(void);
|
||||
float readAltitude(float seaLevelhPa = 1013.25);
|
||||
|
||||
private:
|
||||
|
||||
void readCoefficients(void);
|
||||
uint8_t spixfer(uint8_t x);
|
||||
|
||||
void write8(byte reg, byte value);
|
||||
uint8_t read8(byte reg);
|
||||
uint16_t read16(byte reg);
|
||||
uint32_t read24(byte reg);
|
||||
int16_t readS16(byte reg);
|
||||
uint16_t read16_LE(byte reg); // little endian
|
||||
int16_t readS16_LE(byte reg); // little endian
|
||||
|
||||
uint8_t _i2caddr;
|
||||
int32_t _sensorID;
|
||||
int32_t t_fine;
|
||||
|
||||
int8_t _cs, _mosi, _miso, _sck;
|
||||
|
||||
bmp280_calib_data _bmp280_calib;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,45 @@
|
|||
#Adafruit BMP280 Driver (Barometric Pressure Sensor) #
|
||||
|
||||
This driver is for the Adafruit BMP280 Breakout (http://www.adafruit.com/products/2651)
|
||||
|
||||
## About the BMP280 ##
|
||||
|
||||
This precision sensor from Bosch is the best low-cost sensing solution for measuring barometric pressure and temperature. Because pressure changes with altitude you can also use it as an altimeter!
|
||||
|
||||
## About this Driver ##
|
||||
|
||||
Adafruit invests time and resources providing this open source code. Please support Adafruit and open-source hardware by purchasing products from Adafruit!
|
||||
|
||||
Written by Kevin (KTOWN) Townsend for Adafruit Industries.
|
||||
|
||||
<!-- START COMPATIBILITY TABLE -->
|
||||
|
||||
## Compatibility
|
||||
|
||||
MCU | Tested Works | Doesn't Work | Not Tested | Notes
|
||||
------------------ | :----------: | :----------: | :---------: | -----
|
||||
Atmega328 @ 16MHz | X | | |
|
||||
Atmega328 @ 12MHz | X | | |
|
||||
Atmega32u4 @ 16MHz | X | | | Use SDA/SCL on pins D2 & D3
|
||||
Atmega32u4 @ 8MHz | X | | | Use SDA/SCL on pins D2 & D3
|
||||
ESP8266 | X | | | SDA/SCL default to pins 4 & 5 but any two pins can be assigned as SDA/SCL using Wire.begin(SDA,SCL)
|
||||
Atmega2560 @ 16MHz | X | | | Use SDA/SCL on pins 20 & 21
|
||||
ATSAM3X8E | X | | | Use SDA/SCL on pins 20 & 21
|
||||
ATSAM21D | X | | |
|
||||
ATtiny85 @ 16MHz | | X | |
|
||||
ATtiny85 @ 8MHz | | X | |
|
||||
Intel Curie @ 32MHz | | | X |
|
||||
STM32F2 | | | X |
|
||||
|
||||
* ATmega328 @ 16MHz : Arduino UNO, Adafruit Pro Trinket 5V, Adafruit Metro 328, Adafruit Metro Mini
|
||||
* ATmega328 @ 12MHz : Adafruit Pro Trinket 3V
|
||||
* ATmega32u4 @ 16MHz : Arduino Leonardo, Arduino Micro, Arduino Yun, Teensy 2.0
|
||||
* ATmega32u4 @ 8MHz : Adafruit Flora, Bluefruit Micro
|
||||
* ESP8266 : Adafruit Huzzah
|
||||
* ATmega2560 @ 16MHz : Arduino Mega
|
||||
* ATSAM3X8E : Arduino Due
|
||||
* ATSAM21D : Arduino Zero, M0 Pro
|
||||
* ATtiny85 @ 16MHz : Adafruit Trinket 5V
|
||||
* ATtiny85 @ 8MHz : Adafruit Gemma, Arduino Gemma, Adafruit Trinket 3V
|
||||
|
||||
<!-- END COMPATIBILITY TABLE -->
|
|
@ -0,0 +1,57 @@
|
|||
/***************************************************************************
|
||||
This is a library for the BMP280 humidity, temperature & pressure sensor
|
||||
|
||||
Designed specifically to work with the Adafruit BMEP280 Breakout
|
||||
----> http://www.adafruit.com/products/2651
|
||||
|
||||
These sensors use I2C or SPI to communicate, 2 or 4 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 Limor Fried & Kevin Townsend for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
***************************************************************************/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BMP280.h>
|
||||
|
||||
#define BMP_SCK 13
|
||||
#define BMP_MISO 12
|
||||
#define BMP_MOSI 11
|
||||
#define BMP_CS 10
|
||||
|
||||
Adafruit_BMP280 bme; // I2C
|
||||
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
|
||||
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println(F("BMP280 test"));
|
||||
|
||||
if (!bme.begin()) {
|
||||
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print(F("Temperature = "));
|
||||
Serial.print(bme.readTemperature());
|
||||
Serial.println(" *C");
|
||||
|
||||
Serial.print(F("Pressure = "));
|
||||
Serial.print(bme.readPressure());
|
||||
Serial.println(" Pa");
|
||||
|
||||
Serial.print(F("Approx altitude = "));
|
||||
Serial.print(bme.readAltitude(1013.25)); // this should be adjusted to your local forcase
|
||||
Serial.println(" m");
|
||||
|
||||
Serial.println();
|
||||
delay(2000);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
name=Adafruit BMP280 Library
|
||||
version=1.0.2
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Arduino library for BMP280 sensors.
|
||||
paragraph=Arduino library for BMP280 pressure and altitude sensors.
|
||||
category=Sensors
|
||||
url=https://github.com/adafruit/Adafruit_BMP280_Library
|
||||
architectures=*
|
Loading…
Add table
Add a link
Reference in a new issue