read 1-Wire again if error occurred
This commit is contained in:
parent
03fe849fec
commit
1fb4b4b0e4
@ -7,6 +7,7 @@
|
||||
#include "inputs.h"
|
||||
|
||||
#define MAX_DN18B20_SENSORS 4U
|
||||
#define ONE_WIRE_LOOPS 2U // try to read the 1-Wire sensors that often
|
||||
#define PERIODIC_INTERVAL 1U // read and compute the inputs every 1sec
|
||||
|
||||
static const char *TAG = "smart-oil-heater-control-system-inputs";
|
||||
@ -157,42 +158,46 @@ void taskInput(void *pvParameters)
|
||||
ESP_LOGW(TAG, "More 1-Wire devices found than expected!");
|
||||
}
|
||||
|
||||
if (ds18x20_measure_and_read_multi(uDS18B20Pin, uOneWireAddresses, sSensorCount, fDS18B20Temps) != ESP_OK)
|
||||
for (size_t iReadLoop = 0; iReadLoop < ONE_WIRE_LOOPS; iReadLoop++)
|
||||
{
|
||||
ESP_LOGE(TAG, "1-Wire devices read error");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < sSensorCount; j++)
|
||||
if (ds18x20_measure_and_read_multi(uDS18B20Pin, uOneWireAddresses, sSensorCount, fDS18B20Temps) != ESP_OK)
|
||||
{
|
||||
float temp_c = fDS18B20Temps[j];
|
||||
ESP_LOGI(TAG, "Sensor: %08" PRIx64 " reports %lf°C", (uint64_t)uOneWireAddresses[j], temp_c);
|
||||
|
||||
switch ((uint64_t)uOneWireAddresses[j])
|
||||
ESP_LOGE(TAG, "1-Wire devices read error");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < sSensorCount; j++)
|
||||
{
|
||||
case ((uint64_t)uChamperTempSensorAddr):
|
||||
sChamperTemperature.fCurrentValue = temp_c;
|
||||
sChamperTemperature.state = MEASUREMENT_NO_ERROR;
|
||||
updateAverage(&sChamperTemperature);
|
||||
break;
|
||||
case ((uint64_t)uOutdoorTempSensorAddr):
|
||||
sOutdoorTemperature.fCurrentValue = temp_c;
|
||||
sOutdoorTemperature.state = MEASUREMENT_NO_ERROR;
|
||||
updateAverage(&sOutdoorTemperature);
|
||||
break;
|
||||
case ((uint64_t)uInletFlowTempSensorAddr):
|
||||
sInletFlowTemperature.fCurrentValue = temp_c;
|
||||
sInletFlowTemperature.state = MEASUREMENT_NO_ERROR;
|
||||
updateAverage(&sInletFlowTemperature);
|
||||
break;
|
||||
case ((uint64_t)uReturnFlowTempSensorAddr):
|
||||
sReturnFlowTemperature.fCurrentValue = temp_c;
|
||||
sReturnFlowTemperature.state = MEASUREMENT_NO_ERROR;
|
||||
updateAverage(&sReturnFlowTemperature);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
float temp_c = fDS18B20Temps[j];
|
||||
ESP_LOGI(TAG, "Sensor: %08" PRIx64 " reports %lf°C", (uint64_t)uOneWireAddresses[j], temp_c);
|
||||
|
||||
switch ((uint64_t)uOneWireAddresses[j])
|
||||
{
|
||||
case ((uint64_t)uChamperTempSensorAddr):
|
||||
sChamperTemperature.fCurrentValue = temp_c;
|
||||
sChamperTemperature.state = MEASUREMENT_NO_ERROR;
|
||||
updateAverage(&sChamperTemperature);
|
||||
break;
|
||||
case ((uint64_t)uOutdoorTempSensorAddr):
|
||||
sOutdoorTemperature.fCurrentValue = temp_c;
|
||||
sOutdoorTemperature.state = MEASUREMENT_NO_ERROR;
|
||||
updateAverage(&sOutdoorTemperature);
|
||||
break;
|
||||
case ((uint64_t)uInletFlowTempSensorAddr):
|
||||
sInletFlowTemperature.fCurrentValue = temp_c;
|
||||
sInletFlowTemperature.state = MEASUREMENT_NO_ERROR;
|
||||
updateAverage(&sInletFlowTemperature);
|
||||
break;
|
||||
case ((uint64_t)uReturnFlowTempSensorAddr):
|
||||
sReturnFlowTemperature.fCurrentValue = temp_c;
|
||||
sReturnFlowTemperature.state = MEASUREMENT_NO_ERROR;
|
||||
updateAverage(&sReturnFlowTemperature);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user