BME280

所属分类:单片机开发
开发工具:C/C++
文件大小:38KB
下载次数:0
上传日期:2019-10-05 02:55:35
上 传 者maikroice1
说明:  BME280-Release_Version

文件列表:
BME280-Release_Version_2.1.2 (0, 2017-02-08)
BME280-Release_Version_2.1.2\LICENSE (35142, 2017-02-08)
BME280-Release_Version_2.1.2\examples (0, 2017-02-08)
BME280-Release_Version_2.1.2\examples\BME280_Modes (0, 2017-02-08)
BME280-Release_Version_2.1.2\examples\BME280_Modes\BME280_Modes.ino (4941, 2017-02-08)
BME280-Release_Version_2.1.2\examples\BME_280_I2C_Test (0, 2017-02-08)
BME280-Release_Version_2.1.2\examples\BME_280_I2C_Test\BME_280_I2C_Test.ino (3773, 2017-02-08)
BME280-Release_Version_2.1.2\examples\BME_280_Spi_Sw_Test (0, 2017-02-08)
BME280-Release_Version_2.1.2\examples\BME_280_Spi_Sw_Test\BME_280_Spi_Sw_Test.ino (3673, 2017-02-08)
BME280-Release_Version_2.1.2\examples\BME_280_Spi_Test (0, 2017-02-08)
BME280-Release_Version_2.1.2\examples\BME_280_Spi_Test\BME_280_Spi_Test.ino (3826, 2017-02-08)
BME280-Release_Version_2.1.2\keywords.txt (136, 2017-02-08)
BME280-Release_Version_2.1.2\library.properties (505, 2017-02-08)
BME280-Release_Version_2.1.2\src (0, 2017-02-08)
BME280-Release_Version_2.1.2\src\BME280.cpp (8737, 2017-02-08)
BME280-Release_Version_2.1.2\src\BME280.h (5458, 2017-02-08)
BME280-Release_Version_2.1.2\src\BME280I2C.cpp (4535, 2017-02-08)
BME280-Release_Version_2.1.2\src\BME280I2C.h (2465, 2017-02-08)
BME280-Release_Version_2.1.2\src\BME280Spi.cpp (3880, 2017-02-08)
BME280-Release_Version_2.1.2\src\BME280Spi.h (2523, 2017-02-08)
BME280-Release_Version_2.1.2\src\BME280SpiSw.cpp (4204, 2017-02-08)
BME280-Release_Version_2.1.2\src\BME280SpiSw.h (2678, 2017-02-08)

# BME280 Provides an Arduino library for reading and interpreting Bosch BME280 data over I2C and SPI. ## Table of Contents * [BME280](#bme280) * [Table of Contents](#table_of_contents) * [Summary](#summary) * [Installation](#installation) * [Usage](#usage) * [Methods](#methods) * [BME280I2C(uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3, uint8_t st = 0x5, uint8_t filter = 0x0, bool spiEnable = false, uint8_t bme_280_addr = 0x76)](#methods) * [BME280Spi(uint8_t spiCsPin, uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3, uint8_t st = 0x5, uint8_t filter = 0x0)](#methods) * [BME280SpiSw(uint8_t spiCsPin, uint8_t spiMosiPin, uint8_t spiMisoPin, uint8_t spiSckPin, uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3, uint8_t st = 0x5, uint8_t filter = 0x0)](#methods) * [bool begin()](#methods) * [void setMode(uint8_t mode)](#methods) * [float temp(bool celsius = true)](#methods) * [float pres(uint8_t unit = 0x0)](#methods) * [float hum()](#methods) * [void read(float& pressure, float& temp, float& humidity, bool metric = true, uint8_t p_unit = 0x0)](#methods) * [float alt(bool metric = true, float seaLevelPressure = 101325)](#methods) * [float alt(float pressure, bool metric = true, float seaLevelPressure = 101325)](#methods) * [float dew(bool metric = true)](#methods) * [float dew(float temp, float hum, bool metric = true)](#methods) * [Contributing](#contributing) * [History](#history) * [Credits](#credits) * [License](#license) ## Summary Reads temperature, humidity, and pressure. Calculates altitude and dew point. Provides functions for english and metric. Also reads pressure in Pa, hPa, inHg, atm, bar, torr, N/m^2 and psi. ## Installation To use this library download the zip file, uncompress it to a folder named BME280. Move the folder to {Arduino Path}/libraries. ## Usage Include the library at the top of your Arduino script. `#include ` Create a global or local variable. `BME280 bme` In your start up call `bme.begin()`. Read the temperature, humidity, pressure, altitude and/or dew point. `float pres, temp, hum` `bme.read(pres, temp, hum)` or `temp = bme.temp()` `hum = bme.hum()` `pres = bme.pres()` `float altitude, dewPoint` `altitude = bme.alt()` `dewPoint = bme.dew()` Use `setMode(0x01)` to trigger a new measurement in forced mode. NOTE: It takes ~8ms to measure all values (temp, humidity & pressure) when using x1 oversampling (see datasheet 11.1). Thus a delay of >8ms should be used after triggering a measurement and before reading data to ensure that read values are the latest ones. ## Methods #### BME280I2C(uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3, uint8_t st = 0x5, uint8_t filter = 0x0, bool spiEnable = false, uint8_t bme_280_addr = 0x76) Constructor used to create the I2C Bme class. All parameters have default values. Return: None * Temperature Oversampling Rate (tosr): uint8_t, default = 0x1 values: B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16 * Humidity Oversampling Rate (hosr): uint8_t, default = 0x1 values: B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16 * Pressure Oversampling Rate (posr): uint8_t, default = 0x1 values: B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16 * Mode: uint8_t, default = Normal values: Sleep = B00, Forced = B01 and B10, Normal = B11 * Standby Time (st): uint8_t, default = 1000ms values: B000 = 0.5ms, B001 = 62.5ms, B010 = 125ms, B011 = 250ms, B100 = 250ms, B101 = 1000ms, B110 = 10ms, B111 = 20ms * Filter: uint8_t, default = None values: B000 = off, B001 = 2, B010 = 4, B011 = 8, B100/other = 16 * SPI Enable: bool, default = false values: true = enable, false = disable * BME280 Address: uint8_t, default = 0x76 values: any uint8_t #### BME280Spi(uint8_t spiCsPin, uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3, uint8_t st = 0x5, uint8_t filter = 0x0) Constructor used to create the Spi Bme class. All parameters have default values. Return: None * SPI Chip Select Pin (spiCsPin): uint8_t values: Any pin 0-31 * Temperature Oversampling Rate (tosr): uint8_t, default = 0x1 values: B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16 * Humidity Oversampling Rate (hosr): uint8_t, default = 0x1 values: B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16 * Pressure Oversampling Rate (posr): uint8_t, default = 0x1 values: B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16 * Mode: uint8_t, default = Normal values: Sleep = B00, Forced = B01 and B10, Normal = B11 * Standby Time (st): uint8_t, default = 1000ms values: B000 = 0.5ms, B001 = 62.5ms, B010 = 125ms, B011 = 250ms, B100 = 250ms, B101 = 1000ms, B110 = 10ms, B111 = 20ms * Filter: uint8_t, default = None values: B000 = off, B001 = 2, B010 = 4, B011 = 8, B100/other = 16 #### BME280SpiSw(uint8_t spiCsPin, uint8_t spiMosiPin, uint8_t spiMisoPin, uint8_t spiSckPin, uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x3, uint8_t st = 0x5, uint8_t filter = 0x0) Constructor used to create the software Spi Bme class. All parameters have default values. Return: None * SPI Chip Select Pin (spiCsPin): uint8_t values: Any pin 0-31 * SPI Master Out Slave In Pin (spiMosiPin): uint8_t values: Any pin 0-31 * SPI Master In Slave Out Pin (spiMisoPin): uint8_t values: Any pin 0-31 * SPI Serial Clock Pin (spiSckPin): uint8_t values: Any pin 0-31 * Temperature Oversampling Rate (tosr): uint8_t, default = 0x1 values: B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16 * Humidity Oversampling Rate (hosr): uint8_t, default = 0x1 values: B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16 * Pressure Oversampling Rate (posr): uint8_t, default = 0x1 values: B000 = Skipped, B001 = x1, B010 = x2, B011 = x4, B100 = x8, B101/other = x16 * Mode: uint8_t, default = Normal values: Sleep = B00, Forced = B01 and B10, Normal = B11 * Standby Time (st): uint8_t, default = 1000ms values: B000 = 0.5ms, B001 = 62.5ms, B010 = 125ms, B011 = 250ms, B100 = 250ms, B101 = 1000ms, B110 = 10ms, B111 = 20ms * Filter: uint8_t, default = None values: B000 = off, B001 = 2, B010 = 4, B011 = 8, B100/other = 16 #### bool begin() Method used at start up to initialize the class. Starts the I2C or SPI interface. Return: bool, true = success, false = failure (no device found) #### void setMode(uint8_t mode) Method to set the sensor mode. Sleep = B00, Forced = B01 and B10, Normal = B11. Set to B01 to trigger a new measurement when using forced mode. #### float temp(bool celsius = true) Read the temperature from the BME280 and return a float. Return: float = temperature * Celsius: bool, default = true values: true = return temperature in degrees Celsius, false = return temperature in degrees Fahrenheit #### float pres(uint8_t unit = 0x0) Read the pressure from the BME280 and return a float with the specified unit. Return: float = pressure * Unit: uint8_t, default = 0x0 values: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi #### float hum() Read the humidity from the BME280 and return a percentage as a float. Return: float = percent relative humidity #### void read(float& pressure, float& temp, float& humidity, bool metric = true, uint8_t p_unit = 0x0) Read the data from the BME280 with the specified units. Return: None, however, pressure, temp and humidity are changed. * Pressure: float, reference values: reference to storage float for pressure * Temperature: float, reference values: reference to storage float for temperature * Humidity: float, reference values: reference to storage float for humidity * Metric: bool, default = true values: true = meters, false = feet * Pressure Unit: uint8_t, default = 0x0 values: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi #### float alt(bool metric = true, float seaLevelPressure = 101325) Read the data from the BME280 with the specified units and then calculate the altitude. Return: float = altitude * Metric: bool, default = true values: true = meters, false = feet * Sea Level Pressure: float, unit = Pa, default = 101325 values: any float #### float alt(float pressure, bool metric = true, float seaLevelPressure = 101325) Calculate the altitude based on the pressure with the specified units. Return: float = altitude * Pressure: float, unit = Pa values: any float * Metric: bool, default = true values: true = meters, false = feet * Sea Level Pressure: float, unit = Pa, default = 101325 values: any float #### float dew(bool metric = true) Read BME280 data and calculate the dew point with the specified units. Return: float = dew point * Metric: bool, default = true values: true = return temperature in degrees Celsius, false = return temperature in degrees Fahrenheit #### float dew(float temp, float hum, bool metric = true) Calculate the dew point based on the temperature and humidity with the specified units. Return: float = dew point * Temperature: float, unit = Celsius if metric is true, Fahrenheit if metric is false values: any float * Humidity: float, unit = % relative humidity values: any float * Metric: bool, default = true values: true = return degrees Celsius, false = return degrees Fahrenheit ## Contributing 1. Fork the project. 2. Create your feature branch: `git checkout -b my-new-feature` 3. Commit your changes: `git commit -am 'Add some feature'` 4. Push to the branch: `git push origin my-new-feature` 5. Submit a pull request. ## History - Jan 1, 2016 - Version 1.0.0 released. - Sep 19, 2016 - Version 2.0.0 released (restructure for I2C and SPI). - Dec 19, 2016 - Version 2.1.0 released (support for SPI) - Dec 21, 2016 - Version 2.1.1 released (Fixing compilation errors) ## Credits Written by Tyler Glenn, 2016. Special thanks to Mike Glenn for editing and reviewing the code. ## License GNU GPL, see License.txt

近期下载者

相关文件


收藏者