Finding rise time and amplitude

Thanks a lot for the code and description. It certainly will help once i switch to ESP32 which I have to later. Meanwhile I am using STM32 NucleoL with input from generator CD4060. I have recently tried Interrupt to find the time between rising and falling but am not sure if it actually gives the time I am looking for (that is the falling time in the attached picture). Compared to the data i see in the excel sheet the times are round about similar. And when moisture of soil is increased the time also increases. What do you think about this approach, am I really getting the rise/fall time here?

volatile int pwm_value = 0;
volatile int prev_time = 0;

void setup() {
  Serial.begin(115200);
    analogReadResolution(12);

  // when pin D2 goes high, call the rising function
  attachInterrupt(PB0, rising, RISING);
  
}

void loop()
{
  }

void rising() {
  attachInterrupt(PB0, falling, FALLING);
  prev_time = micros();
}

void falling() {
  attachInterrupt(PB0, rising, RISING);
  pwm_value = micros()-prev_time;
  Serial.println(pwm_value);
}

Screenshot (138)
Thanks again.