diff --git a/src/capacitiveSoilMoistureSensor.cpp b/src/capacitiveSoilMoistureSensor.cpp index 116061f..4f69fb6 100644 --- a/src/capacitiveSoilMoistureSensor.cpp +++ b/src/capacitiveSoilMoistureSensor.cpp @@ -19,7 +19,7 @@ void setupCapacitiveSoilMoistureSensor() { } } -void loopCapacitiveSoilMoistureSensor() { +int loopCapacitiveSoilMoistureSensor() { // subtract the last reading: total = total - readings[readIndex]; // read from the sensor: @@ -37,5 +37,6 @@ void loopCapacitiveSoilMoistureSensor() { // calculate the average: average = total / numReadings; - Serial.println(average); + + return average; } \ No newline at end of file diff --git a/src/header.h b/src/header.h index ee66b47..f557c4b 100644 --- a/src/header.h +++ b/src/header.h @@ -12,7 +12,7 @@ extern int meineVariable; // moisture extern void setupCapacitiveSoilMoistureSensor(); -extern void loopCapacitiveSoilMoistureSensor(); +extern int loopCapacitiveSoilMoistureSensor(); // light extern void setupLightSensor(); diff --git a/src/main.cpp b/src/main.cpp index 44e2c7c..02ae86d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,6 +16,9 @@ void loop() { Serial.print(lxValue); Serial.println(" lx"); - loopCapacitiveSoilMoistureSensor(); + uint16_t mstValue = loopCapacitiveSoilMoistureSensor(); + Serial.print("Soil moisture: "); + Serial.println(mstValue); + delay(200); // delay in between reads for stability } \ No newline at end of file