adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
571 stars 292 forks source link

mqtt.readSubscription cause huge slowness on execute following code on RasPiArduino #135

Closed Barabba11 closed 5 years ago

Barabba11 commented 5 years ago

Hi mates, I suppose it's quite difficult for me to find an MQTT library that works on RaspBerryPi using RasPiArduino, anyway this works.. but the slowness the code create, especially the line:

while ((subscription = mqtt.readSubscription(1000))) {

is impossible to tollerate. I need to read constanly sensors and input lines, when I use this code I can check them only after one second, so how to overcome this? It looks like mqtt.readSubscription(1000) works like a "delay (1000);" is that normal? If I short it putting for example (100) the cose speeds up but it doesn;t receive the mqtt messages, it needs at least 700, but with 700 sometimes the ping goes in timeout and the message will never be received. Result make it not reliable and impossible to use for the delay. Thank you for help! PS: I used the example file .ino to test it, with just slight changes

brentru commented 5 years ago

We don't advise using this library on the Raspberry Pi.

For Raspberry Pi, you may want to use Adafruit IO Python for MQTT with Adafruit.IO (https://github.com/adafruit/Adafruit_IO_Python) or Paho MQTT (https://pypi.org/project/paho-mqtt/)