The Bosch BME280 is a digital environmental sensor that measures temperature, relative humidity, and barometric pressure. It typically communicates with microcontrollers over I2C . Use it to build weather/air-quality projects by connecting the sensor’s data interface to your Arduino/ESP32.
| Pin | Signal | Description |
|---|---|---|
VIN |
power | Module power input, typically 3.3–5V for the BME280 breakout. |
GND |
ground | Ground reference for power and I2C signals. |
SCL |
SCL | I2C clock line from the microcontroller to the BME280. |
SDA |
SDA | I2C data line between the microcontroller and the BME280. |
| From | To | Wire |
|---|---|---|
board:5V |
x1:VIN |
red |
board:GND |
x1:GND |
black |
board:SCL |
x1:SCL |
green |
board:SDA |
x1:SDA |
blue |
This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
Serial.println("BME280 sensor example");
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor at 0x76. Check wiring.");
while (1) {
delay(10);
}
}
Serial.println("BME280 initialized successfully.");
}
void loop() {
float temperature = bme.readTemperature();
float humidity = bme.readHumidity();
float pressure = bme.readPressure() / 100.0F;
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
Serial.print("Pressure: ");
Serial.print(pressure);
Serial.println(" hPa");
Serial.println("---");
delay(2000);
}
Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.
Start for free