The BME280 is a high-precision digital sensor designed to measure temperature, humidity, and atmospheric pressure. Manufactured by Adafruit, this sensor is widely used in weather stations, Internet of Things (IoT) applications, and environmental monitoring systems. Its compact size, low power consumption, and high accuracy make it an ideal choice for both hobbyists and professionals.
The BME280 sensor offers excellent performance and versatility. Below are its key technical details:
Parameter | Value |
---|---|
Supply Voltage | 1.8V to 3.6V |
Interface | I2C (up to 3.4 MHz) or SPI (up to 10 MHz) |
Temperature Range | -40°C to +85°C |
Temperature Accuracy | ±1.0°C |
Humidity Range | 0% to 100% |
Humidity Accuracy | ±3% RH |
Pressure Range | 300 hPa to 1100 hPa |
Pressure Accuracy | ±1 hPa |
Power Consumption | 3.6 µA (in normal mode) |
Dimensions | 2.5 mm x 2.5 mm x 0.93 mm |
The BME280 sensor typically comes in a breakout board format. Below is the pinout for the Adafruit BME280 breakout board:
Pin | Name | Description |
---|---|---|
1 | VIN | Power supply input (3.3V or 5V compatible) |
2 | GND | Ground connection |
3 | SCL | I2C clock line (or SPI clock in SPI mode) |
4 | SDA | I2C data line (or SPI MOSI in SPI mode) |
5 | CS | Chip select (used in SPI mode, connect to GND for I2C) |
6 | SDO | SPI MISO (or I2C address selection) |
The BME280 can be used in either I2C or SPI communication mode. Below are the steps to integrate the sensor into a circuit and use it with an Arduino UNO.
Wiring:
VIN
pin of the BME280 to the 5V pin on the Arduino.GND
pin of the BME280 to the GND pin on the Arduino.SCL
pin of the BME280 to the A5 pin on the Arduino (I2C clock line).SDA
pin of the BME280 to the A4 pin on the Arduino (I2C data line).CS
pin unconnected or tied to GND for I2C mode.SDO
pin unconnected or tied to GND for the default I2C address (0x76).Install Required Libraries:
Example Code: Use the following code to read temperature, humidity, and pressure from the BME280:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
// Create an instance of the BME280 sensor
Adafruit_BME280 bme;
void setup() {
Serial.begin(9600);
while (!Serial); // Wait for the serial monitor to open
// Initialize the BME280 sensor
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
// Read and print temperature, humidity, and pressure
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" °C");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F); // Convert Pa to hPa
Serial.println(" hPa");
Serial.println();
delay(2000); // Wait 2 seconds before the next reading
}
0x76
. If the SDO
pin is connected to VCC
, the address changes to 0x77
.Sensor Not Detected:
SDO
pin is configured correctly for the desired I2C address.Incorrect Readings:
Arduino Freezes or Crashes:
Can the BME280 be used with 5V logic? Yes, the Adafruit breakout board includes level-shifting circuitry, making it compatible with 5V logic.
What is the difference between I2C and SPI modes? I2C uses fewer pins and is easier to set up, while SPI offers faster communication speeds.
How do I calibrate the sensor? The BME280 is factory-calibrated, so no additional calibration is required for most applications.
Can the BME280 measure altitude? Yes, altitude can be calculated using the pressure readings and a reference sea-level pressure value.