mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-13 11:44:29 +05:00
refactor: improved NTC polling
This commit is contained in:
@@ -382,13 +382,13 @@ protected:
|
|||||||
const auto value = analogRead(sSensor.gpio) / 1023 * DEFAULT_NTC_VREF;
|
const auto value = analogRead(sSensor.gpio) / 1023 * DEFAULT_NTC_VREF;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (value < DEFAULT_NTC_VLOW_TRESHOLD) {
|
if (value < DEFAULT_NTC_VLOW_TRESHOLD || value > DEFAULT_NTC_VHIGH_TRESHOLD) {
|
||||||
if (Sensors::getConnectionStatusById(sensorId)) {
|
if (Sensors::getConnectionStatusById(sensorId)) {
|
||||||
Sensors::setConnectionStatusById(sensorId, false, false);
|
Sensors::setConnectionStatusById(sensorId, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.swarningln(
|
Log.swarningln(
|
||||||
FPSTR(L_SENSORS_NTC), F("GPIO %hhu, sensor #%hhu '%s', voltage too low: %.2f"),
|
FPSTR(L_SENSORS_NTC), F("GPIO %hhu, sensor #%hhu '%s', voltage is out of threshold: %.3f"),
|
||||||
sSensor.gpio, sensorId, sSensor.name, (value / 1000.0f)
|
sSensor.gpio, sensorId, sSensor.name, (value / 1000.0f)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#define DEFAULT_NTC_BETA_FACTOR 3950.0f
|
#define DEFAULT_NTC_BETA_FACTOR 3950.0f
|
||||||
#define DEFAULT_NTC_VREF 3300.0f
|
#define DEFAULT_NTC_VREF 3300.0f
|
||||||
#define DEFAULT_NTC_VLOW_TRESHOLD 25.0f
|
#define DEFAULT_NTC_VLOW_TRESHOLD 25.0f
|
||||||
|
#define DEFAULT_NTC_VHIGH_TRESHOLD 3298.0f
|
||||||
|
|
||||||
#ifndef BUILD_VERSION
|
#ifndef BUILD_VERSION
|
||||||
#define BUILD_VERSION "0.0.0"
|
#define BUILD_VERSION "0.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user