I’m setting up a mqtt client on an Arduino with PubSubClient. However I’m struggling with the right way
to publish a topic with a retain flag. I can’t get it right. I’ve been looking in the PubSubClient API
but I cannot find what I’m doing wrong
In the future, please paste code as text, not as screenshot.
Regarding the problem: These are the possible overloads of the function
Then you’ll notice that the second parameter needs to be a const uint8_t* when you want to send some data – not an integer. You seem to want to transmit the value 5 as a 2-byte value (aka short), directly in binary form, not as an ASCII string. Then write (uint8_t*)&conMsg as the second parameter.