🍞
Breadstick
  • Breadstick Innovations Website
  • Breadsticks
    • đŸĨ–Raspberry Breadstick
      • Code Examples
        • Demo Code
        • POV Wand
        • Pride Flags POV Wand
        • 6-Axis IMU
        • RGB Blink
        • AsyncIO RGB Blink
        • Digital Input
        • Digital Output
        • PWM
        • ADC
        • Servo Motor
    • đŸĨ–Raspberry Breadstick Lite
    • 🍞Support Boards
      • I2C Devices
        • 🚌I2C Bus Rail Adapter
        • đŸŒĻī¸Weather Crouton
        • 😎Brightness Crouton
        • 📏Distance Crouton
        • đŸĢ¨Motion Crouton
      • I2S Devices
        • đŸ“ĸBoombox
      • SPI Devices
      • đŸ•šī¸Buttons/Switches
    • Learning Resources
    • Troubleshooting
  • Nougat
    • Nougat C3
    • Nougat Quad
    • Installing WLED
  • Pico Slices
    • 🔴Slice 1 - LED Mixer
      • Assembly Guide
      • CircuitPython Code
        • 1 - Blink
        • 2 - Analog Read to Plotter
        • 3 - PWM Fade
        • 4 - Pot Controlled PWM
        • 5 - Gamma Correction
    • âąī¸Slice 2 - Stopwatch
      • Assembly Guide
      • Coding Lessons
        • 1 - 7-Segment Display Intro
        • 2 - Cycling Through All Segments
    • âŦœSlice 3 - 8x8 Dot Matrix
      • Assembly Guide
      • MicroPython Code
        • 1 - Moveable Pixel
        • 2 - Snake
    • Circuit Python Setup
    • Reset Bricked Pico
  • Christmas
    • Christmas Tree DIY kit
  • Protoboards
    • â¤ī¸Proto-Heart
    • đŸĨĒProto-Toast
  • SHOP
Powered by GitBook
On this page
  • Product Page
  • Circuit Python Library
  • BME280 Datasheet
  • Code

Was this helpful?

  1. Breadsticks
  2. Support Boards
  3. I2C Devices

Weather Crouton

BME280 Temperature, Humidity, & Pressure Sensor

PreviousI2C Bus Rail AdapterNextBrightness Crouton

Last updated 1 year ago

Was this helpful?

Product Page

Circuit Python Library

BME280 Datasheet

Code

"""
Weather Crouton (BME280) Demo Code
Breadstick Innovations
April 7, 2024
https://learn.breadstick.ca/breadstick/breadsticks/support-boards/i2c-devices/weather-crouton
"""

import board
import time
from adafruit_bme280 import basic as adafruit_bme280

crouton_i2c = board.I2C()  # Default Breadstick I2C pins D11(SCL) & D12(SDA)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(crouton_i2c)  #

# Sea Level Pressure is defined as 1013.25 hPa
# This number is used for calculating bme280.altitude in meters
bme280.sea_level_pressure = 1013.25

# Uncomment this line if you want to calibrate the altitude to your location
# Warning - natural changes in air pressure will affect altimeter measurements
bme280.sea_level_pressure = bme280.pressure

while True:
    temp = bme280.temperature
    hum = bme280.relative_humidity
    pres = bme280.pressure
    alt = bme280.altitude

    plotter_data = (alt,)  # Mu's Plotter only displays tuples, this is a single object tuple

    print(plotter_data)
    print(f"Temperature: {temp} °C")
    print(f"Humidity: {hum} %")
    print(f"Pressure: {pres} hPa")
    print(f"Altitude: {alt} m")
    print("")

    time.sleep(0.1)

🍞
đŸŒĻī¸
https://github.com/adafruit/Adafruit_CircuitPython_BME280
https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme280-ds002.pdf
https://shop.breadstick.ca/products/weather-crouton