ESP32 touch sensor outputs unstable values
On studying graph, it is observed that actual touch lasts around 80 to 100 ms and false touch lasts for much less time. Although I had tried some filters before but turns out that was just too complicated, a simple filter works fine (my siliness).
Working code:-
boolean touchStarted = false;
unsigned long touchTime = 0;
int threshold = 90;
int touchMinDuration = 100;

void setup() {
  Serial.begin(115200);
}

void loop() {
  int t = touchRead(27);
  if (t &lt; threshold &amp;&amp; !touchStarted) { // on fresh touch
    touchStarted = true;
    touchTime = millis();
  } else if (t &gt;= threshold &amp;&amp; touchStarted) { // untouched
    if (millis() - touchTime &gt; touchMinDuration)
      touched;
    touchStarted = false;
  }
  delay(10);
}

void touched(){
  Serial.println(&quot;Touched&quot;);
}

Thanks to the comments which helped me to come on this solution.