SuomyNonaPatri wrote:First part I don't really understand, is that the 'ESP8266WiFi.h' library becomes unavailable when I select the mega as my board. That library is necessary to talk to the ESP8266, but I cant use it when uploading to my mega. It only works when I select 'generic ESP8266' as my board. So what am I supposed to voojio omegle do here?
The ESP8266WiFi library will only work on the ESP8266. It is used to work with WiFi. It does not allow the ESP to communicate with the Mega. You mentioned you want MQTT which requires WiFi which requires the ESP8266. Most any project can do everything on the ESP8266. You have not said why you want to use the Mega... is it because of the number of pins you need for your project??? If so...
You'll need to setup some kind of communications protocol between the two. The most common is using serial communications.
What you are asking to do is WAY non-trivial - Do some undefined program on the Mega that must also talk both ways using a serial communications. And separately, create a program that talks both ways over serial communications and passes that to the MQTT communications talking over the WiFi.
That's why, if you can, to do everything on the ESP8266 and punt the Mega and the serial communications part. If you must have the Mega, you should google "Arduino serial communications with ESP8266" will probably get you a good tutorial.
w/ GUI Admin Client, Drag & Drop File Manager, OTA Built-In, Access Point Manager,
Performance Metrics, Web Socket Comms, App API, All running on ESP8266...
Even usable on ESP-01S --- Please check it out!
https://inqonthat.com/inqportal-the-three-line-promise/
https://InqOnThat.com/inqportal