CircuitPython library for the Bosch BME280 temperature/humidity/pressure sensor.
Project description
Introduction
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file adafruit_circuitpython_bme280-2.6.25.tar.gz
.
File metadata
- Download URL: adafruit_circuitpython_bme280-2.6.25.tar.gz
- Upload date:
- Size: 32.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cb991d117dc2e922f4f619ff6af43d6a93a6e2cfbeb4ed31fb95f70782d87a1 |
|
MD5 | 91d2990f3a19b286d6ada81a64d2b694 |
|
BLAKE2b-256 | f0296827ec86ebce5ba23cc6f32584a08790ddd17c6f844a1159f2b90e430263 |
File details
Details for the file adafruit_circuitpython_bme280-2.6.25-py3-none-any.whl
.
File metadata
- Download URL: adafruit_circuitpython_bme280-2.6.25-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a719cb747da3d292b5c3caf696aa644d259995efe7075dd0c624bb093626db99 |
|
MD5 | a21f859364acab33e60ebb4ad5a2f2d7 |
|
BLAKE2b-256 | 0acc03b5b6d9a05dc97d9c1d148403f9fd97fb76331984aecb99cad82af0a92c |