Skip to content

docs(bme280): Add README, examples, and hardware test scenarios#314

Merged
nedseb merged 4 commits into
mainfrom
docs/bme280-examples-readme
Mar 29, 2026
Merged

docs(bme280): Add README, examples, and hardware test scenarios#314
nedseb merged 4 commits into
mainfrom
docs/bme280-examples-readme

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 29, 2026

Closes #307
Closes #9

Summary

  • README.md: full API documentation (initialization, measurements, configuration, modes, device management)
  • basic_reader.py: simple example reading temperature, pressure, humidity 10 times
  • weather_station.py: continuous monitoring with altitude computation and CSV logging to DAPLink flash
  • Hardware tests: 6 new scenarios (plausible range checks for temperature, pressure, humidity, read(), read_one_shot(), and a manual validation prompt)
  • Root README.md: updated board components table — BME280 now links to driver README instead of "not yet implemented"

Note: bme280 scope was already added to commitlint.config.js in PR #311.

Test plan

  • 39 mock tests pass (make test-bme280)
  • Lint passes (ruff check lib/bme280/)
  • Hardware tests require a BME280 sensor connected on I2C bus 1 at 0x76

Copilot AI review requested due to automatic review settings March 29, 2026 11:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds documentation, examples, and hardware test scenarios for the BME280 MicroPython driver, and updates the root component table to link to the new driver docs.

Changes:

  • Added lib/bme280/README.md with API reference and usage notes
  • Added two BME280 example scripts (basic_reader.py, weather_station.py)
  • Added BME280 hardware test scenarios and updated root README.md to link the driver

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/scenarios/bme280.yaml Adds hardware-mode range checks plus a manual validation prompt
lib/bme280/examples/basic_reader.py Adds a simple 10-sample read example
lib/bme280/examples/weather_station.py Adds continuous monitoring with altitude estimation + DAPLink flash CSV logging
lib/bme280/README.md Adds driver documentation and API reference
README.md Updates board components table to link to the BME280 README

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/bme280/README.md Outdated
Comment on lines +16 to +18
# Features

* I2C communication
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Section headings are using # (H1) repeatedly (e.g., “# Features”, “# Sensor Overview”, ...). This makes the document structure inconsistent and can hurt navigation; other driver READMEs use a single H1 title and H2/H3 for sections. Downgrade these subsection headings to ##/### as appropriate.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b660b06: all section headings downgraded from H1 to H2 (Features, Sensor Overview, I2C Address, Basic Usage, API Reference, Examples, References).

Comment thread lib/bme280/README.md
Comment on lines +272 to +276
| Example | Description |
| -------------------- | -------------------------------------------------- |
| `basic_reader.py` | Read temperature, pressure, and humidity |
| `weather_station.py` | Continuous logging with altitude computation |

Copy link

Copilot AI Mar 29, 2026

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

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.

Comment thread lib/bme280/examples/basic_reader.py Outdated
print("Device ID:", hex(sensor.device_id()))

for _ in range(10):
temperature, pressure, humidity = sensor.read()
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basic_reader.py calls sensor.read() without ever starting measurements (the driver’s constructor configures the BME280 into sleep mode). This will read whatever stale/undefined values are currently in the data registers. Either call sensor.set_continuous(...) once before the loop or use sensor.read_one_shot() inside the loop.

Suggested change
temperature, pressure, humidity = sensor.read()
temperature, pressure, humidity = sensor.read_one_shot()

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b660b06: basic_reader.py now uses sensor.read_one_shot() instead of sensor.read().

Comment thread lib/bme280/README.md
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)
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “Basic Usage” snippet uses sensor.read() in a loop, but the driver defaults to sleep mode and read() does not trigger a measurement. Update the docs to either show set_continuous(...) before the loop or use read_one_shot() so the example produces fresh readings on real hardware.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

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().

Comment on lines +422 to +446
- name: "Temperature in plausible range"
action: call
method: temperature
expect_range: [10.0, 45.0]
mode: [hardware]

- name: "Pressure in plausible range"
action: call
method: pressure_hpa
expect_range: [900.0, 1100.0]
mode: [hardware]

- name: "Humidity in plausible range"
action: call
method: humidity
expect_range: [5.0, 95.0]
mode: [hardware]

- name: "read() returns three plausible values"
action: script
script: |
t, p, h = dev.read()
result = 10.0 <= t <= 45.0 and 900.0 <= p <= 1100.0 and 5.0 <= h <= 95.0
expect_true: true
mode: [hardware]
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These hardware tests call temperature/pressure_hpa/humidity/read() directly, but the driver initializes the sensor in sleep mode and these methods do not trigger a conversion. This can make hardware tests fail or read stale data. Convert these to scripts that first start a measurement (e.g., dev.trigger_one_shot() + wait, dev.read_one_shot(), or dev.set_continuous() with a short delay) before validating ranges.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b660b06: all hardware tests now use read_one_shot() (forced mode) instead of direct method calls in sleep mode. Also added a "Continuous mode produces plausible values" test that explicitly enters normal mode before reading.

- method: humidity
label: "Humidity"
unit: "%RH"
prompt: "Do the values look reasonable?"
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manual hardware test currently has no expectation (e.g., expect_true: true). As a result, the scenario runner will always pass this test regardless of the user's answer (it falls back to “no assertion”). Add an explicit expectation so a “No” response fails the test.

Suggested change
prompt: "Do the values look reasonable?"
prompt: "Do the values look reasonable?"
expect_true: true

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b660b06: added expect_true: true to the manual test.

Comment thread lib/bme280/README.md
Comment on lines +36 to +46
| 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 |

Copy link

Copilot AI Mar 29, 2026

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

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.

Comment thread lib/bme280/README.md
Comment on lines +53 to +57
| SDO | Address |
| ------ | ------- |
| GND | `0x76` |
| VDDIO | `0x77` |

Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I2C address table also uses || at the start of rows, which breaks standard Markdown table rendering. Use the usual single-pipe table row format so it displays correctly.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

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.

@nedseb nedseb merged commit c041dcc into main Mar 29, 2026
9 checks passed
@nedseb nedseb deleted the docs/bme280-examples-readme branch March 29, 2026 11:54
@nedseb nedseb mentioned this pull request Mar 29, 2026
2 tasks
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bme280: Add examples, README, and hardware tests. bme280: Add BME280 temperature, humidity and pressure sensor driver

2 participants