Skip to content

Raspberry Pi Pico BME280: Read data in CircuitPython | ShillehTek

October 22, 2023

Video Tutorial (Optional)

Watch first if you want to follow along and see the BME280 sensor wired to the Raspberry Pi Pico and read in CircuitPython.

Project Overview

Raspberry Pi Pico + BME280: In this build, you connect a Raspberry Pi Pico to a BME280 temperature, pressure, and humidity sensor and use CircuitPython to read environmental values.

The BME280 is a low-cost sensor for temperature, pressure, and humidity. It is often confused with the BMP280, but the BMP280 cannot measure humidity.

  • Time: 20 to 40 minutes
  • Skill level: Beginner
  • What you will build: A working I2C sensor hookup that prints BME280 readings in CircuitPython

Parts List

From ShillehTek

  • Breadboard (optional) - makes it easy to prototype the I2C wiring without soldering
  • Jumper wires - connect the Pico to the BME280 pins

External

  • Raspberry Pi Pico (or compatible Pico variant) - the microcontroller running CircuitPython
  • BME280 pressure, humidity, and temperature sensor module - the I2C sensor being read
  • BME280 sensor on Amazon
  • USB cable + a computer - to power the Pico and copy files

Note: Some BME280 modules have extra pins or slightly different layouts. For I2C you only need VCC, GND, SCL, and SDA.

Step-by-Step Guide

Step 1 - Wire the BME280 to the Pico (I2C)

Goal: Make the four required I2C connections so the Pico can talk to the BME280.

What to do: Connect the sensor to the Pico using the four pins shown in the wiring diagram (VCC, GND, SCL, SDA). Some BME280 boards include extra pins, but they are not required for this tutorial.

Raspberry Pi Pico connected to a BME280 sensor module using four I2C wires (VCC, GND, SCL, SDA)
Use I2C: VCC, GND, SCL, and SDA.

Expected result: The Pico and BME280 are physically connected with VCC, GND, SCL, and SDA, and you are ready to add the CircuitPython libraries.

Step 2 - Download and copy the Adafruit libraries

Goal: Install the CircuitPython library files required to use the BME280.

What to do: Get the BME280 CircuitPython library bundle from Adafruit: https://learn.adafruit.com/circuitpython-libraries-on-micropython-using-the-raspberry-pi-pico/bme280-library-example.

Click Download Project Bundle. Extract the zip, then copy the two required folders into the lib folder on your Raspberry Pi Pico so your directory matches the example layout.

Raspberry Pi Pico CircuitPython filesystem showing the lib folder structure for Adafruit BME280 libraries
Example file and folder structure on the Pico.

If you cannot copy and paste the files over, you may need to manually create the directory and file names and copy the contents.

Expected result: The required Adafruit library files are present on the Pico under the lib folder.

Step 3 - Run the sample CircuitPython code

Goal: Execute a working script that reads temperature, pressure, and humidity from the BME280.

What to do: Create a Python file (name of your choice) and copy the contents from this GitHub file: https://github.com/shillehbean/youtube-channel/blob/main/circuit_python_bme280.py.

Depending on your BME280 version, you may need to change the I2C address in the code to 0x77 instead of 0x76. You can also change the time.sleep() value to get readings slower or faster.

Once your libraries are installed and wiring is correct, run the script in Thonny. Make sure your Pico is powered when you are ready to go.

Expected result: The script runs and prints BME280 sensor readings in Thonny (temperature, pressure, and humidity).

Conclusion

You now have a Raspberry Pi Pico reading a BME280 sensor over I2C in CircuitPython, giving you temperature, pressure, and humidity values for environmental projects.

Want the exact parts used in this build? Grab what you need from ShillehTek.com. If you want help customizing this project or building something similar for your product, check out our consulting: https://shillehtek.com/pages/iot-consulting.