From 3bcdab97947f4b524304d2d7b11a53688b00d438 Mon Sep 17 00:00:00 2001 From: elwimen Date: Tue, 24 Mar 2026 14:12:18 +0100 Subject: [PATCH] feat: add DS18B20 1-Wire sensor support - New DS18B20Reading message (fixed32 device_id via FNV-1a hash, float temperature) - New DS18B20Config message in TelemetryConfig (pin, TemperatureMode enum, mesh_enabled) - DS18B20 = 51 in TelemetrySensorType enum - max_count:16 in telemetry.options for ds18b20_readings array --- meshtastic/module_config.proto | 49 ++++++++++++++++++++++++++++++++++ meshtastic/telemetry.options | 1 + meshtastic/telemetry.proto | 25 +++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/meshtastic/module_config.proto b/meshtastic/module_config.proto index 10753c6..7b70a34 100644 --- a/meshtastic/module_config.proto +++ b/meshtastic/module_config.proto @@ -619,6 +619,50 @@ message ModuleConfig { bool clear_on_reboot = 4; } + /* + * DS18B20 1-Wire sensor configuration. + */ + message DS18B20Config { + /* + * GPIO pin for the DS18B20 1-Wire sensor bus. 0 = disabled. + * Set via CLI to activate DS18B20 support on any pin. + */ + uint32 pin = 1; + + /* + * Which value the legacy EnvironmentMetrics.temperature scalar reports. + */ + enum TemperatureMode { + /* + * Report the temperature of the first sensor (index 0, sorted by ROM code). Default. + */ + FIRST = 0; + /* + * Report the average temperature across all connected sensors. + */ + AVERAGE = 1; + /* + * Report the minimum temperature across all connected sensors. + */ + MIN = 2; + /* + * Report the maximum temperature across all connected sensors. + */ + MAX = 3; + } + + /* + * Selects what value the legacy EnvironmentMetrics.temperature scalar reports. + */ + TemperatureMode mode = 2; + + /* + * When true, DS18B20 readings beyond the first packet are broadcast over LoRa mesh. + * When false (default), extra sensor chunks are sent only to the connected phone/client. + */ + bool mesh_enabled = 3; + } + /* * Configuration for both device and environment metrics */ @@ -707,6 +751,11 @@ message ModuleConfig { * Enable/Disable the air quality telemetry measurement module on-device display */ bool air_quality_screen_enabled = 15; + + /* + * DS18B20 1-Wire sensor configuration. Pin, temperature mode, and mesh broadcast control. + */ + DS18B20Config ds18b20 = 16; } /* diff --git a/meshtastic/telemetry.options b/meshtastic/telemetry.options index 81d2aa8..959292e 100644 --- a/meshtastic/telemetry.options +++ b/meshtastic/telemetry.options @@ -1,6 +1,7 @@ # options for nanopb # https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options +*EnvironmentMetrics.ds18b20_readings max_count:16 *EnvironmentMetrics.iaq int_size:16 *EnvironmentMetrics.wind_direction int_size:16 *EnvironmentMetrics.soil_moisture int_size:8 diff --git a/meshtastic/telemetry.proto b/meshtastic/telemetry.proto index bd27a7b..9c3b960 100644 --- a/meshtastic/telemetry.proto +++ b/meshtastic/telemetry.proto @@ -153,6 +153,26 @@ message EnvironmentMetrics { * Soil temperature measured (*C) */ optional float soil_temperature = 22; + + /* + * DS18B20 1-Wire temperature sensor readings + */ + repeated DS18B20Reading ds18b20_readings = 23; +} + +/* + * A single DS18B20 1-Wire temperature sensor reading with its unique ROM code + */ +message DS18B20Reading { + /* + * 32-bit FNV-1a hash of the 64-bit 1-Wire ROM code — stable, compact identifier per sensor + */ + fixed32 device_id = 1; + + /* + * Temperature in degrees Celsius + */ + float temperature = 2; } /* @@ -871,6 +891,11 @@ enum TelemetrySensorType { * SHT family of sensors for temperature and humidity */ SHTXX = 50; + + /* + * Dallas/Maxim DS18B20 1-Wire digital thermometer + */ + DS18B20 = 51; } /*