Introduction
BME280 is an environmental sensor that integrates onboard temperature sensor, humidity sensor and barometer. The sensor has high precision, multiple functions, and a small form factor. It provides both SPI and I2C interfaces, which make it easy to make fast prototypes. It can be widely used in environmental monitoring, story height measurement, Internet of Things (IoT) control and other various enviroment related ideas! Tge Gravity I2C BME280 Environmental Sensor has based on BoSCH's newest MEMS sensor (Micro-Electro-Mechanical System). It is very stable when compared with similar sensors. The sensor is especially adept in air pressure measurement; it has an offset temperature coefficient of ±1.5 Pa/K, equiv. to ±12.6 cm at 1 °C temperature change. Therefore, the stable and multi-function form of the BME280 can be a perfect fit in many scenarios.
Specification
- Working Voltage:3.3V~5.0V
- Working Current:2mA
- Working Temperature:-40℃~ 85℃
- Temperature Measuring Range: -40℃~ 85℃, resolution of 0.1℃, deviation of ±0.5℃
- Humidity Measuring Range: 0~100%RH, resolution of 0.1%RH, deviation of ±2%RH
- Pressure Measuring Range: 300~1100hPa
- Humidity Sampling Time: 1s
- Dimension: 22 * 25 mm/ 0.87 * 0.98 inches
- Weight: 12g
Board Overview
Num | Label | Description |
---|---|---|
1 | + | 3.3~5V |
2 | - | GND |
3 | C | SCL |
4 | D | SDA |
Tutorial
BME280 Environmental Sensor has two interface: I2C and SPI. In this section, we'll show you two examples about how to use.
Requirements
Hardware
- DFRduino UNO x 1
- Gravity: I2C BME280 Environmental Sensor x1
- M-M/F-M/F-F Jumper wires
Software
- Arduino IDE (Version requirement: V1.8 ), Click to Download Arduino IDE from Arduino®
- BME280 Environmental Sensor Arduino Library (Github) How to install Libraries in Arduino IDE
Arduino I2C Connection Diagram
Arduino I2C Sample Code
* raed_data_i2c.ino
*
* Download this demo to test read data from bme280, connect sensor through IIC interface
* Data will print on your serial monitor
*
* Copyright [DFRobot](https://www.dfrobot.com), 2016
* Copyright GNU Lesser General Public License
*
* version V1.0
* date 12/03/2019
*/
#include "DFRobot_BME280.h"
#include "Wire.h"
typedef DFRobot_BME280_IIC BME; // ******** use abbreviations instead of full names ********
BME bme(&Wire, 0x77); // select TwoWire peripheral and set sensor address
#define SEA_LEVEL_PRESSURE 1015.0f
// show last sensor operate status
void printLastOperateStatus(BME::eStatus_t eStatus)
{
switch(eStatus) {
case BME::eStatusOK: Serial.println("everything ok"); break;
case BME::eStatusErr: Serial.println("unknow error"); break;
case BME::eStatusErrDeviceNotDetected: Serial.println("device not detected"); break;
case BME::eStatusErrParameter: Serial.println("parameter error"); break;
default: Serial.println("unknow status"); break;
}
}
void setup()
{
Serial.begin(115200);
bme.reset();
Serial.println("bme read data test");
while(bme.begin() != BME::eStatusOK) {
Serial.println("bme begin faild");
printLastOperateStatus(bme.lastOperateStatus);
delay(2000);
}
Serial.println("bme begin success");
delay(100);
}
void loop()
{
float temp = bme.getTemperature();
uint32_t press = bme.getPressure();
float alti = bme.calAltitude(SEA_LEVEL_PRESSURE, press);
float humi = bme.getHumidity();
Serial.println();
Serial.println("======== start print ========");
Serial.print("temperature (unit Celsius): "); Serial.println(temp);
Serial.print("pressure (unit pa): "); Serial.println(press);
Serial.print("altitude (unit meter): "); Serial.println(alti);
Serial.print("humidity (unit percent): "); Serial.println(humi);
Serial.println("======== end print ========");
delay(1000);
}
Expected Results
Arduino SPI Connection Diagram
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum. |
---|