Skip to content

Commit b660b06

Browse files
committed
fix(bme280): Address Copilot review comments on PR 314.
1 parent 8cddc22 commit b660b06

3 files changed

Lines changed: 35 additions & 31 deletions

File tree

lib/bme280/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The BME280 is a high-precision environmental sensor suitable for applications su
1313

1414
---
1515

16-
# Features
16+
## Features
1717

1818
* I2C communication
1919
* device identification
@@ -31,7 +31,7 @@ The BME280 is a high-precision environmental sensor suitable for applications su
3131

3232
---
3333

34-
# Sensor Overview
34+
## Sensor Overview
3535

3636
| Feature | Value |
3737
| ---------------------- | ----------------------- |
@@ -46,7 +46,7 @@ The BME280 is a high-precision environmental sensor suitable for applications su
4646

4747
---
4848

49-
# I2C Address
49+
## I2C Address
5050

5151
The sensor can use two I2C addresses depending on the **SDO pin**:
5252

@@ -59,7 +59,7 @@ The default address used by the driver is **0x76**.
5959

6060
---
6161

62-
# Basic Usage
62+
## Basic Usage
6363

6464
```python
6565
from machine import I2C
@@ -71,7 +71,7 @@ i2c = I2C(1)
7171
sensor = BME280(i2c)
7272

7373
while True:
74-
temperature, pressure, humidity = sensor.read()
74+
temperature, pressure, humidity = sensor.read_one_shot()
7575

7676
print("T:", temperature, "C")
7777
print("P:", pressure, "hPa")
@@ -83,7 +83,7 @@ while True:
8383

8484
---
8585

86-
# API Reference
86+
## API Reference
8787

8888
## Initialization
8989

@@ -267,7 +267,7 @@ Performs a soft reset, re-reads calibration data, and re-applies default configu
267267

268268
---
269269

270-
# Examples
270+
## Examples
271271

272272
| Example | Description |
273273
| -------------------- | -------------------------------------------------- |
@@ -276,6 +276,6 @@ Performs a soft reset, re-reads calibration data, and re-applies default configu
276276

277277
---
278278

279-
# References
279+
## References
280280

281281
* [BME280 Datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme280-ds002.pdf)

lib/bme280/examples/basic_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
print("Device ID:", hex(sensor.device_id()))
1414

1515
for _ in range(10):
16-
temperature, pressure, humidity = sensor.read()
16+
temperature, pressure, humidity = sensor.read_one_shot()
1717

1818
print(
1919
"T: {:.1f} C P: {:.1f} hPa H: {:.1f} %RH".format(

tests/scenarios/bme280.yaml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -420,50 +420,54 @@ tests:
420420
# ----- Hardware tests -----
421421

422422
- name: "Temperature in plausible range"
423-
action: call
424-
method: temperature
425-
expect_range: [10.0, 45.0]
423+
action: script
424+
script: |
425+
t, _, _ = dev.read_one_shot()
426+
result = 10.0 <= t <= 45.0
427+
expect_true: true
426428
mode: [hardware]
427429

428430
- name: "Pressure in plausible range"
429-
action: call
430-
method: pressure_hpa
431-
expect_range: [900.0, 1100.0]
431+
action: script
432+
script: |
433+
_, p, _ = dev.read_one_shot()
434+
result = 900.0 <= p <= 1100.0
435+
expect_true: true
432436
mode: [hardware]
433437

434438
- name: "Humidity in plausible range"
435-
action: call
436-
method: humidity
437-
expect_range: [5.0, 95.0]
439+
action: script
440+
script: |
441+
_, _, h = dev.read_one_shot()
442+
result = 5.0 <= h <= 95.0
443+
expect_true: true
438444
mode: [hardware]
439445

440-
- name: "read() returns three plausible values"
446+
- name: "read_one_shot returns three plausible values"
441447
action: script
442448
script: |
443-
t, p, h = dev.read()
449+
t, p, h = dev.read_one_shot()
444450
result = 10.0 <= t <= 45.0 and 900.0 <= p <= 1100.0 and 5.0 <= h <= 95.0
445451
expect_true: true
446452
mode: [hardware]
447453

448-
- name: "read_one_shot returns three plausible values"
454+
- name: "Continuous mode produces plausible values"
449455
action: script
450456
script: |
451-
t, p, h = dev.read_one_shot()
457+
from time import sleep_ms
458+
dev.set_continuous()
459+
sleep_ms(100)
460+
t, p, h = dev.read()
461+
dev.power_off()
452462
result = 10.0 <= t <= 45.0 and 900.0 <= p <= 1100.0 and 5.0 <= h <= 95.0
453463
expect_true: true
454464
mode: [hardware]
455465

456466
- name: "Readings feel correct"
457467
action: manual
458468
display:
459-
- method: temperature
460-
label: "Temperature"
461-
unit: "C"
462-
- method: pressure_hpa
463-
label: "Pressure"
464-
unit: "hPa"
465-
- method: humidity
466-
label: "Humidity"
467-
unit: "%RH"
469+
- method: read_one_shot
470+
label: "T, P, H"
468471
prompt: "Do the values look reasonable?"
472+
expect_true: true
469473
mode: [hardware]

0 commit comments

Comments
 (0)