Refactor the moisture prints into the main file.

This commit is contained in:
Andrés Uribe Stengel 2020-06-23 12:22:17 +02:00
parent 2a830468e9
commit 73e0739815
3 changed files with 8 additions and 4 deletions

View File

@ -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;
} }

View File

@ -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();

View File

@ -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
} }