Module ds18b20

Source
Expand description

Contains the functionality for reading from DS18B20 sensor Manages temperature reading from DS18B20 1-Wire digital thermometers.

This module provides the Ds18b20 struct, which is designed to run as a dedicated thread. It interfaces with the Linux 1-Wire subsystem via sysfs to periodically read temperature data from one or more configured sensors.

§Responsibilities

  1. Configuration Validation: The new() constructor performs rigorous checks on the provided configuration, ensuring that all necessary paths are specified and that sensor IDs are unique and valid before the thread starts.
  2. Periodic Measurement: The execute() loop periodically reads sensor data based on the measurement_pause_duration_millis setting in the configuration.
  3. Robust Reading: It implements a retry mechanism with a configurable pause to handle transient CRC errors or other temporary read failures common on the 1-Wire bus.
  4. State Sharing: It updates shared Arc<Mutex<Ds18b20Result>> containers with the latest water and ambient temperature readings, making the data available to other parts of the application in a thread-safe manner.
  5. Graceful Shutdown: The execute() loop is responsive to a Quit command received from the main signal handler, allowing the thread to terminate cleanly.
  6. Performance Monitoring: It includes logic to detect and log warnings if access to the shared mutexes is blocked for longer than a predefined threshold.

Modules§

ds18b20_constants 🔒

Structs§

Ds18b20
Represents a Ds18b20 sensor module responsible for reading temperature signals.
Ds18b20ResultData

Type Aliases§

Ds18b20Result