[SOLVED] Arduino Mega2560, ESP8266-01, MQTT problem receiving messages

Hi simon

The problem was not with WiFi connection/disconnection but with connection to the MQTT broker
This is handled by the PubSubClient library. This is an excellent MQTT library but it needs regular calls to client.loop() (to receive messages in callback) and reconnect() (To maintain connection to the MQTT broker) All the examples with the PubSubClient library call these functions every loop. It would appear that most people use this library in sketches that are flashed to the ESP boards - in which case they work fine. The problem seems to arise if the program is used on an arduino (in my case a Mega2560 with a spare hardware serial) which is connected to an ESP via a serial connection - This connection can become overwhelmed by status messages from the ESP which block incoming messages. Outgoing messages to the MQTT broker are fine!
I am very much a newbie with regard to ESP & MQTT but this is my understanding of the situation

Regards

Richard