3-phase PV router
|
Implements temperature sensing functionality for multiple sensors. More...
#include <utils_temp.h>
Public Member Functions | |
constexpr | TemperatureSensing ()=delete |
constexpr | TemperatureSensing (uint8_t pin, const DeviceAddress(&ref)[N]) |
Construct a new Temperature Sensing object. | |
constexpr auto | get_pin () const |
Get the pin of the sensor(s). | |
constexpr auto | get_size () const |
Get the number of sensors. | |
void | initTemperatureSensors () const |
Initialize the Dallas temperature sensors. | |
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. | |
Private Types | |
using | ScratchPad = uint8_t[9] |
Represents a buffer for storing sensor data. | |
Private Attributes | |
const DeviceAddress | sensorAddrs [N] |
const uint8_t | sensorPin { unused_pin } |
Static Private Attributes | |
static OneWireType | oneWire |
Implements temperature sensing functionality for multiple sensors.
The TemperatureSensing
class 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_ENABLED
to include or exclude temperature sensing features. Definition at line 111 of file utils_temp.h.
|
constexprdelete |
|
inlineconstexpr |
Construct a new Temperature Sensing object.
This constructor initializes the TemperatureSensing
object with the specified pin and a list of device addresses for the connected temperature sensors.
N | The number of sensors connected to the system. |
pin | The pin number where the temperature sensors are connected. |
ref | A reference to an array of DeviceAddress objects representing the addresses of the sensors. |
Definition at line 141 of file utils_temp.h.
|
inlineconstexpr |
Get the pin of the sensor(s).
This method returns the pin number where the temperature sensors are connected.
Definition at line 208 of file utils_temp.h.
|
inlineconstexpr |
Get the number of sensors.
This method returns the number of temperature sensors connected to the system. It provides a compile-time constant value representing the total number of sensors.
Definition at line 196 of file utils_temp.h.
|
inline |
Initialize the Dallas temperature sensors.
This method initializes the OneWire bus and sends a request to all connected sensors to start temperature conversion. It ensures that the sensors are ready for temperature readings.
CONVERT_TEMPERATURE
command to all sensors on the bus.Definition at line 179 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 225 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 248 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 157 of file utils_temp.h.
|
inlinestaticprivate |
For temperature sensing
Definition at line 297 of file utils_temp.h.
|
private |
Array of sensors
Definition at line 295 of file utils_temp.h.
|
private |
The pin of the sensor(s)
Definition at line 293 of file utils_temp.h.