1-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. | |
int16_t | readTemperature (const uint8_t idx) const |
Reads the temperature of a specific sensor. | |
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 conditional< TEMP_SENSOR_PRESENT, OneWire, MockOneWire >::type | 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 105 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 135 of file utils_temp.h.
References sensorAddrs, and sensorPin.
|
inlineconstexpr |
Get the pin of the sensor(s).
This method returns the pin number where the temperature sensors are connected.
Definition at line 202 of file utils_temp.h.
References sensorPin.
|
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 190 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 173 of file utils_temp.h.
References oneWire, requestTemperatures(), sensorPin, and TEMP_SENSOR_PRESENT.
|
inlinenodiscard |
Reads the temperature of a specific sensor.
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.
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 223 of file utils_temp.h.
References DEVICE_DISCONNECTED_RAW, oneWire, OUTOFRANGE_TEMPERATURE, READ_SCRATCHPAD, sensorAddrs, TEMP_RANGE_HIGH, and TEMP_SENSOR_PRESENT.
|
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 151 of file utils_temp.h.
References CONVERT_TEMPERATURE, oneWire, and TEMP_SENSOR_PRESENT.
Referenced by initTemperatureSensors().
|
inlinestaticprivate |
For temperature sensing
Definition at line 267 of file utils_temp.h.
Referenced by initTemperatureSensors(), readTemperature(), and requestTemperatures().
|
private |
Array of sensors
Definition at line 265 of file utils_temp.h.
Referenced by TemperatureSensing(), and readTemperature().
|
private |
The pin of the sensor(s)
Definition at line 263 of file utils_temp.h.
Referenced by TemperatureSensing(), get_pin(), and initTemperatureSensors().