How to build AC current sensor circuit for ESP-01 GPIO
How to use circuitry to process signal after OP amp/comparator and get suitable 3.3V logic HIGH state on GPIO when current flow is present

AC current oscillates about zero, so crosses zero twice per cycle. Any circuitry used to detect this current is going to output a time-varying result, usually two pulses per cycle. Even if the AC current signal is rectified to a DC current signal, it'll still produce two pulses per cycle. And maybe that is ok and handled in software:

Detect high once, set a &quot;pulse detected&quot; timer for 0.2s. Set LOAD = 1.
Try detecting multiple times - eventually detect another one, reset timer.
When no pulses detected in 0.2s, assume must be off, clear timer. Set LOAD = 0.

This is not ideal, as it is possible to &quot;always sample at the wrong time&quot; and miss events. An alternative to this, is if the micro has &quot;interrupt on pin-change&quot; capability. If it does, reset the timer like previous on each interrupt. Here the timer only needs to be 21ms, because each pulse will always be detected.
If that's no good (need a physically constant logic high) then use that pulsed signal to charge a capacitor, through a diode, long enough so that it can't go low while pulses are present. For 50Hz mains AC the period is 20ms, 60Hz = 18.667ms (remember two pulses in this much time.) Might want/need to buffer the cap output to the GPIO, perhaps with a Schottky buffer to get a &quot;clean&quot; digital signal. Of course this means the GPIO detection of turn-off will be slightly delayed by the time-constant of the capacitor used. Research R-C Time Constant for more info.



simulate this circuit &ndash; Schematic created using CircuitLab
Might look something like this (note this can be simulated here and values adjusted.)
Then there's the issue of resolution. If you want simple &quot;flow&quot;, &quot;no flow&quot; resolution, then what threshold should be considered &quot;on&quot;? 1A? 1mA? The setpoint can be adjusted by altering the opamp resistor values, but the result will get noisier at lower currents. Also consider that this setpoint may drift with temperature.
If considering linear 0-3.3v = 0-15A, that becomes much more complex since the AC current is almost never a pure sinusoid.  The only practical way of measuring an analog AC current is via the Root-Mean-Square (RMS) method.
Take a look at the various types of current sensors offered by all manufacturers and distributors. It may be possible to find a robust and easy-to-use solution which would work well for your application.