/* Code for the Capacitive Soil Moisture Sensor */ #include const int numReadings = 20; void setupCapacitiveSoilMoistureSensor() { // pinMode(PIN_MS, INPUT); } int readCapacitiveSoilMoistureSensor() { int total = 0; // the running total // read from the sensor: for (int readIndex = 0; readIndex < numReadings; readIndex++) { total = total + analogRead(PIN_MS); delay(2); } int measurement = total / numReadings; Serial.print("soil moisture raw: "); Serial.println(measurement); // add the reading to the total: //int measurement = analogRead(PIN_MS); return map(measurement, VALUE_AIR, VALUE_WATER, 0, 100); }