Open HaViGit opened 1 year ago
Without seeing what you have actually tried it is hard to suggest where it may be going wrong.
But it should be a case of calling client.subscribe
once for each topic you want to subscribe to:
const char *topic = "Energy/timestamp";
const char *topic2 = "Energy/anotherTopic";
...
client.subscribe(topic);
client.subscribe(topic2);
Thanks for your help, it does indeed work with just that extra code.
As a beginner in using MQTT I run into a problem when I want to subscribe to two topics. Subscribing to one topic is going well with the sketch below, but I can't subscribe to both topics (Energy/timestamp and Energy/power). Not even with the instructions elsewhere in this forum and not even after trying for many hours.
Can someone link to a (complete) demo sketch? Or is someone kind enough to show me how to modify the sketch below?