Raspberry Pi Pico and BME680 gas sensor circuitpython example

In this article we connect a BME680 gas sensor to a Raspberry Pi Pico running Circuitpython

Sensor Information

The BME680 is a gas sensor that integrates high-linearity and high-accuracy gas, pressure, humidity and temperature sensors. It is especially developed for mobile applications and wearables where size and low power consumption are critical requirements.

The BME680 guarantees – depending on the specific operating mode – optimized consumption, long-term stability and high EMC robustness.

In order to measure air quality for personal wellbeing the gas sensor within the BME680 can detect a broad range of gases such as volatile organic compounds (VOC).

Parameter Technical data
Package dimensions 8-Pin LGA with metal 3.0 x 3.0 x 0.93 mm³
Operation range (full accuracy) Pressure: 300…1100 hPa
Humidity 0…100%
Temperature: -40…85°C
Supply voltage VDDIO
Supply voltage VDD
1.2 … 3.6 V
1.71 … 3.6 V
Interface I²C and SPI
Average current consumption
(1Hz data refresh rate))
Average current consumption in sleep mode
2.1 µA at 1 Hz humidity and temperature
3.1 µA at 1 Hz pressure and temperature
3.7 µA at 1 Hz humidity, pressure and temperature
0.09‒12 mA for p/h/T/gas depending on operation mode
Gas sensor
Response time (τ 33-63%)
Sensor-to-sensor deviation
Power consumption
Output data processing
< 1 s (for new sensors)
+/- 15% +/- 15
< 0.1 mA in ultra-low power mode
direct output of IAQ: Index for Air Quality
Humidity sensor
Response time (τ0-63%)
Accuracy tolerance
Hysteresis
8 s
± 3 % relative humidity
≤ 1.5 % relative humidity
Pressure sensor
RMS Noise
Sensitivity Error
Temperature coefficient offset
0.12 Pa (equiv. to 1.7 cm)
± 0.25 % (equiv. to 1 m at 400 m height change)
±1.3 Pa/K (equiv. to ±10.9 cm at 1°C temperature change)

Parts Required

A more expensive which can cost up to $11 to $14

Name Link
Pico Raspberry Pi Pico Development Board
BME680 BME680 Digital Temperature Humidity Pressure Sensor
Connecting cables Aliexpress link

Amazon.com link

Ebay link

 

Schematic/Connection

Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

rp2040 and bme680

Code Example

I used Thonny for development

The following is based on a library , I copied the adafruit_bme680.mpy library for this device to the lib folder on my Raspberry Pi Pico – https://circuitpython.org/libraries

This is the basic example which comes with the library

[codesyntax lang=”python”]

import time
import board
import adafruit_bme680
import busio

i2c = busio.I2C(scl=board.GP1, sda=board.GP0) # uses board.SCL and board.SDA

# To initialise using the default address:
bme680 = adafruit_bme680.Adafruit_BME680_I2C(i2c, 0x76)

# change this to match the location's pressure (hPa) at sea level
bme680.sea_level_pressure = 1013.25

# You will usually have to add an offset to account for the temperature of
# the sensor. This is usually around 5 degrees but varies by use. Use a
# separate temperature sensor to calibrate this one.
temperature_offset = -5

while True:
    print("\nTemperature: %0.1f C" % (bme680.temperature + temperature_offset))
    print("Gas: %d ohm" % bme680.gas)
    print("Humidity: %0.1f %%" % bme680.relative_humidity)
    print("Pressure: %0.3f hPa" % bme680.pressure)
    print("Altitude = %0.2f meters" % bme680.altitude)

    time.sleep(1)

[/codesyntax]

Output

Here is what I saw in Thonny REPL window

Temperature: 13.8 C
Gas: 57510 ohm
Humidity: 48.8 %
Pressure: 995.629 hPa
Altitude = 147.76 meters

Temperature: 13.8 C
Gas: 19884 ohm
Humidity: 48.9 %
Pressure: 995.628 hPa
Altitude = 147.76 meters

Links

https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme680-ds001.pdf

Related posts

Raspberry Pi Pico and MMC5603 3-axis AMR magnetic sensor circuitpython example

Raspberry Pi Pico and LTR329 UV Light Sensor circuitpython example

Raspberry Pi Pico and LTR303 UV Light Sensor circuitpython example

1 comment

ICYMI Python on Microcontrollers Newsletter: Python Developer’s Survey, vscode.dev and more! #Python #ICYMI #CircuitPython @micropython @ThePSF « Adafruit Industries – Makers, hackers, artists, designers and engineers! 27 October 2021 - 2:32 pm
[…] Connecting a BME680 gas sensor to a Raspberry Pi Pico running CircuitPython – RP2040. […]

Comments are closed.

Add Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More