Skip to content

Add one wire i2c bridge support#10078

Open
oscgonfer wants to merge 15 commits intomeshtastic:developfrom
fablabbcn:feat/add-one-wire-i2c-bridge
Open

Add one wire i2c bridge support#10078
oscgonfer wants to merge 15 commits intomeshtastic:developfrom
fablabbcn:feat/add-one-wire-i2c-bridge

Conversation

@oscgonfer
Copy link
Copy Markdown
Contributor

@oscgonfer oscgonfer commented Apr 4, 2026

Goes with meshtastic/protobufs#885

Adds support to DS248X I2C to one-wire temperature sensors like the DS18B20 (dallas/maxim/analog).

This PR supports a single sensor either via DS2482, or up to 8 sensors via DS2482-800, although currently there is no way for us to report more than one temperature (TBD potentially in 3.0).

For now, with this PR, we can report data on environment telemetry for the I2C to one-wire bridges. In the future, we could report up to 64 sensors (8 per DS2482-800, with 8 different addresses), although not worth the hassle - if we manage to make 8 sensors with one DS2482-800, that'd be quite amazing.

Tested this with both chips.

Example of DS2484-800 with two sensors connected (ch0 and ch1):

DEBUG | 16:41:13 213 [EnvironmentTelemetry] DS248X: read temperature in channel 0: 23.69
DEBUG | 16:41:13 213 [EnvironmentTelemetry] Got DS248X readings: temperature=23.69
WARN  | 16:41:13 213 [EnvironmentTelemetry] DS248X: No ROM in channel 1
DEBUG | 16:41:13 214 [EnvironmentTelemetry] DS248X: read temperature in channel 2: 23.62
WARN  | 16:41:13 214 [EnvironmentTelemetry] DS248X: No ROM in channel 3
WARN  | 16:41:13 214 [EnvironmentTelemetry] DS248X: No ROM in channel 4
WARN  | 16:41:13 214 [EnvironmentTelemetry] DS248X: No ROM in channel 5
WARN  | 16:41:13 214 [EnvironmentTelemetry] DS248X: No ROM in channel 6
WARN  | 16:41:13 214 [EnvironmentTelemetry] DS248X: No ROM in channel 7
INFO  | 16:41:13 214 [EnvironmentTelemetry] Send: barometric_pressure=0.000000, current=0.000000, gas_resistance=0.000000, relative_humidity=0.000000, temperature=23.687500

If we want to report all 8-channels already (although probably best to unify at 3.0), here is a PR for it: meshtastic/protobufs#886

* Supports single readings on DS2484
* Supports readings on ch0 for DS2484_800
* Detection of variant for DS248X
@oscgonfer oscgonfer self-assigned this Apr 4, 2026
@oscgonfer oscgonfer added enhancement New feature or request hardware-support Hardware related: new devices or modules, problems specific to hardware labels Apr 4, 2026
@oscgonfer
Copy link
Copy Markdown
Contributor Author

@thebentern probably good to have a copilot check because the 8-channel bridge has up to 8 different addresses, which collide with quite a few of the already supported keyboards and all sort of other things. I added support for all of them, but maybe it finds a mistake.

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 firmware support for DS248x I2C-to-1-Wire bridges so DS18B20 temperature sensors can be reported via Environment Telemetry (single temperature reported for now, with DS2482-800 multi-channel scanning supported).

Changes:

  • Introduces a new DS248XSensor telemetry sensor implementation using Adafruit’s DS248x library.
  • Extends I2C scanning to detect DS248x devices (including address conflicts with other peripherals).
  • Wires the new sensor into EnvironmentTelemetry and adds the dependency in platformio.ini.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/modules/Telemetry/Sensor/DS248XSensor.h New sensor header (DS248x/DS18B20 definitions and interface).
src/modules/Telemetry/Sensor/DS248XSensor.cpp New sensor implementation: init, ROM discovery, and temperature reads.
src/modules/Telemetry/EnvironmentTelemetry.cpp Registers DS248XSensor to be added after I2C scan.
src/detect/ScanI2CTwoWire.cpp Adds DS248x detection logic to the I2C scanner in overlapping-address cases.
src/detect/ScanI2C.h Adds DS248X to the DeviceType enum.
src/configuration.h Adds DS248x address constants (0x18–0x1F) with conflict notes.
platformio.ini Adds Adafruit_DS248x library dependency.

Comment thread src/modules/Telemetry/Sensor/DS248XSensor.h
Comment thread src/modules/Telemetry/Sensor/DS248XSensor.h Outdated
Comment thread src/modules/Telemetry/Sensor/DS248XSensor.h
Comment thread src/modules/Telemetry/Sensor/DS248XSensor.cpp Outdated
Comment thread src/modules/Telemetry/Sensor/DS248XSensor.cpp
Comment thread src/modules/Telemetry/Sensor/DS248XSensor.cpp
Comment thread src/detect/ScanI2CTwoWire.cpp
Comment thread src/detect/ScanI2CTwoWire.cpp
Comment thread src/detect/ScanI2CTwoWire.cpp
Comment thread src/modules/Telemetry/Sensor/DS248XSensor.cpp
@oscgonfer
Copy link
Copy Markdown
Contributor Author

@caveman99 since the multiple sensor protobuf option was merged, should I then support it here?

@fifieldt
Copy link
Copy Markdown
Member

@caveman99 since the multiple sensor protobuf option was merged, should I then support it here?

Suggest keeping this one as is and add that in a new patch. This PR has already got a few different things going on

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

Labels

enhancement New feature or request hardware-support Hardware related: new devices or modules, problems specific to hardware

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants