I think that at this stage it’s worth pointing out that your hardware combination is rather unusual, so you wont find an out of the box solution. Some experimentation will be required, and if you read the code comments, and research the Uno and Mega boards, you’ll see that the Uno has one UART and the Mega has three.
The code says…
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
in other words, this is universal code that can be used on a variety of different Arduino boards by commenting/deleting some lines of code and removing the code for other lines.
Your initial; post indicated a degree of familiarity with C++ programming and devices, so several of us have made the mistake of signposting you in the right direction without actually going into much detail. Part of the reason for that was probably that we’ve never come across this hardware combination before, but we have no reason to think that it wouldn’t work - with some tweaking of code and experimentation.
If you’re new to coding in general, or to IoT projects, then you might be better looking at a different solution. Personally, I’d be basing this project around a Wemos D1 Mini rather than a Nano + ESP-01
Pete.