Temperature and Pressure with BME280

Introduction

This experiment demonstrates how to use the BME280 sensor to measure temperature, humidity, and pressure.

BME280 Sensor

Components Needed

Circuit Setup

  1. Connect the BME280 sensor's VCC pin to 3.3V on the Arduino.
  2. Connect the GND pin to ground.
  3. Connect the SDA and SCL pins to A4 and A5 on the Arduino for I2C communication.

The sensor will start collecting data when powered on.

BME280 Circuit Setup

Code for Temperature and Pressure Measurement

Upload the following code to your Arduino to read the temperature and pressure from the BME280 sensor:


#include 
#include 
#include 

Adafruit_BME280 bme; // Create an instance of the BME280 sensor

void setup() {
  Serial.begin(9600);
  if (!bme.begin()) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
}

void loop() {
  Serial.print("Temperature: ");
  Serial.print(bme.readTemperature());
  Serial.print(" °C");
  Serial.print(" Pressure: ");
  Serial.print(bme.readPressure() / 100.0F);
  Serial.println(" hPa");
  delay(1000);
}
            

Explanation

The BME280 sensor is used to measure environmental conditions. It outputs data for temperature, humidity, and pressure, which can be displayed on a serial monitor or used in more complex applications.

Troubleshooting