The Adafruit BME280 is a versatile and high-precision environmental sensor module capable of measuring temperature, humidity, and barometric pressure. Its compact size and I2C interface make it ideal for a wide range of applications, including weather monitoring, indoor climate control, and IoT projects. The sensor's ability to provide accurate and reliable environmental data makes it a popular choice for hobbyists and professionals alike.
Pin Number | Pin Name | Description |
---|---|---|
1 | VDD | Power supply (1.71 V to 3.6 V) |
2 | GND | Ground |
3 | SCK/SCL | Serial Clock Line for I2C/SPI |
4 | SDI/SDA | Serial Data In for SPI, Data for I2C |
5 | SDO | Serial Data Out for SPI, optional for I2C |
6 | CS | Chip Select for SPI (active low) |
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme; // I2C
void setup() {
Serial.begin(9600);
if (!bme.begin(0x76)) { // Address 0x76 for SDO connected to GND
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
delay(2000);
}
Serial.begin
rate in your code.Q: Can the BME280 sensor measure altitude? A: Yes, the sensor can estimate altitude based on the barometric pressure reading and a reference sea-level pressure.
Q: Is the BME280 waterproof? A: No, the BME280 is not waterproof and should be protected from moisture and condensation.
Q: How can I extend the life of the sensor? A: Avoid exposing the sensor to pollutants and corrosive gases, as they can degrade the sensor's performance over time.
Q: Can I use the BME280 sensor with a 5V microcontroller? A: Yes, but ensure that the logic levels are shifted down to 3.3V to avoid damaging the sensor.