Built-in project · Raspberry Pi Pico

CircuitPython BME280 on a Pico

CircuitPython on a Raspberry Pi Pico: busio.I2C and Adafruit’s adafruit_bme280 read the temperature, humidity and pressure and print them every two seconds. The whole build, a Raspberry Pi Pico and 1 more part, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Beginner Runs in your browser. Free, and no account needed.

The parts retail for about $10. On Mokxi they're free.

CircuitPython BME280 on a Pico · Raspberry Pi Picolive0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The MicroPython code exactly as the editor opens it. Change a line there and press Run: the board runs it on the official MicroPython firmware, with nothing to compile.

code.py · Raspberry Pi Pico
# CircuitPython on a Raspberry Pi Pico: a BME280 to the Serial Monitor.
# I2C0 on GP5 (SCL) and GP4 (SDA); Adafruit's adafruit_bme280 library goes
# into lib/ for you.
import board
import busio
import time
from adafruit_bme280 import basic as adafruit_bme280

i2c = busio.I2C(board.GP5, board.GP4)
bme = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76)

while True:
    print("%.1f C  %.1f %% humidity  %.1f hPa" % (bme.temperature, bme.relative_humidity, bme.pressure))
    time.sleep(2)

Parts list

2 parts, plus the jumper wires. They retail for about $10; on Mokxi they're free.

How it is wired

4 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Ground: Raspberry Pi Pico pin GND; Pressure, humidity and temperature, BME280 pin GND
  • Raspberry Pi Pico pin GP4; Pressure, humidity and temperature, BME280 pin SDA
  • Raspberry Pi Pico pin GP5; Pressure, humidity and temperature, BME280 pin SCL
  • Raspberry Pi Pico pin 3V3; Pressure, humidity and temperature, BME280 pin VIN

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.