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