Refactor the moisture prints into the main file.
This commit is contained in:
parent
2a830468e9
commit
73e0739815
@ -19,7 +19,7 @@ void setupCapacitiveSoilMoistureSensor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loopCapacitiveSoilMoistureSensor() {
|
int loopCapacitiveSoilMoistureSensor() {
|
||||||
// subtract the last reading:
|
// subtract the last reading:
|
||||||
total = total - readings[readIndex];
|
total = total - readings[readIndex];
|
||||||
// read from the sensor:
|
// read from the sensor:
|
||||||
@ -37,5 +37,6 @@ void loopCapacitiveSoilMoistureSensor() {
|
|||||||
|
|
||||||
// calculate the average:
|
// calculate the average:
|
||||||
average = total / numReadings;
|
average = total / numReadings;
|
||||||
Serial.println(average);
|
|
||||||
|
return average;
|
||||||
}
|
}
|
||||||
@ -12,7 +12,7 @@ extern int meineVariable;
|
|||||||
|
|
||||||
// moisture
|
// moisture
|
||||||
extern void setupCapacitiveSoilMoistureSensor();
|
extern void setupCapacitiveSoilMoistureSensor();
|
||||||
extern void loopCapacitiveSoilMoistureSensor();
|
extern int loopCapacitiveSoilMoistureSensor();
|
||||||
|
|
||||||
// light
|
// light
|
||||||
extern void setupLightSensor();
|
extern void setupLightSensor();
|
||||||
|
|||||||
@ -16,6 +16,9 @@ void loop() {
|
|||||||
Serial.print(lxValue);
|
Serial.print(lxValue);
|
||||||
Serial.println(" lx");
|
Serial.println(" lx");
|
||||||
|
|
||||||
loopCapacitiveSoilMoistureSensor();
|
uint16_t mstValue = loopCapacitiveSoilMoistureSensor();
|
||||||
|
Serial.print("Soil moisture: ");
|
||||||
|
Serial.println(mstValue);
|
||||||
|
|
||||||
delay(200); // delay in between reads for stability
|
delay(200); // delay in between reads for stability
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user