Check values before publishing water stuff
This commit is contained in:
parent
2d91f91290
commit
c448960415
@ -69,7 +69,6 @@ void Plant::clearMoisture(void){
|
|||||||
void Plant::addSenseValue(void)
|
void Plant::addSenseValue(void)
|
||||||
{
|
{
|
||||||
int raw = analogRead(this->mPinSensor);
|
int raw = analogRead(this->mPinSensor);
|
||||||
Serial << "plant bla " << raw << endl;
|
|
||||||
if(raw < MOIST_SENSOR_MAX_ADC && raw > MOIST_SENSOR_MIN_ADC){
|
if(raw < MOIST_SENSOR_MAX_ADC && raw > MOIST_SENSOR_MIN_ADC){
|
||||||
this->moistureRaw.add(raw);
|
this->moistureRaw.add(raw);
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,6 @@ void setup()
|
|||||||
waterSensorAddr.setDefaultValue("");
|
waterSensorAddr.setDefaultValue("");
|
||||||
Homie.setLoopFunction(homieLoop);
|
Homie.setLoopFunction(homieLoop);
|
||||||
Homie.onEvent(onHomieEvent);
|
Homie.onEvent(onHomieEvent);
|
||||||
//Homie.disableLogging();
|
|
||||||
|
|
||||||
Homie.setup();
|
Homie.setup();
|
||||||
|
|
||||||
@ -814,8 +813,13 @@ void plantcontrol()
|
|||||||
|
|
||||||
if (mAliveWasRead)
|
if (mAliveWasRead)
|
||||||
{
|
{
|
||||||
sensorWater.setProperty("remaining").send(String(waterLevelMax.get() - waterRawSensor.getAverage()));
|
float remaining = waterLevelMax.get() - waterRawSensor.getAverage();
|
||||||
|
if (! isnan(remaining)) {
|
||||||
|
sensorWater.setProperty("remaining").send(String(remaining));
|
||||||
|
}
|
||||||
|
if (! isnan(waterRawSensor.getAverage())) {
|
||||||
sensorWater.setProperty("distance").send(String(waterRawSensor.getAverage()));
|
sensorWater.setProperty("distance").send(String(waterRawSensor.getAverage()));
|
||||||
|
}
|
||||||
sensorLipo.setProperty("percent").send(String(100 * batteryVoltage / VOLT_MAX_BATT));
|
sensorLipo.setProperty("percent").send(String(100 * batteryVoltage / VOLT_MAX_BATT));
|
||||||
sensorLipo.setProperty("volt").send(String(batteryVoltage));
|
sensorLipo.setProperty("volt").send(String(batteryVoltage));
|
||||||
sensorLipo.setProperty("current").send(String(battery.getCurrent()));
|
sensorLipo.setProperty("current").send(String(battery.getCurrent()));
|
||||||
|
Loading…
Reference in New Issue
Block a user