Robotdyn Mega +WiFi R3 ATmega2560+ESP8266

Hi,
You could start by trying to follow suggestion from here:

Although this is written with Uno in mind the process is similar.
BB