Chat freely about anything...

User avatar
By Scott Jercich
#92724 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,
(17.29 KiB) Downloaded 16 times