Commit 1cdf9ff1 authored by Frank Radzio 's avatar Frank Radzio

add BME280 Lib

parent 68006727
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at finitespaceghb2@junk.yoglenn.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
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.
### Expected behavior
### Actual behavior
### Steps to reporduce the behavior
### Related issue # and issue behavior
### Description of changes/fixes
### @mention a person to review
### Steps to test
### Any outstanding TODOs or known issues
\ No newline at end of file
This diff is collapsed.
......@@ -24,41 +24,56 @@ SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-M
#define SERIAL_BAUD 115200
BME280I2C bme; // Default : forced mode, standby time = 1000 ms
// pressure ×1, temperature ×1, humidity ×1, filter off
/* Based on Bosch BME280I2C environmental sensor data sheet. */
//BME280I2C bme; // Weather Monitoring : forced mode, 1 sample/minute
// pressure ×1, temperature ×1, humidity ×1, filter off
// Current Consumption = 0.16 μA
// RMS Noise = 3.3 Pa/30 cm, 0.07 %RH
// Data Output Rate 1/60 Hz
//BME280I2C bme(1, 1, 0); // Humidity Sensing : forced mode, 1 sample/second
// pressure ×0, temperature ×1, humidity ×1, filter off
// Current Consumption = 2.9 μA
// RMS Noise = 0.07 %RH
// Data Output Rate = 1 Hz
//BME280I2C bme(2, 1, 5, 3, 0, 4); // Indoor Navigation : normal mode, standby time = 0.5ms
// pressure ×16, temperature ×2, humidity ×1, filter = x16
// Current Consumption = 633 μA
// RMS Noise = 0.2 Pa/1.7 cm
// Data Output Rate = 25Hz
// Filter Bandwidth = 0.53 Hz
// Response Time (75%) = 0.9 s
//BME280I2C bme(1, 0, 4, 3, 0, 4); // Gaming : normal mode, standby time = 0.5ms
// pressure ×4, temperature ×1, humidity ×0, filter = x16
// Current Consumption = 581 μA
// RMS Noise = 0.3 Pa/2.5 cm
// Data Output Rate = 83 Hz
// Filter Bandwidth = 1.75 Hz
// Response Time (75%) = 0.3 s
bool metric = false;
/* Recommended Modes -
Based on Bosch BME280I2C environmental sensor data sheet.
Weather Monitoring :
forced mode, 1 sample/minute
pressure ×1, temperature ×1, humidity ×1, filter off
Current Consumption = 0.16 μA
RMS Noise = 3.3 Pa/30 cm, 0.07 %RH
Data Output Rate 1/60 Hz
Humidity Sensing :
forced mode, 1 sample/second
pressure ×0, temperature ×1, humidity ×1, filter off
Current Consumption = 2.9 μA
RMS Noise = 0.07 %RH
Data Output Rate = 1 Hz
Indoor Navigation :
normal mode, standby time = 0.5ms
pressure ×16, temperature ×2, humidity ×1, filter = x16
Current Consumption = 633 μA
RMS Noise = 0.2 Pa/1.7 cm
Data Output Rate = 25Hz
Filter Bandwidth = 0.53 Hz
Response Time (75%) = 0.9 s
Gaming :
normal mode, standby time = 0.5ms
pressure ×4, temperature ×1, humidity ×0, filter = x16
Current Consumption = 581 μA
RMS Noise = 0.3 Pa/2.5 cm
Data Output Rate = 83 Hz
Filter Bandwidth = 1.75 Hz
Response Time (75%) = 0.3 s
*/
BME280I2C::Settings settings(
BME280::OSR_X1,
BME280::OSR_X1,
BME280::OSR_X1,
BME280::Mode_Forced,
BME280::StandbyTime_1000ms,
BME280::Filter_Off,
BME280::SpiEnable_False,
BME280I2C::I2CAddr_0x76 // I2C address. I2C specific.
);
BME280I2C bme(settings);
//////////////////////////////////////////////////////////////////
void setup()
......@@ -66,19 +81,36 @@ void setup()
Serial.begin(SERIAL_BAUD);
while(!Serial) {} // Wait
Wire.begin();
while(!bme.begin())
{
Serial.println("Could not find BME280I2C sensor!");
delay(1000);
}
switch(bme.chipModel())
{
case BME280::ChipModel_BME280:
Serial.println("Found BME280 sensor! Success.");
break;
case BME280::ChipModel_BMP280:
Serial.println("Found BMP280 sensor! No Humidity available.");
break;
default:
Serial.println("Found UNKNOWN sensor! Error!");
}
// Change some settings before using.
settings.tempOSR = BME280::OSR_X4;
bme.setSettings(settings);
}
//////////////////////////////////////////////////////////////////
void loop()
{
printBME280Data(&Serial);
printBME280CalculatedData(&Serial);
delay(500);
}
......@@ -89,31 +121,21 @@ void printBME280Data
)
{
float temp(NAN), hum(NAN), pres(NAN);
uint8_t pressureUnit(3); // unit: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
bme.read(pres, temp, hum, pressureUnit, metric); // Parameters: (float& pressure, float& temp, float& humidity, bool hPa = true, bool celsius = false)
BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
BME280::PresUnit presUnit(BME280::PresUnit_Pa);
bme.read(pres, temp, hum, tempUnit, presUnit);
client->print("Temp: ");
client->print(temp);
client->print("°"+ String(metric ? 'C' :'F'));
client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F'));
client->print("\t\tHumidity: ");
client->print(hum);
client->print("% RH");
client->print("\t\tPressure: ");
client->print(pres);
client->print(" atm");
}
//////////////////////////////////////////////////////////////////
void printBME280CalculatedData
(
Stream* client
)
{
float altitude = bme.alt(metric);
client->println("Pa");
client->print("\t\tAltitude: ");
client->print(altitude);
client->print((metric ? "m" : "ft"));
client->println();
delay(1000);
}
......@@ -14,7 +14,7 @@ to support https://github.com/pasko-zh/brzo_i2c library on ESP8266.
GNU General Public License
Written: Dec 30 2015.
Last Updated: Sep 23 2017.
Last Updated: Oct 07 2017.
Connecting the BME280 Sensor:
Sensor -> Board
......@@ -25,12 +25,17 @@ SDA (Serial Data) -> D2 on ESP8266
SCK (Serial Clock) -> D1 on ESP8266
*/
#include "Arduino.h"
#include <BME280BRZO_I2C.h>
#include "brzo_i2c.h"
#define USING_BRZO 1
#include "BME280I2C_BRZO.h"
#define SERIAL_BAUD 115200
BME280BRZO_I2C bme; // Default : forced mode, standby time = 1000 ms
const uint32_t I2C_ACK_TIMEOUT = 2000;
BME280I2C_BRZO bme; // Default : forced mode, standby time = 1000 ms
// Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off,
bool metric = true;
......@@ -42,18 +47,31 @@ void setup()
while(!Serial) {} // Wait
brzo_i2c_setup(SDA,SCL,I2C_ACK_TIMEOUT);
while(!bme.begin())
{
Serial.println("Could not find BME280 sensor!");
delay(1000);
}
switch(bme.chipModel())
{
case BME280::ChipModel_BME280:
Serial.println("Found BME280 sensor! Success.");
break;
case BME280::ChipModel_BMP280:
Serial.println("Found BMP280 sensor! No Humidity available.");
break;
default:
Serial.println("Found UNKNOWN sensor! Error!");
}
}
//////////////////////////////////////////////////////////////////
void loop()
{
printBME280Data(&Serial);
printBME280CalculatedData(&Serial);
delay(500);
}
......@@ -64,34 +82,21 @@ void printBME280Data
)
{
float temp(NAN), hum(NAN), pres(NAN);
uint8_t pressureUnit(3); // unit: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
bme.read(pres, temp, hum, metric, pressureUnit); // Parameters: (float& pressure, float& temp, float& humidity, bool celsius = false, uint8_t pressureUnit = 0x0)
BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
BME280::PresUnit presUnit(BME280::PresUnit_Pa);
bme.read(pres, temp, hum, tempUnit, presUnit);
client->print("Temp: ");
client->print(temp);
client->print("°"+ String(metric ? 'C' :'F'));
client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F'));
client->print("\t\tHumidity: ");
client->print(hum);
client->print("% RH");
client->print("\t\tPressure: ");
client->print(pres);
client->print(" atm");
}
client->println("Pa");
//////////////////////////////////////////////////////////////////
void printBME280CalculatedData
(
Stream* client
)
{
float altitude = bme.alt(metric);
float dewPoint = bme.dew(metric);
client->print("\t\tAltitude: ");
client->print(altitude);
client->print((metric ? "m" : "ft"));
client->print("\t\tDew point: ");
client->print(dewPoint);
client->println("°"+ String(metric ? 'C' :'F'));
delay(1000);
}
......@@ -8,7 +8,7 @@ BME280 library.
GNU General Public License
Written: Dec 30 2015.
Last Updated: Sep 19 2017.
Last Updated: Oct 07 2017.
Connecting the BME280 Sensor:
Sensor -> Board
......@@ -21,15 +21,13 @@ SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-M
*/
#include <BME280I2C.h>
#include <Wire.h> // Needed for legacy versions of Arduino.
#include <Wire.h>
#define SERIAL_BAUD 115200
BME280I2C bme; // Default : forced mode, standby time = 1000 ms
// Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off,
bool metric = false;
//////////////////////////////////////////////////////////////////
void setup()
{
......@@ -38,19 +36,30 @@ void setup()
while(!Serial) {} // Wait
Wire.begin();
while(!bme.begin())
{
Serial.println("Could not find BME280 sensor!");
delay(1000);
}
switch(bme.chipModel())
{
case BME280::ChipModel_BME280:
Serial.println("Found BME280 sensor! Success.");
break;
case BME280::ChipModel_BMP280:
Serial.println("Found BMP280 sensor! No Humidity available.");
break;
default:
Serial.println("Found UNKNOWN sensor! Error!");
}
}
//////////////////////////////////////////////////////////////////
void loop()
{
printBME280Data(&Serial);
printBME280CalculatedData(&Serial);
delay(500);
}
......@@ -60,37 +69,22 @@ void printBME280Data
Stream* client
)
{
float temp(NAN), hum(NAN), pres(NAN);
uint8_t pressureUnit(3); // unit: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
bme.read(pres, temp, hum, metric, pressureUnit); // Parameters: (float& pressure, float& temp, float& humidity, bool celsius = false, uint8_t pressureUnit = 0x0)
client->print("Temp: ");
client->print(temp);
client->print("°"+ String(metric ? 'C' :'F'));
client->print("\t\tHumidity: ");
client->print(hum);
client->print("% RH");
client->print("\t\tPressure: ");
client->print(pres);
client->print(" atm");
}
float temp(NAN), hum(NAN), pres(NAN);
//////////////////////////////////////////////////////////////////
void printBME280CalculatedData
(
Stream* client
)
{
float altitude = bme.alt(metric);
float dewPoint = bme.dew(metric);
BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
BME280::PresUnit presUnit(BME280::PresUnit_Pa);
bme.read(pres, temp, hum, tempUnit, presUnit);
client->print("\t\tAltitude: ");
client->print(altitude);
client->print((metric ? "m" : "ft"));
client->print("\t\tDew point: ");
client->print(dewPoint);
client->println("°"+ String(metric ? 'C' :'F'));
client->print("Temp: ");
client->print(temp);
client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F'));
client->print("\t\tHumidity: ");
client->print(hum);
client->print("% RH");
client->print("\t\tPressure: ");
client->print(pres);
client->println("Pa");
delay(1000);
}
......@@ -8,7 +8,7 @@ BME280 library.
GNU General Public License
Written: Dec 30 2015.
Last Updated: Sep 23 2017.
Last Updated: Oct 07 2017.
Connecting the BME280 Sensor:
Sensor -> Board
......@@ -29,8 +29,8 @@ SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-M
#define MISO_PIN 12
#define SCK_PIN 13
BME280SpiSw bme(CHIP_SELECT_PIN, MOSI_PIN, MISO_PIN, SCK_PIN);
BME280SpiSw::Settings settings(CHIP_SELECT_PIN, MOSI_PIN, MISO_PIN, SCK_PIN);
BME280SpiSw bme(settings);
bool metric = false;
......@@ -46,13 +46,24 @@ void setup()
Serial.println("Could not find BME280 sensor!");
delay(1000);
}
switch(bme.chipModel())
{
case BME280::ChipModel_BME280:
Serial.println("Found BME280 sensor! Success.");
break;
case BME280::ChipModel_BMP280:
Serial.println("Found BMP280 sensor! No Humidity available.");
break;
default:
Serial.println("Found UNKNOWN sensor! Error!");
}
}
//////////////////////////////////////////////////////////////////
void loop()
{
printBME280Data(&Serial);
printBME280CalculatedData(&Serial);
delay(1000);
}
......@@ -63,34 +74,21 @@ void printBME280Data
)
{
float temp(NAN), hum(NAN), pres(NAN);
uint8_t pressureUnit(3); // unit: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
bme.read(pres, temp, hum, metric, pressureUnit); // Parameters: (float& pressure, float& temp, float& humidity, bool celsius = false, uint8_t pressureUnit = 0x0)
BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
BME280::PresUnit presUnit(BME280::PresUnit_Pa);
bme.read(pres, temp, hum, tempUnit, presUnit);
client->print("Temp: ");
client->print(temp);
client->print("°"+ String(metric ? 'C' :'F'));
client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F'));
client->print("\t\tHumidity: ");
client->print(hum);
client->print("% RH");
client->print("\t\tPressure: ");
client->print(pres);
client->print(" atm");
}
client->println("Pa");
//////////////////////////////////////////////////////////////////
void printBME280CalculatedData
(
Stream* client
)
{
float altitude = bme.alt(metric);
float dewPoint = bme.dew(metric);
client->print("\t\tAltitude: ");
client->print(altitude);
client->print((metric ? "m" : "ft"));
client->print("\t\tDew point: ");
client->print(dewPoint);
client->println("°"+ String(metric ? 'C' :'F'));
delay(1000);
}
......@@ -8,7 +8,7 @@ BME280 library.
GNU General Public License
Written: Dec 30 2015.
Last Updated: Sep 23 2017.
Last Updated: Oct 07 2017.
Connecting the BME280 Sensor:
Sensor -> Board
......@@ -27,9 +27,10 @@ SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-M
#define DEVICE_PIN 10
BME280Spi bme(DEVICE_PIN); // Default : forced mode, standby time = 1000 ms
// Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off,
bool metric = false;
BME280Spi::Settings settings(DEVICE_PIN); // Default : forced mode, standby time = 1000 ms
// Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off,
BME280Spi bme(settings);
//////////////////////////////////////////////////////////////////
......@@ -39,18 +40,31 @@ void setup()
while(!Serial) {} // Wait
SPI.begin();
while(!bme.begin())
{
Serial.println("Could not find BME280 sensor!");
delay(1000);
}
switch(bme.chipModel())
{
case BME280::ChipModel_BME280:
Serial.println("Found BME280 sensor! Success.");
break;
case BME280::ChipModel_BMP280:
Serial.println("Found BMP280 sensor! No Humidity available.");
break;
default:
Serial.println("Found UNKNOWN sensor! Error!");
}
}
//////////////////////////////////////////////////////////////////
void loop()
{
printBME280Data(&Serial);
printBME280CalculatedData(&Serial);
delay(500);
}
......@@ -61,34 +75,21 @@ void printBME280Data
)
{
float temp(NAN), hum(NAN), pres(NAN);
uint8_t pressureUnit(3); // unit: B000 = Pa, B001 = hPa, B010 = Hg, B011 = atm, B100 = bar, B101 = torr, B110 = N/m^2, B111 = psi
bme.read(pres, temp, hum, metric, pressureUnit); // Parameters: (float& pressure, float& temp, float& humidity, bool celsius = false, uint8_t pressureUnit = 0x0)
BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
BME280::PresUnit presUnit(BME280::PresUnit_Pa);
bme.read(pres, temp, hum, tempUnit, presUnit);
client->print("Temp: ");
client->print(temp);
client->print("°"+ String(metric ? 'C' :'F'));
client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F'));
client->print("\t\tHumidity: ");
client->print(hum);
client->print("% RH");
client->print("\t\tPressure: ");
client->print(pres);
client->print(" atm");
}
//////////////////////////////////////////////////////////////////
void printBME280CalculatedData
(
Stream* client
)
{
float altitude = bme.alt(metric);
float dewPoint = bme.dew(metric);
client->print("\t\tAltitude: ");
client->print(altitude);
client->print((metric ? "m" : "ft"));
client->print("\t\tDew point: ");
client->print(dewPoint);
client->println("°"+ String(metric ? 'C' :'F'));
client->println("Pa");
delay(1000);
}
/*
Environment_Calculations.ino
This code shows how to record data from the BME280 environmental sensor
and perform various calculations.
GNU General Public License
Written: Dec 30 2015.
Last Updated: Oct 07 2017.
Connecting the BME280 Sensor:
Sensor -> Board
-----------------------------
Vin (Voltage In) -> 3.3V
Gnd (Ground) -> Gnd
SDA (Serial Data) -> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro
SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro
*/
#include <EnvironmentCalculations.h>
#include <BME280I2C.h>
#include <Wire.h>
#define SERIAL_BAUD 115200
// Assumed environmental values:
float referencePressure = 1018.6; // hPa local QFF (official meteor-station reading)
float outdoorTemp = 4.7; // °C measured local outdoor temp.
float barometerAltitude = 1650.3; // meters ... map readings + barometer position
BME280I2C::Settings settings(
BME280::OSR_X1,
BME280::OSR_X1,
BME280::OSR_X1,
BME280::Mode_Forced,
BME280::StandbyTime_1000ms,
BME280::Filter_16,
BME280::SpiEnable_False,
BME280I2C::I2CAddr_0x76
);
BME280I2C bme(settings);
//////////////////////////////////////////////////////////////////