Skip to main content

CircuitPython library for the Bosch BME280 temperature/humidity/pressure sensor.

Project description

Introduction

Documentation Status Discord Build Status Code Style: Black

I2C and SPI driver for the Bosch BME280 Temperature, Humidity, and Barometric Pressure sensor

Installation and Dependencies

This driver depends on:

Please ensure that the driver and all dependencies are available on the CircuitPython filesystem. This can be most easily achieved by downloading and installing the latest Adafruit library and driver bundle on your device.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-bme280

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-bme280

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-bme280

Installing to a connected CircuitPython Device

Some devices, eg. the QT-PY, are very limited in memory. The BME280 library contains two variants - basic and advanced - which give different levels of functionality.

Installing the BME280 library could have the following outcomes:

  • It installs successfully and your code runs successfully. Woo-hoo! Continue with your amazing project.

  • It installs successfully and your code fails to run with a memory allocation error. Try one of the following:

    • If your code.py is large, especially if it has lots of comments, you can shrink it into a .mpy file instead. See the Adafruit Learn Guide on shrinking your code.

    • Only use the basic BME280 implementation, and remove the following file: <CIRCUITPY>/lib/adafruit_bme280/advanced.mpy where <CIRCUITPY> is the mounted location of your device. Make sure that your code only uses the basic implementation.

Usage Example

import board
import time
from adafruit_bme280 import basic as adafruit_bme280

# Create sensor object, using the board's default I2C bus.
i2c = board.I2C()   # uses board.SCL and board.SDA
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)

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

while True:
    print("\nTemperature: %0.1f C" % bme280.temperature)
    print("Humidity: %0.1f %%" % bme280.relative_humidity)
    print("Pressure: %0.1f hPa" % bme280.pressure)
    print("Altitude = %0.2f meters" % bme280.altitude)
    time.sleep(2)

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adafruit-circuitpython-bme280-2.6.14.tar.gz (34.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file adafruit-circuitpython-bme280-2.6.14.tar.gz.

File metadata

File hashes

Hashes for adafruit-circuitpython-bme280-2.6.14.tar.gz
Algorithm Hash digest
SHA256 de2b07e2b5ab77a1e1c850cb56426ab61b29ce640106b406330dc340022892f9
MD5 9f3c7a43c5a79c6e0e1b2469dd926def
BLAKE2b-256 56a6329719bafb40e317a5cc3c8e6fbf30313f20739b7b248295d42b36b90cfd

See more details on using hashes here.

File details

Details for the file adafruit_circuitpython_bme280-2.6.14-py3-none-any.whl.

File metadata

File hashes

Hashes for adafruit_circuitpython_bme280-2.6.14-py3-none-any.whl
Algorithm Hash digest
SHA256 1f2ef3c9307983dda4b6bc7a0d0c10a1b20ee0c004a7279ac18e6f056c3359b8
MD5 d783c2a42d39d9b654d70c3960d1c80e
BLAKE2b-256 6bc43a9f994e5525165375f5e77439c538f0907fc92c207803747bcc85804bf5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page