feat: add ECMA-419 SHT3x sensor driver - #617
Conversation
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@firmware/mods/examples/unit_temperature/mod.js`:
- Around line 15-17: Wrap the SHT3x sample call in the relevant targetLoop flow
with try/catch so I2C exceptions trigger the same “Sensor read failed.” balloon
and return path as the existing sample === undefined CRC guard. Preserve the
current CRC handling while ensuring both thrown errors and undefined samples are
handled locally.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4bc6a19d-72f6-4513-acfd-0bf97d285105
📒 Files selected for processing (12)
.changeset/calm-sensors-sample.mdfirmware/host/modules/testing/fakes/mock-i2c.tsfirmware/host/modules/testing/manifest.jsonfirmware/mods/drivers/sensors/sht3x/README.mdfirmware/mods/drivers/sensors/sht3x/__tests__/sht3x-conformance/manifest.test.jsonfirmware/mods/drivers/sensors/sht3x/__tests__/sht3x-conformance/sht3x-conformance.test.tsfirmware/mods/drivers/sensors/sht3x/__tests__/sht3x-conformance/timer.jsfirmware/mods/drivers/sensors/sht3x/manifest.jsonfirmware/mods/drivers/sensors/sht3x/sht3x.jsfirmware/mods/examples/unit_temperature/manifest.jsonfirmware/mods/examples/unit_temperature/mod.jsfirmware/scripts/run-module-tests.js
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
firmware/mods/drivers/sensors/sht3x/__tests__/sht3x-conformance/sht3x-conformance.test.ts (1)
120-137: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRe-arm the settling check for every measurement.
minimumSettleTimeElapsedbecomestrueafter the first timer fires and is never reset. The sameio.readwrapper handles the secondsensor.sample()call, so that read can occur without a new settling delay and still pass. The timer also starts before the measurement write.Start a fresh timer for each
MEASUREwrite and clear it after the corresponding read, or record the write-to-read interval inMockI2C.As per path instructions, tests must assert observable behavior or relational invariants.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@firmware/mods/drivers/sensors/sht3x/__tests__/sht3x-conformance/sht3x-conformance.test.ts` around lines 120 - 137, Update testSampleShapeScaleAndMeasurementSettling so the settling assertion is re-armed for each MEASURE write and validated only for its corresponding read. Start the delay timer when each measurement command is written, clear or reset it after the matching io.read, and preserve coverage for both sensor.sample() calls without allowing the first timer to satisfy the second read.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@firmware/mods/drivers/sensors/sht3x/__tests__/sht3x-conformance/sht3x-conformance.test.ts`:
- Around line 120-137: Update testSampleShapeScaleAndMeasurementSettling so the
settling assertion is re-armed for each MEASURE write and validated only for its
corresponding read. Start the delay timer when each measurement command is
written, clear or reset it after the matching io.read, and preserve coverage for
both sensor.sample() calls without allowing the first timer to satisfy the
second read.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6792a50d-7343-492c-a635-53f869f3c626
📒 Files selected for processing (3)
firmware/mods/drivers/sensors/sht3x/__tests__/sht3x-conformance/sht3x-conformance.test.tsfirmware/mods/drivers/sensors/sht3x/sht3x.jsfirmware/mods/examples/unit_temperature/mod.js
🚧 Files skipped from review as they are similar to previous changes (1)
- firmware/mods/drivers/sensors/sht3x/sht3x.js

Summary
What Changed
target,configure(),sample(), idempotentclose(),Symbol.dispose, and asynchronousonError()handling.0..1range.0x2400and wait 16 ms before reading, covering the datasheet's 15.5 ms maximum high-repeatability conversion time.mods/examplesto allmodsso driver tests run by default.Verification
cd firmware && npm run formatcd firmware && npm run lintcd firmware && npx biome ci . --error-on-warningscd firmware && npm run test— 331 tests passedcd firmware && npm run check:legacy-namesnpm run check:architecture— passednpm run check:manifest— 6 targets passednpm run test:moddable— all 37 manifests passed, including SHT3x conformanceSTACKCHAN_MODULE_TEST_FILTER=sht3x-conformance npm run test:moddable— passed after the hardware-derived timing changePhysical hardware
/dev/ttyACM0, with the M5Stack SHT30 Unit connected to Port A0x2C06failed on this controller. The no-clock-stretch command0x2400plus a 16 ms conversion wait produced stable readings.Affected Areas
Breaking Changes
Release Impact
minor— adds a user-visible sensor driver and updates the Unit Temperature MOD..changeset/calm-sensors-sample.md.Related Issues
Summary by CodeRabbit