Arduino mega and Esp01

It’s not possible to use the ESP-01 and Arduino in the way you’ve set them up.

The normal way to use this pair together is to run the factory AT firmware on the ESP-01, but this doesn’t allow WiFiManager to be used.

You should read this…

Pete.