feat: BME280 temp/humidity/pressure telemetry (#30) #31

Merged
seb merged 1 commits from sl-firmware/bme280-full into main 2026-02-28 21:42:55 -05:00
Collaborator

Summary

  • Extends bmp280.c to fully support BME280 (chip_id 0x60) alongside BMP280 (0x58)
  • Reads humidity calibration (dig_H1H6) from registers 0xA1 and 0xE10xE7
  • Sets ctrl_hum (0xF2, osrs_h=×16) before ctrl_meas — hardware requirement
  • Adds bmp280_read_humidity(): float compensation on FPv5-SP FPU, returns %RH × 10; -1 if BMP280
  • main.c: baro_chip (chip_id) replaces baro_ok; telemetry adds t (°C×10), pa (hPa×10) for all barometers; h (%RH×10) for BME280 only
  • Web UI: hidden TEMP / HUMIDITY / PRESSURE rows revealed on first packet containing t/h/pa
  • I2C hang safety: all HAL operations use 100ms timeouts — missing hardware returns fast, not stuck

Test plan

  • Build passes (verified: 7.4% Flash, 1.6% RAM)
  • With GYBMEP at 0x76 or 0x77: JSON stream includes t, pa, h fields
  • With BMP280 only: h field absent, t and pa present
  • With no baro: no t/pa/h/alt fields
  • Web UI shows TEMP/HUMIDITY/PRESSURE rows only when data received

Closes #30.

🤖 Generated with Claude Code

## Summary - Extends `bmp280.c` to fully support BME280 (chip_id `0x60`) alongside BMP280 (`0x58`) - Reads humidity calibration (`dig_H1`–`H6`) from registers `0xA1` and `0xE1`–`0xE7` - Sets `ctrl_hum` (`0xF2`, `osrs_h=×16`) **before** `ctrl_meas` — hardware requirement - Adds `bmp280_read_humidity()`: float compensation on FPv5-SP FPU, returns `%RH × 10`; `-1` if BMP280 - `main.c`: `baro_chip` (chip_id) replaces `baro_ok`; telemetry adds `t` (°C×10), `pa` (hPa×10) for all barometers; `h` (%RH×10) for BME280 only - Web UI: hidden TEMP / HUMIDITY / PRESSURE rows revealed on first packet containing `t`/`h`/`pa` - I2C hang safety: all HAL operations use 100ms timeouts — missing hardware returns fast, not stuck ## Test plan - [ ] Build passes (verified: 7.4% Flash, 1.6% RAM) - [ ] With GYBMEP at 0x76 or 0x77: JSON stream includes `t`, `pa`, `h` fields - [ ] With BMP280 only: `h` field absent, `t` and `pa` present - [ ] With no baro: no `t`/`pa`/`h`/`alt` fields - [ ] Web UI shows TEMP/HUMIDITY/PRESSURE rows only when data received Closes #30. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sl-firmware added 1 commit 2026-02-28 19:44:05 -05:00
- bmp280.c: detect BME280 (chip_id 0x60) vs BMP280 (0x58) at init
- bmp280.c: read humidity calibration (dig_H1–H6) from 0xA1 and 0xE1–0xE7
- bmp280.c: set ctrl_hum (0xF2, osrs_h=×16) before ctrl_meas — hardware req
- bmp280.c: add bmp280_read_humidity() — float compensation (FPv5-SP FPU),
  returns %RH × 10; -1 if chip is BMP280 or not initialised
- bmp280.h: add bmp280_read_humidity() declaration + timeout note
- main.c: baro_ok → baro_chip (stores chip_id for BME280 detection)
- main.c: telemetry adds t (°C×10), pa (hPa×10) for all barometers;
  adds h (%RH×10) for BME280 only; alt unchanged
- ui/index.html: hidden TEMP/HUMIDITY/PRESSURE rows, revealed on first
  packet containing t/h/pa fields; values shown with 1 dp

I2C hang safety: all HAL_I2C_Mem_Read/Write use 100ms timeouts, so
missing hardware (NAK) returns in <1ms, not after a hang.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
seb approved these changes 2026-02-28 21:42:54 -05:00
seb left a comment
Owner

Flash-tested, builds and streams clean.

Flash-tested, builds and streams clean.
seb merged commit ad02d90b6b into main 2026-02-28 21:42:55 -05:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#31
No description provided.