Skip to main content

BME-280 sensor device driver with Micropython support (I2C + SPI)

Project description

BME-280 sensor device driver with Micropython support (I2C + SPI)

Project website

Git repository

This driver runs on regular Python and on Micropython.

It has support for both I2C and SPI bus.

Example

import bme280

try:
    # Connect to BME-280 via I2C.
    bme = bme280.BME280(i2cBus=0)

    # Synchronously trigger a MODE_FORCED conversion and return the result.
    temperature, humidity, pressure = bme.readForced(filter=bme280.FILTER_2,
                                                     tempOversampling=bme280.OVSMPL_4,
                                                     humidityOversampling=bme280.OVSMPL_4,
                                                     pressureOversampling=bme280.OVSMPL_4)

    # Print the result.
    print(f"{temperature:.1f} *C; {humidity * 100:.1f} % rel. hum.; {pressure / 100:.1f} hPa")

except bme280.BME280Error as e:
    print(f"BME280 error: {e}")

License

Copyright (c) 2020-2022 Michael Büsch m@bues.ch

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

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

bme280-upy-1.0.tar.gz (16.0 kB view details)

Uploaded Source

File details

Details for the file bme280-upy-1.0.tar.gz.

File metadata

  • Download URL: bme280-upy-1.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for bme280-upy-1.0.tar.gz
Algorithm Hash digest
SHA256 ca9399b8dd380665c6d0135d78d3d70194830c5f17a5b2cf1348b36921e76ea1
MD5 3ccb7f4ad7e9008be2316d479ef086ec
BLAKE2b-256 5c635e95a625a8ce18788d40c73041b1c7bdaec9abe8963734237f20be642aba

See more details on using hashes here.

Supported by

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