attachInterrupt and/or Serial.print (ESP32)

Your posted code does not reflect that.