DIY capacitive moisture sensor ESP8266

Hello, trying to develop a simple capacitive moisture sensor with two parallel strips of aluminum and hook it up to my ESP8266. Have made the circuit work with a 10uF capacitor but I get no reasonable values with my homemade one.

I used this site as a starting point with R=10Mohm.

#define analogPin 0            // analog pin for measuring capacitor voltage
#define chargePin 14  //D5           // pin to charge the capacitor - connected to one end of the charging resistor
#define dischargePin 12    //D6    // pin to discharge the capacitor
#define resistorValue 10000.0F // change this to whatever resistor value you are using
#define ledPin 2

// F formatter tells compiler it's a floating point value

unsigned long startTime;
unsigned long elapsedTime;
float microFarads; // floating point variable to preserve precision, make calculations
float nanoFarads;

void setup(){
  pinMode(chargePin, OUTPUT); // set chargePin to output
  digitalWrite(chargePin, LOW);
  Serial.begin(115200); // initialize serial transmission for debugging
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
}

void loop(){
  digitalWrite(chargePin, HIGH); // set chargePin HIGH and capacitor charging
  pinMode(dischargePin, INPUT); // set discharge pin back to input
  startTime = micros();
  while (analogRead(analogPin) < 1000){
    if (micros() - startTime > 2000000){
      break;
    }
  }
  elapsedTime = micros() - startTime;
  // convert milliseconds to seconds ( 10^-3 ) and Farads to microFarads ( 10^6 ),  net 10^3 (1000)
  microFarads = ((float)elapsedTime / resistorValue) * 1000000;
  Serial.print(elapsedTime); // print the value to serial port
  Serial.print(" uS    ");   // print units and carriage return

  if (microFarads > 1){
    Serial.print((long)microFarads); // print the value to serial port
    Serial.println(" microFarads"); // print units and carriage return
  }

  else{
    // if value is smaller than one microFarad, convert to nanoFarads (10^-9 Farad).
    // This is  a workaround because Serial.print will not print floats
    nanoFarads = microFarads * 1000.0; // multiply by 1000 to convert to nanoFarads (10^-9 Farads)
    Serial.print((long)nanoFarads); // print the value to serial port
    Serial.println(" nanoFarads"); // print units and carriage return
  }

  Serial.println(analogRead(analogPin));
  /* dicharge the capacitor  */
  digitalWrite(chargePin, LOW); // set charge pin to  LOW
  pinMode(dischargePin, OUTPUT); // set discharge pin to output
  digitalWrite(dischargePin, LOW); // set discharge pin LOW
  
  while (analogRead(analogPin) > 28){ // wait until capacitor is completely discharged
  }
  Serial.println(analogRead(analogPin)); // Discharged value approx. 10
  delay(1000);
}

With this code and setup I don't seem to be able to charge the capacitive sensor and receives the maximum (constant) value of 28 for the analog pin during charging. Have tried several resistors ranging from 10Kohm to 20Mohm but can't figure out where it fails.

Can you show a picture of the DIY capacitor?

The foil is mounted on a piece of cardboard and everything is held together with household tape.

Sorry, but your homemade capacitor is about 1/1000 the 10uF that worked for you. Perhaps a lot less.