14#include <DallasTemperature.h>
119 bool begin(uint32_t nowMs);
130 void update(uint32_t nowMs);
148 size_t bufferSize)
const;
151 static uint32_t conversionTimeMsForResolution(uint8_t resolutionBits);
153 bool discoverSensors(uint32_t nowMs);
154 void startConversion(uint32_t nowMs);
155 void finishConversion(uint32_t nowMs);
156 void clearTrackedSensor(
size_t trackedIndex);
157 void clearDiscoveredSensors();
158 int findDiscoveredIndexByAddress(
const uint8_t address[8])
const;
162 DallasTemperature sensors_;
165 uint32_t conversionReadyAtMs_;
Discovers and samples DS18B20-compatible sensors on a OneWire bus.
Definition sensor_manager.h:104
void update(uint32_t nowMs)
Advances discovery and temperature conversion state.
Definition sensor_manager.cpp:45
bool begin(uint32_t nowMs)
Initializes the bus, discovers sensors, and requests the first conversion.
Definition sensor_manager.cpp:29
const SensorSnapshot & snapshot() const
Returns the latest sensor snapshot.
Definition sensor_manager.cpp:81
void formatTrackedAddress(size_t trackedIndex, char *buffer, size_t bufferSize) const
Formats a tracked sensor ROM code as a hexadecimal string.
Definition sensor_manager.cpp:85
constexpr size_t kMaxDiscoveredSensors
Maximum discovered OneWire devices retained for diagnostics.
Definition sensor_manager.h:18
constexpr size_t kMaxTrackedSensors
Number of named sensors used by control logic.
Definition sensor_manager.h:17
Diagnostic data for one discovered OneWire sensor.
Definition sensor_manager.h:57
bool present
True when this entry contains a discovered device.
Definition sensor_manager.h:58
bool externallyPowered
True when the device reports external power.
Definition sensor_manager.h:60
bool assigned
True when this device is assigned to a tracked sensor.
Definition sensor_manager.h:59
uint8_t romCode[8]
OneWire ROM code for the discovered device.
Definition sensor_manager.h:61
OneWire bus and temperature sampling configuration.
Definition sensor_manager.h:71
uint32_t sampleIntervalMs
Interval between conversion requests.
Definition sensor_manager.h:73
TrackedSensorConfig trackedSensors[kMaxTrackedSensors]
Named sensor configuration.
Definition sensor_manager.h:76
size_t trackedSensorCount
Number of configured tracked sensors.
Definition sensor_manager.h:75
uint8_t resolutionBits
DS18B20 resolution in bits.
Definition sensor_manager.h:74
uint8_t oneWirePin
GPIO used for the OneWire bus.
Definition sensor_manager.h:72
Complete OneWire bus and sensor state snapshot.
Definition sensor_manager.h:86
bool busInitialized
True after the OneWire bus is initialized.
Definition sensor_manager.h:87
bool conversionPending
True while waiting for a temperature conversion.
Definition sensor_manager.h:89
DiscoveredSensorSnapshot discoveredSensors[kMaxDiscoveredSensors]
Diagnostic discovery list.
Definition sensor_manager.h:94
uint32_t lastDiscoveryMs
Timestamp of the last discovery pass.
Definition sensor_manager.h:91
TrackedSensorSnapshot trackedSensors[kMaxTrackedSensors]
State for named sensors.
Definition sensor_manager.h:93
uint32_t lastRequestMs
Timestamp of the last conversion request.
Definition sensor_manager.h:92
bool presenceDetected
True when at least one device is present.
Definition sensor_manager.h:88
uint8_t discoveredSensorCount
Number of devices found during discovery.
Definition sensor_manager.h:90
Configuration for one named temperature sensor.
Definition sensor_manager.h:28
const char * sensorLabel
Human-readable label for diagnostics.
Definition sensor_manager.h:31
uint8_t preferredAddress[8]
Expected OneWire ROM code for this sensor.
Definition sensor_manager.h:30
bool hasPreferredAddress
True when preferredAddress should be matched.
Definition sensor_manager.h:29
Latest sample and identity data for one tracked sensor.
Definition sensor_manager.h:41
uint32_t lastSampleMs
Timestamp of the last valid sample.
Definition sensor_manager.h:47
bool externallyPowered
True when the device reports external power.
Definition sensor_manager.h:45
uint8_t romCode[8]
OneWire ROM code assigned to this sensor.
Definition sensor_manager.h:48
bool addressKnown
True when romCode contains a discovered address.
Definition sensor_manager.h:43
bool configuredAddressMatched
True when the preferred ROM code was found.
Definition sensor_manager.h:42
bool sampleValid
True when temperatureC is usable.
Definition sensor_manager.h:44
float temperatureC
Last sampled temperature in degrees Celsius.
Definition sensor_manager.h:46