This is an adaptation of (Minimal Arduino Metal Detector)[https://www.instructables.com/Minimal-Arduino-Metal-Detector/] for ESP-WROOM-32 microcontroller. Since it's fastest timer is 40MHz (vs Arduino's 16MHz), this detector should be more sensitive.
The main circuit here is a classic LR circuit:
Pulse GPIO > ---------
)
(
) Coil (L)
(
Measure GPIO < --------- ----^^^^^----- GND
R
Detector sends a pulse through a pulse GPIO (techinally, sets GPIO to 1 and shortly after to 0). After setting pulse GPIO to 0, the energy in RL circuit, accumulated during a pulse, starts to fade. Current in RL circuit becomes an exponentially decaying function.
Pulse induction metal detectors measures time of decay of the current in RL circuit, that is waiting for 0 on measure GPIO. When no metal objects present near the coil, the time of decay has some reference value, depending on the environment and the chip itseld. Presence of metal objects near the coil causes a current to decay faster due to eddy currents. Comparing a measured time of decay with reference value allows us to detect a metal object nearby.
You can see more detailed explanation in Russian in explanation.pdf
