Aquarium Cooling Controller
ESP32 firmware for aquarium cooling fan control, monitoring, telemetry, and fault handling.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SensorManager Class Reference

Discovers and samples DS18B20-compatible sensors on a OneWire bus. More...

#include <sensor_manager.h>

Public Member Functions

 SensorManager (const SensorManagerConfig &config)
 Creates a sensor manager for the supplied OneWire configuration.
 
bool begin (uint32_t nowMs)
 Initializes the bus, discovers sensors, and requests the first conversion.
 
void update (uint32_t nowMs)
 Advances discovery and temperature conversion state.
 
const SensorSnapshotsnapshot () const
 Returns the latest sensor snapshot.
 
void formatTrackedAddress (size_t trackedIndex, char *buffer, size_t bufferSize) const
 Formats a tracked sensor ROM code as a hexadecimal string.
 

Detailed Description

Discovers and samples DS18B20-compatible sensors on a OneWire bus.

The class performs discovery, starts conversions, and later collects results once the conversion time for the selected resolution has elapsed. This avoids blocking the controller loop while still keeping tracked sensor roles stable.

Constructor & Destructor Documentation

◆ SensorManager()

SensorManager::SensorManager ( const SensorManagerConfig config)
explicit

Creates a sensor manager for the supplied OneWire configuration.

Parameters
configBus pin, sampling interval, resolution, and tracked sensors.

Member Function Documentation

◆ begin()

bool SensorManager::begin ( uint32_t  nowMs)

Initializes the bus, discovers sensors, and requests the first conversion.

Parameters
nowMsCurrent monotonic timestamp in milliseconds.
Returns
True when bus initialization completed.

◆ formatTrackedAddress()

void SensorManager::formatTrackedAddress ( size_t  trackedIndex,
char *  buffer,
size_t  bufferSize 
) const

Formats a tracked sensor ROM code as a hexadecimal string.

Parameters
trackedIndexIndex into the tracked sensor array.
bufferDestination character buffer.
bufferSizeSize of the destination buffer in bytes.

◆ snapshot()

const SensorSnapshot & SensorManager::snapshot ( ) const

Returns the latest sensor snapshot.

Returns
Immutable snapshot reference.

◆ update()

void SensorManager::update ( uint32_t  nowMs)

Advances discovery and temperature conversion state.

Call this frequently from the main loop. It will request a new conversion when the sample interval elapses and will finish pending conversions once the DS18B20 conversion time has passed.

Parameters
nowMsCurrent monotonic timestamp in milliseconds.

The documentation for this class was generated from the following files: