|
3-phase PV router
|
Implements temperature sensing functionality for multiple sensors. More...
#include <utils_temp.h>


Public Member Functions | |
| constexpr | TempSensors (const TemperatureSensing< N > &sensors) |
| The sensors of config.h. | |
| int16_t | endRead () const |
| CLOSE, the last transaction: a reset (the sensor still there?), the reading decoded. | |
| void | initTemperatureSensors () const |
| Initialize the Dallas temperature sensors. | |
| void | printSensorsOnBus () const |
| Lists the sensors on the bus, with their ROM codes as config.h takes them. | |
| void | readScratchpad (const uint8_t idx) const |
| READ, the second transaction: the second half of the ROM code, Read Scratchpad, the 9 bytes of the scratchpad. | |
| template<uint8_t IDX> | |
| int16_t | readTemperature () const |
| Read temperature from a specific sensor (compile-time bounds checking). | |
| int16_t | readTemperature (const uint8_t idx) const |
| Reads the temperature of a specific sensor (runtime bounds checking). | |
| void | requestTemperatures () const |
| Request temperature conversion for all sensors. | |
| bool | startRead (const uint8_t idx) const |
| ADDRESS, the first transaction of a sensor's read: reset, Match ROM, the first half of its ROM code. | |
Public Member Functions inherited from TemperatureSensing< N > | |
| constexpr | TemperatureSensing ()=delete |
| constexpr | TemperatureSensing (const uint8_t pin, const DeviceAddress(&ref)[N]) |
The sensors on pin, from their addresses. | |
| constexpr uint8_t | get_pin () const |
| The pin of the bus. | |
| constexpr uint8_t | size () const |
| Number of sensors. | |
Private Member Functions | |
| bool | isConfigured (const DeviceAddress &device) const |
| Whether config.h lists this sensor. | |
Static Private Attributes | |
| static constexpr uint8_t | MATCH_ROM { 0x55 } |
| static OneWireType | oneWire |
| static constexpr uint8_t | ROM_HALF { 4 } |
| static DS18B20::ScratchPad | scratchPad |
Additional Inherited Members | |
Protected Attributes inherited from TemperatureSensing< N > | |
| const DeviceAddress | sensorAddrs [N] |
| const uint8_t | sensorPin { unused_pin } |
Implements temperature sensing functionality for multiple sensors.
The TempSensors class reads the sensors of config.h (its base, TemperatureSensing). It manages temperature sensors connected via the OneWire bus. It supports initialization, temperature reading, and error handling for multiple sensors.
| N | The number of sensors connected to the system. |
TEMP_SENSOR_PRESENT selects the real OneWire bus or a mock. Definition at line 96 of file utils_temp.h.
|
inlineexplicitconstexpr |
The sensors of config.h.
| sensors | The pin of the bus and the address of each sensor, as in config.h. |
Definition at line 107 of file utils_temp.h.

|
inlinenodiscard |
CLOSE, the last transaction: a reset (the sensor still there?), the reading decoded.
DEVICE_DISCONNECTED_RAW if the sensor is disconnected or CRC validation fails. Returns OUTOFRANGE_TEMPERATURE if the temperature is out of the defined range. Definition at line 276 of file utils_temp.h.


|
inline |
Initialize the Dallas temperature sensors.
Initializes the OneWire bus on the sensor pin. The first conversion is requested by the main loop, at the first mains cycle (temp_schedule.h), like every other one. Call it during system initialization.
Definition at line 205 of file utils_temp.h.
|
inlineprivate |
Whether config.h lists this sensor.
Definition at line 341 of file utils_temp.h.

|
inline |
Lists the sensors on the bus, with their ROM codes as config.h takes them.
Calibration mode only (CALIBRATION_MODE), with temperature sensing: to find the codes to put in config.h, or to check them. Each code says whether config.h has it. The OneWire library is built without its search (-DONEWIRE_SEARCH=0, platformio.ini): RomSearch (onewire_search.h) does it here, with its state on the stack.
Definition at line 141 of file utils_temp.h.

|
inline |
READ, the second transaction: the second half of the ROM code, Read Scratchpad, the 9 bytes of the scratchpad.
| idx | The index of the sensor, as for startRead() |
Definition at line 248 of file utils_temp.h.

|
inlinenodiscard |
Read temperature from a specific sensor (compile-time bounds checking).
This template version provides compile-time bounds checking for constant sensor indices. Use this version when the sensor index is known at compile time for better safety.
| IDX | The sensor index (must be < N) |
DEVICE_DISCONNECTED_RAW if the sensor is disconnected or CRC validation fails. Returns OUTOFRANGE_TEMPERATURE if the temperature is out of the defined range. Definition at line 304 of file utils_temp.h.


|
inlinenodiscard |
Reads the temperature of a specific sensor (runtime bounds checking).
This method reads the temperature data from a specific sensor connected to the OneWire bus. It validates the data using CRC and ensures the temperature is within the acceptable range. Includes runtime bounds checking for safety when the index is not known at compile time.
| idx | The index of the sensor to read. |
DEVICE_DISCONNECTED_RAW if the sensor is disconnected or CRC validation fails. Returns OUTOFRANGE_TEMPERATURE if the temperature is out of the defined range.Definition at line 329 of file utils_temp.h.

|
inline |
Request temperature conversion for all sensors.
This method sends a command to all sensors on the OneWire bus to start temperature conversion. It ensures that all connected sensors begin measuring their respective temperatures.
CONVERT_TEMPERATURE command to initiate temperature conversion.Definition at line 123 of file utils_temp.h.
|
inlinenodiscard |
ADDRESS, the first transaction of a sensor's read: reset, Match ROM, the first half of its ROM code.
| idx | The index of the sensor |
Definition at line 220 of file utils_temp.h.

|
staticconstexprprivate |
the ROM command that addresses one sensor
Definition at line 353 of file utils_temp.h.
|
inlinestaticprivate |
For temperature sensing
Definition at line 356 of file utils_temp.h.
|
staticconstexprprivate |
the bytes of the ROM code written by startRead()
Definition at line 354 of file utils_temp.h.
|
inlinestaticprivate |
the scratchpad of the sensor being read
Definition at line 357 of file utils_temp.h.