The Adafruit BME680 is a cutting-edge environmental sensor module that combines measurements of temperature, humidity, barometric pressure, and volatile organic compounds (VOCs) to assess indoor air quality. This sensor is ideal for a wide range of applications, including IoT devices, weather stations, and environmental monitoring systems. Its small form factor and low power consumption make it suitable for portable and battery-powered devices.
Pin Number | Pin Name | Description |
---|---|---|
1 | VDD | Power supply (3.3V-5V) |
2 | GND | Ground |
3 | SCK/SCL | Serial Clock for SPI/I2C |
4 | SDI/SDA | Serial Data In for SPI / Serial Data for I2C |
5 | SDO | Serial Data Out for SPI / I2C Address Select |
6 | CS | Chip Select for SPI |
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h>
// Create an instance of the Adafruit_BME680 class
Adafruit_BME680 bme;
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println(F("BME680 test"));
if (!bme.begin()) { // Start the sensor
Serial.println(F("Could not find a valid BME680 sensor, check wiring!"));
while (1);
}
// Set up oversampling and filter initialization
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
bme.setGasHeater(320, 150); // 320*C for 150 ms
}
void loop() {
// Tell BME680 to begin measurement.
unsigned long startTime = millis();
if (!bme.performReading()) {
Serial.println(F("Failed to perform reading :("));
return;
}
Serial.print(F("Temperature = "));
Serial.print(bme.temperature);
Serial.println(F(" *C"));
Serial.print(F("Pressure = "));
Serial.print(bme.pressure / 100.0);
Serial.println(F(" hPa"));
Serial.print(F("Humidity = "));
Serial.print(bme.humidity);
Serial.println(F(" %"));
Serial.print(F("Gas = "));
Serial.print(bme.gas_resistance / 1000.0);
Serial.println(F(" KOhms"));
Serial.print(F("Approx. Altitude = "));
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(F(" m"));
Serial.println();
delay(2000); // Delay between readings
}
Q: Can the BME680 sensor measure outdoor air quality? A: While the BME680 is capable of measuring a wide range of environmental parameters, it is not specifically designed for outdoor air quality monitoring and may not be as effective in detecting large-scale pollutants.
Q: How long does the sensor need to warm up? A: The BME680 includes a built-in heater for the gas sensor. The heating time can be configured, but a typical warm-up time is around 150 milliseconds.
Q: Is the sensor waterproof? A: No, the BME680 is not waterproof and should be protected from moisture and water exposure to prevent damage.
Q: How can I extend the life of the sensor? A: Avoid exposing the sensor to extreme conditions, such as high temperatures and humidity levels, beyond its specified operating range. Also, avoid using the gas sensor continuously at high heater temperatures.