Used distance reading time to stabilize temperature sensors
This commit is contained in:
parent
6f5c5536cc
commit
bd5fc9839f
@ -46,7 +46,7 @@
|
|||||||
/** \addtogroup Configuration
|
/** \addtogroup Configuration
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define FIRMWARE_VERSION "1.0.9"
|
#define FIRMWARE_VERSION "1.0.10"
|
||||||
|
|
||||||
#define ADC_TO_VOLT(adc) ((adc) * 3.3 ) / 4095)
|
#define ADC_TO_VOLT(adc) ((adc) * 3.3 ) / 4095)
|
||||||
#define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc)*3.3 * (multi)) / 4095)
|
#define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc)*3.3 * (multi)) / 4095)
|
||||||
|
@ -437,6 +437,9 @@ void readDistance()
|
|||||||
bool readSensors()
|
bool readSensors()
|
||||||
{
|
{
|
||||||
bool leaveMode1 = false;
|
bool leaveMode1 = false;
|
||||||
|
int sensorCount = 0;
|
||||||
|
int timeoutTemp = millis() + 2000;
|
||||||
|
|
||||||
Serial << "Read Sensors" << endl;
|
Serial << "Read Sensors" << endl;
|
||||||
|
|
||||||
readSystemSensors();
|
readSystemSensors();
|
||||||
@ -456,6 +459,7 @@ bool readSensors()
|
|||||||
}
|
}
|
||||||
delay(10);
|
delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAX_PLANTS; i++)
|
for (int i = 0; i < MAX_PLANTS; i++)
|
||||||
{
|
{
|
||||||
long current = mPlants[i].getCurrentMoisture();
|
long current = mPlants[i].getCurrentMoisture();
|
||||||
@ -486,10 +490,6 @@ bool readSensors()
|
|||||||
rtcLastBatteryVoltage = getBatteryVoltage();
|
rtcLastBatteryVoltage = getBatteryVoltage();
|
||||||
rtcLastSolarVoltage = getSolarVoltage();
|
rtcLastSolarVoltage = getSolarVoltage();
|
||||||
|
|
||||||
readDistance();
|
|
||||||
Serial << "Distance sensor " << waterRawSensor.getAverage() << " cm" << endl;
|
|
||||||
int sensorCount = 0;
|
|
||||||
int timeoutTemp = millis() + 2000;
|
|
||||||
while (sensorCount == 0 && millis() < timeoutTemp)
|
while (sensorCount == 0 && millis() < timeoutTemp)
|
||||||
{
|
{
|
||||||
sensors.begin();
|
sensors.begin();
|
||||||
@ -498,8 +498,16 @@ bool readSensors()
|
|||||||
delay(200);
|
delay(200);
|
||||||
}
|
}
|
||||||
Serial << "One wire count: " << sensorCount << endl;
|
Serial << "One wire count: " << sensorCount << endl;
|
||||||
|
/* Measure temperature */
|
||||||
if (sensorCount > 0)
|
if (sensorCount > 0)
|
||||||
{
|
{
|
||||||
|
sensors.requestTemperatures();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the distance and give the temperature sensors some time */
|
||||||
|
readDistance();
|
||||||
|
Serial << "Distance sensor " << waterRawSensor.getAverage() << " cm" << endl;
|
||||||
|
|
||||||
/* Required to read the temperature once */
|
/* Required to read the temperature once */
|
||||||
int readAgain = 5;
|
int readAgain = 5;
|
||||||
while (readAgain > 0)
|
while (readAgain > 0)
|
||||||
@ -527,20 +535,6 @@ bool readSensors()
|
|||||||
Serial << "waterTempCurrent: " << temp2Raw << endl;
|
Serial << "waterTempCurrent: " << temp2Raw << endl;
|
||||||
waterTempSensor.add(temp2Raw);
|
waterTempSensor.add(temp2Raw);
|
||||||
}
|
}
|
||||||
if ((lipoTempSensor.getAverage() - rtcLastLipoTemp > TEMPERATURE_DELTA_TRIGGER_IN_C) ||
|
|
||||||
(rtcLastLipoTemp - lipoTempSensor.getAverage() > TEMPERATURE_DELTA_TRIGGER_IN_C))
|
|
||||||
{
|
|
||||||
leaveMode1 = true;
|
|
||||||
}
|
|
||||||
if ((waterTempSensor.getAverage() - rtcLastWaterTemp > TEMPERATURE_DELTA_TRIGGER_IN_C) ||
|
|
||||||
(rtcLastWaterTemp - waterTempSensor.getAverage() > TEMPERATURE_DELTA_TRIGGER_IN_C))
|
|
||||||
{
|
|
||||||
leaveMode1 = true;
|
|
||||||
}
|
|
||||||
if (!leaveMode1)
|
|
||||||
{
|
|
||||||
readAgain = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
readAgain--;
|
readAgain--;
|
||||||
delay(50);
|
delay(50);
|
||||||
@ -549,7 +543,6 @@ bool readSensors()
|
|||||||
{
|
{
|
||||||
Serial << "OnwWire sensor " << i << " has value " << sensors.getTempCByIndex(i) << endl;
|
Serial << "OnwWire sensor " << i << " has value " << sensors.getTempCByIndex(i) << endl;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (abs(lipoTempSensor.getAverage() - rtcLastLipoTemp) > TEMPERATURE_DELTA_TRIGGER_IN_C)
|
if (abs(lipoTempSensor.getAverage() - rtcLastLipoTemp) > TEMPERATURE_DELTA_TRIGGER_IN_C)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user