After I purchased some ESP8266-boards (NodeMCU v1.0 and WeMos D1 mini) I was looking for an easy way to connect them via wifi to an mqtt broker.
I found this framework called "Homie for ESP8266"
The “bare minimum sketch” (“Hello World”) is only 10 lines of code and provides everything to connect to your wifi, your mqtt broker and sending general information.
It startes as an access point on configuration mode after flashing.
With a simple app (Web, Android, iOS) you can configure Wifi and mqtt credentials.
As a beginner, I am happy I can control my first LED via wifi on an Arduino board.
Without having to deal with error handling (reconnecting) for wifi and mqtt.
Have a look at this project.
It might be worth it.
Or let me now if this is a completely bad designed framework and you know a better one.