I bought a Sonoff switch to understand how it connect to my wifi without predefined ssid and pass. But I couldn't understand its logic. When I want to use ESP8266 module with Arduino, how my phone and this device start to communicate with my ssid?

As I understand, Sonoff switch don't save my SSID and password. The application of the device (wWeLink) needs my ssic and password.

The point I don't understand how this software and device communicate?

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

I see someone has voted to close this question. Likely because it is too open ended. @ismail I would encourage you to read the links provided by Juraj, edit your question and go as far as entering your own answer (there's nothing wrong with that!). The point being to leave a good question and answer for others to find who have similar concerns.
– st2000Jan 7 at 15:08

2

BTW, you can flash the ESP chip in a Sonoff switch with explicitly defined SSID and Password values to make the process straight forward. Otherwise, I believe that the process is along the lines where the Sonoff turns into an open wifi "hot-spot" for your phone to connect to and down load the information to allow the Sonoff to later turn into a normal wifi client of your wifi router.
– st2000Jan 7 at 15:12

2

and yes, the esp8266 in Sonoff saves your ssid and password once you enter it over the application
– JurajJan 7 at 16:23