1. Introduction
The BME280 is an advanced environmental sensor that measures temperature, humidity, and atmospheric pressure. It uses I2C or SPI communication and is widely used in weather stations and IoT applications.
2. Components
- Raspberry Pi
- BME280 Sensor Module
- Breadboard
- Jumper Wires
3. Circuit and connections

Raspberry Pi Pinout Diagram

BME 280 Sensor Module Pinout Diagram
Connections (I2C Mode):
- VCC → 3.3V (Pin 1)
- GND → GND (Pin 6)
- SDA → GPIO2 (Pin 3)
- SCL → GPIO3 (Pin 5)
4. Detailed Step By Step Circuit working
- BME280 measures temperature, humidity, and pressure
- Internal ADC converts readings into digital data
- Data is sent via I2C communication
- Raspberry Pi receives data through SDA and SCL
- Values are processed and displayed
5. Libraries to be included
import smbus2
import bme280
import time
6. Code
import smbus2
import bme280
import time
port = 1
address = 0x76
bus = smbus2.SMBus(port)
calibration_params = bme280.load_calibration_params(bus, address)
while True:
data = bme280.sample(bus, address, calibration_params)
print("Temperature: {:.2f} C".format(data.temperature))
print("Humidity: {:.2f} %".format(data.humidity))
print("Pressure: {:.2f} hPa".format(data.pressure))
time.sleep(1)
7. Detailed Step By Step Code working
- Import required libraries
- Initialize I2C bus
- Set sensor address (0x76 or 0x77)
- Load calibration parameters
- Read sensor data
- Extract temperature, humidity, pressure
- Print values
- Repeat continuously
8. Tips
- Enable I2C in Raspberry Pi settings
-
Check sensor address using
i2cdetect -y 1 - Use correct library installation
- Ensure proper wiring
9. Uses
- Weather monitoring systems
- IoT environmental sensing
- Altitude measurement
- Smart home automation
10. Conclusion
The BME280 is a powerful and versatile sensor for environmental monitoring. It is ideal for advanced IoT projects with Raspberry Pi.