The whole course as been very nice! Thank you for this.
I am playing with the mqqt protocol. Completed this course with a light measurement sensor and it worked fine with a graph on the portal from the node-red.
Now I want to add a distance sensor and include it in the webportal. The sensor works fine in the serial monitor but If I just copy the publish code and chance the topic I get the error: “redeclaration of uint16_t packetIdPub2?
So essentially I have :
uint16_t packetIdPub2 = mqttClient.publish(“SLITTER/light”, 2, true, LightString.c_str()); //which works fine
uint16_t packetIdPub2 = mqttClient.publish(“SLITTER/distance”, 2, true, DistanceString.c_str());//which is a redeclaration?
I do not fully understand the syntax of this publishing?
All help is welcome,
ps: I am not using a pure ESP32 but playing with the M5GO (fire) but absolutely no issue during the full course.
Hi Geert, you need to use something like this (create a new unit16_t variable):
uint16_t packetIdPub2 = mqttClient.publish("SLITTER/light", 2, true, LightString.c_str()); //which works fine uint16_t packetIdPub3 = mqttClient.publish("SLITTER/distance", 2, true, DistanceString.c_str());
- Topic name
- Quality of service
- Retain message (yes=true)
Thanks for letting me know! Yes, all ESP32 boards should be compatible with the course if you always double-check the pin assignment!
Perfect, that works golden.
Now the sensors are nicely available.
At this moment they are connected to different ESP32’s and publish correctly to the server.