Add messages on failed 1wire sensors

This commit is contained in:
Ollo 2025-05-03 15:37:10 +02:00
parent cf1f631e07
commit 1190b0324e
3 changed files with 26 additions and 15 deletions

View File

@ -127,7 +127,7 @@
#define FIRMWARE_BASENAME "PlantControl"
#define FIRMWARE_NAME FIRMWARE_BASENAME FIRMWARE_FEATURE1 FIRMWARE_FEATURE2
#define FIRMWARE_VERSIONNMUMBER "3.014"
#define FIRMWARE_VERSIONNMUMBER "3.020"
#ifdef HWREVISION07
#define FIRMWARE_VERSION FIRMWARE_VERSIONNMUMBER " HW0.7"
@ -170,7 +170,7 @@
#define TEMPERATUR_TIMEOUT 3000 /**< 3 Seconds timeout for the temperatures sensors */
#define WATERSENSOR_TIMEOUT 3000 /**< 3 Seconds timeout for the water distance sensor */
#define WATERSENSOR_CYCLE 3 /**< 5 sensor measurement are performed */
#define WATERSENSOR_CYCLE 10 /**< 10 sensor measurement are performed */
#define DS18B20_RESOLUTION 9 /**< 9bit temperature resolution -> 0.5°C steps */
#define UTC_OFFSET_DE 3600 /* UTC offset in seconds for Germany */

View File

@ -25,7 +25,8 @@
#define LOG_SENSORMODE_UNKNOWN "Unknown sensor mode requested"
#define LOG_SENSORMODE_UNKNOWN_CODE -5
#define LOG_SENSOR_MISSING -6
#define LOG_SENSOR_MISSING_ERROR_MESSAGE "1Wire: sensors found"
#define LOG_SENSOR_MISSING_ERROR_CODE -6
#define LOG_PUMP_AND_DOWNLOADMODE "Download mode, ignoring pump request"
#define LOG_PUMP_AND_DOWNLOADMODE_CODE 2

View File

@ -381,7 +381,7 @@ void readPowerSwitchedSensors()
int value = analogRead(SENSOR_TANK_ANALOG);
Serial << "Round " << i << " measurement: " << value << " mV " << endl;
waterRawSensor.add(value);
delay(5);
delay(7);
}
Serial << "Analog water measurement done" << endl;
#else
@ -1114,18 +1114,28 @@ void plantcontrol()
sensorLipo.setProperty("percent").send(String(100 * (((mBatteryVoltage - VOLT_MIN_BATT) / (VOLT_MAX_BATT - VOLT_MIN_BATT)))));
}
sensorLipo.setProperty("volt").send(String(mBatteryVoltage));
sensorLipo.setProperty("current").send(String(battery.getCurrent()));
sensorLipo.setProperty("Ah").send(String(battery.getAh()));
sensorLipo.setProperty("ICA").send(String(battery.getICA()));
sensorLipo.setProperty("DCA").send(String(battery.getDCA()));
sensorLipo.setProperty("CCA").send(String(battery.getCCA()));
if (mSolarVoltage < SOLAR_MAX_VOLTAGE_POSSIBLE) {
sensorSolar.setProperty("volt").send(String(mSolarVoltage));
if (battery.isFound()) {
sensorLipo.setProperty("volt").send(String(mBatteryVoltage));
sensorLipo.setProperty("current").send(String(battery.getCurrent()));
sensorLipo.setProperty("Ah").send(String(battery.getAh()));
sensorLipo.setProperty("ICA").send(String(battery.getICA()));
sensorLipo.setProperty("DCA").send(String(battery.getDCA()));
sensorLipo.setProperty("CCA").send(String(battery.getCCA()));
if (mSolarVoltage < SOLAR_MAX_VOLTAGE_POSSIBLE) {
sensorSolar.setProperty("volt").send(String(mSolarVoltage));
} else {
log(LOG_LEVEL_INFO, String("Ignore unrealistc sun voltage" + String(mSolarVoltage) +"V"), LOG_SOLAR_CHARGER_MISSING);
}
sensorTemp.setProperty(TEMPERATUR_SENSOR_CHIP).send(String(chipTemp));
} else {
log(LOG_LEVEL_INFO, String("Ignore unrealistc sun voltage" + String(mSolarVoltage) +"V"), LOG_SOLAR_CHARGER_MISSING);
log(LOG_LEVEL_ERROR, String("No battery or sun sensor found"), LOG_SOLAR_CHARGER_MISSING);
}
sensorTemp.setProperty(TEMPERATUR_SENSOR_CHIP).send(String(chipTemp));
/* Publish 1-wire sensor status on failure */
if (sensors.getDS18Count() <= 1) {
log(LOG_LEVEL_ERROR, String("Found " + String(sensors.getDS18Count()) + " DS18B20 sensors"), LOG_SENSOR_MISSING_ERROR_CODE);
}
}
else
{
@ -1145,7 +1155,7 @@ bool isLowLight = (mSolarVoltage <= SOLAR_CHARGE_MIN_VOLTAGE);
#endif // TIMED_LIGHT_PIN
bool isLiquid = waterTemp > 5;
bool isLiquid = (waterTemp > 5.0f);
bool hasWater = true; // By default activate the pump
if (waterRawSensor.getCount() > 0)
{