Skip to content

feat(sensors): add 1-Wire (Dallas) temperature sensor support#2822

Open
drewmccal wants to merge 1 commit into
meshcore-dev:mainfrom
drewmccal:feat/onewire-sensor-support
Open

feat(sensors): add 1-Wire (Dallas) temperature sensor support#2822
drewmccal wants to merge 1 commit into
meshcore-dev:mainfrom
drewmccal:feat/onewire-sensor-support

Conversation

@drewmccal

Copy link
Copy Markdown

Closes #2692

Summary

Adds 1-Wire (Dallas) temperature sensor support to EnvironmentSensorManager, so any board can report temperature telemetry from a DS18B20-family probe with no source changes — just two build flags.

What's included

  • New OneWireSensor driver (src/helpers/sensors/OneWireSensor.{cpp,h}) covering every DallasTemperature-supported temperature family:
    • DS18B20 (0x28), DS18S20/DS1820 (0x10), DS1822 (0x22), DS1825/MAX31850 (0x3B), DS28EA00 (0x42)
  • Integration into EnvironmentSensorManager::begin() via a dedicated 1-Wire registration pass. Each detected probe on the bus is enumerated and exposed as its own telemetry sub-channel, so multiple probes on one pin work without configuration.
  • The driver gates on a 1-Wire presence pulse before engaging DallasTemperature, mirroring the existing I2C ACK check — an absent bus pushes no telemetry entries, preserving the "never touch absent hardware" invariant.
  • RAK_4631_sensor env enables it as a reference (WB_IO1).

How to enable on a board

Add to the board env's build_flags:

-D ENV_INCLUDE_ONEWIRE=1
-D TELEM_ONEWIRE_PIN=<gpio>

(plus the paulstoffregen/OneWire and milesburton/DallasTemperature lib deps, added to the shared lib_deps)

Portability

No board-specific pins or #ifdefs in the driver — the bus pin comes from TELEM_ONEWIRE_PIN, and the whole module compiles out when ENV_INCLUDE_ONEWIRE is unset. The same flags can be added to other server builds (e.g. the repeater), since they share EnvironmentSensorManager.

Testing

Tested and confirmed working on a RAK4631 on a WisBlock base board: a DS18B20 probe wired to WB_IO1 (DATA), 3V3, GND with a 4.7 kΩ pull-up. The probe is detected at boot and its temperature is reported as a telemetry channel, verified via the companion's Request Telemetry. Absent-bus and multi-probe enumeration paths both exercised.

🤖 Generated with Claude Code

Add a portable 1-Wire bus driver to EnvironmentSensorManager covering
the DallasTemperature-supported temperature families (DS18B20, DS18S20,
DS1822, DS1825/MAX31850, DS28EA00). Each detected probe on the bus is
registered as its own telemetry sub-channel, so multiple probes on one
pin work without configuration.

The driver gates on a 1-Wire presence pulse before engaging
DallasTemperature, mirroring the I2C ACK check, so an absent bus pushes
no telemetry entries. Boards opt in purely via build flags
(ENV_INCLUDE_ONEWIRE + TELEM_ONEWIRE_PIN) with no source changes; the
RAK4631 sensor env enables it on WB_IO1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] 1-Wire (DS18B20) sensor support for environmental telemetry

1 participant