Recommendation on which ESP8266 library to use with Mega

I have been programming with NodeMCU's and using the ESP8266WiFi.h and WiFiUDP.h libraries as thats what was used in the code I started with.

I now need to use this code on a Mega as I need a 2nd serial for DMX.

Which Wi-fi library would you recommend for the ESP8266 (ESP-01) on the Mega and is there one that I can use the same commands as the ESP8266WiFi library?

That is not a good idea. Such code uses the AT command set of the ESP-01, which works well for demos and testing, but isn’t robust enough for everyday use. 99.9% of the code written to use this method, use blocking code and so will disturb the timing of any cooperative multitasking that you’re using.

What you have to do, is write custom code for the ESP that performs a useful subset of wifi functions that you need, and a custom command interface to replace the AT set.

You can run without all that, but the performance will be substandard.

I now need to use this code on a Mega as I need a 2nd serial for DMX.

Go for an ESP32 ! it supports the DMX BAUD-rate, has a few UARTs and is a fair bit quicker than a MEGA.
Or use the MEGA as a slave to the ESP and use it for routing the Serial & DMX data to the ESP (upon it's request)

Deva_Rishi:
Or use the MEGA as a slave to the ESP and use it for routing the Serial & DMX data to the ESP (upon it's request)

Ooooh, interesting... I'll have to try that...

I have a ESP32 here I could use.

I'm new to all of this, so apologies for the simple questions.

I can use a ESP32 with Wi-fi as well as a hardware serial connection for DMX?

aarg:
That is not a good idea. Such code uses the AT command set of the ESP-01, which works well for demos and testing, but isn't robust enough for everyday use. 99.9% of the code written to use this method, use blocking code and so will disturb the timing of any cooperative multitasking that you're using.

What you have to do, is write custom code for the ESP that performs a useful subset of wifi functions that you need, and a custom command interface to replace the AT set.

You can run without all that, but the performance will be substandard.

That's way beyond my capabilities.

So use an ESP32.

I can use a ESP32 with Wi-fi as well as a hardware serial connection for DMX?

I would say so, the hardware capabilities are sufficient for DMX, i haven't had it running yet though.

Any device interface that uses UART serial communication has an extremely high probability of working without problems on different machine architectures.

I hope this isn’t too much of a hijack…

@Juraj, you suggest flashing AT firmware version 1.7.x with WiFiEspAT. Have the performance problems that I encountered and mentioned above, been fixed in that version?

Some background. I tested some out of the box sketches that worked but blocked. I then made non-blocking versions and they didn’t work reliably. That points to my code, but I did walk through it multiple times to try and troubleshoot. Basically what I found is that there are undocumented timing requirements for some of the AT commands. It’s been too long ago to remember the details. I do still have the code, attached. It worked but glitched every few days, when the blocking version did not:

esp_at_sntp.h (14.1 KB)

esp_at_sntp_nonblocking_115.ino (1.86 KB)

aarg:
I hope this isn't too much of a hijack...

@Juraj, you suggest flashing AT firmware version 1.7.x with WiFiEspAT. Have the performance problems that I encountered and mentioned above, been fixed in that version?

the Serial communication on hardware Serial can run at 500000 baud

blocking are the calls which are defined blocking in Arduino WiFi API and some calls where it must wait for AT command response (for example CWLAP. and CWJAP takes long with DHCP, but can be avoid using the automatic connection with remembered ssid and password.)

Any device interface that uses UART serial communication has an extremely high probability of working without problems on different machine architectures.

depending on the maximum baud-rate that is supported.