Hello,
I have a nodeMCU (with an LCD display) which I would like to alternate the reading of 2 MQTT topic.
I have a flag (dependent on the state of a digital entry) which works, but I do not see the change of topic on reading.
Thank you for your help
code :
void reconnect() {
while (!client.connected()) {
Serial.println("Connection au serveur MQTT ...");
if (client.connect("LectureXYZ_1")) {
Serial.println("MQTT connecté");
}
else {
Serial.print("echec, code erreur= ");
Serial.println(client.state());
Serial.println("nouvel essai dans 1.5 s");
delay(1500);
}
}
if (flagTfa) {
client.subscribe("TFA");
} else {
client.subscribe("CPT");
}
}