-
Notifications
You must be signed in to change notification settings - Fork 1
docs(bme280): Add README, examples, and hardware test scenarios #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8cddc22
b660b06
755f08c
64d0ca1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,320 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # BME280 MicroPython Driver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MicroPython driver for the **Bosch BME280** combined pressure, humidity, and temperature sensor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This driver provides a simple API to read **pressure**, **humidity**, and **temperature** over **I2C**. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The BME280 is a high-precision environmental sensor suitable for applications such as: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * weather monitoring | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * indoor air quality | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * altimetry support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * environmental sensing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Features | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * I2C communication | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * device identification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * pressure measurement (hPa) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * temperature measurement (C) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * relative humidity measurement (%RH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * one-shot acquisition (forced mode) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * continuous measurement mode (normal mode) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * configurable oversampling (temperature, pressure, humidity) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * configurable IIR filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * configurable standby time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * data-ready status helpers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * sleep mode (power off) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * soft reset and full reset with recalibration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Sensor Overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Feature | Value | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ---------------------- | ----------------------- | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Pressure range | 300 hPa - 1100 hPa | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Pressure resolution | 0.18 Pa (20-bit ADC) | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Temperature range | -40 C to +85 C | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Temperature resolution | 0.01 C | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Humidity range | 0 - 100 %RH | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Humidity resolution | 0.008 %RH (16-bit ADC) | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Interface | I2C / SPI | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Chip ID | 0x60 | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## I2C Address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The sensor can use two I2C addresses depending on the **SDO pin**: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | SDO | Address | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ------ | ------- | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | GND | `0x76` | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | VDDIO | `0x77` | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+53
to
+57
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The default address used by the driver is **0x76**. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Basic Usage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ```python | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from machine import I2C | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from time import sleep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from bme280 import BME280 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| i2c = I2C(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sensor = BME280(i2c) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while True: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| temperature, pressure, humidity = sensor.read_one_shot() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print("T:", temperature, "C") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print("P:", pressure, "hPa") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print("H:", humidity, "%RH") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sleep(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+69
to
+81
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| i2c = I2C(1) | |
| sensor = BME280(i2c) | |
| while True: | |
| temperature, pressure, humidity = sensor.read() | |
| print("T:", temperature, "C") | |
| print("P:", pressure, "hPa") | |
| print("H:", humidity, "%RH") | |
| print() | |
| sleep(1) | |
| i2c = I2C(1) | |
| sensor = BME280(i2c) | |
| sensor.set_continuous() # start continuous measurements | |
| while True: | |
| temperature, pressure, humidity = sensor.read() | |
| print("T:", temperature, "C") | |
| print("P:", pressure, "hPa") | |
| print("H:", humidity, "%RH") | |
| print() | |
| sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in b660b06: Basic Usage snippet now uses read_one_shot().
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The examples table at the end also starts rows with ||, which won’t render as a proper Markdown table. Switch to standard single-pipe table syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked: the tables use standard single-pipe syntax. No double-pipe issue found in the actual file.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| from time import sleep | ||
|
|
||
| from bme280 import BME280 | ||
| from machine import I2C | ||
|
|
||
| # Update the I2C bus number and pins to match your board | ||
| i2c = I2C(1) | ||
|
|
||
| # Create the sensor object | ||
| sensor = BME280(i2c) | ||
|
|
||
| print("BME280 found") | ||
| print("Device ID:", hex(sensor.device_id())) | ||
|
|
||
| for _ in range(10): | ||
| temperature, pressure, humidity = sensor.read_one_shot() | ||
|
|
||
| print( | ||
| "T: {:.1f} C P: {:.1f} hPa H: {:.1f} %RH".format( | ||
| temperature, pressure, humidity | ||
| ) | ||
| ) | ||
|
|
||
| sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Markdown table syntax here uses double leading pipes (
|| ...). GitHub-flavored Markdown tables require a single leading pipe per row, so this section will not render as intended. Convert these rows to standard| col | col |table formatting.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked: the tables use standard single-pipe Markdown syntax. No double-pipe issue in the actual source.