Open darc76 opened 7 years ago
The client is only able to receive a message when you call client.loop
.
If you are not calling it regularly, then you will see an apparent delay in receiving a message.
I'm not going to debug your code, but I suggest you add a Serial.println
ahead of the call to client.loop
so you can confirm how often you are calling it and how that relates to the receiving of messages.
Thanks @knolleary, I wiil try that and let you know.
What worked for me:
Hi @knolleary I'm using the pububclient library on an arduino uno and a ESP8266 via software serial, I intend to do a multi sensor connected via MQTT, I followed the example with the DHT22 sensor, it works great, publishing the temperature and humidity every second, or less, but when I try to subscribe to a topic in my broker, the subscribe is ok, but the callback receive the messages once in a while at most, here is my code, may seems a little messy, but, I was the last three days trying to figured out what is the problem. Thanks in advance.
PS. I tried a solution from another user, to delay the client.loop and the client.connect. There is in the code. The subcribed topic is home y el outtopic es home/out