-->
Page 1 of 1

MQTT reconnecting over and over/ callback function

PostPosted: Tue Oct 26, 2021 1:05 pm
by Scott Jercich
Hello,

I actually have three question about the code I am using to turn a device on and off via WiFi and MQTT. Based upon what I am seeing in the Arduino IDE, MQTT is connecting and reconnecting repeatedly. It seems to me this should happen just once.

Also, on a different note, I don't understand how the callback function in the code can keep executing (as it is supposed to) everytime a new message is published by MQTT since the callback code lies within the void setup() which I understand runs only once.

Finally, with regard to the void calback function, how is it that the three arguments (topic, message and length) are being populated?

Attached is the code.

Any help someone could provide would be most appreciated!
Thank you,
Scott