Anyone have a reliable MQTT interface using PyCom?

  • I'm trying to use pycom for MQTT to GCP. I can't really make a reliable connection. In this screenshot, I show a long running exchange of messages with GCP, but once it fails bringing down the network interface and restarting still results in a crash. The and code which is from the pycom github is in play. I have filed issues with the files there and I have not gotten any response. I'm asking here again in hopes someone can advise if this is simply the expected behaviour.

    I have added a poll/select timeout on the mqtt socket read in That is shown with the !!! in the debug log.

    Screenshot from 2020-07-12 09-43-56.png

  • Hi @netskink,

    Yes this is part of Pybytes, but you can use the MQTT without integrating with pybytes, I mean you can use the library instead of

    In your case what you should use is only:


    the try-catch is related to libraries under the "lib" folder and in the frozen zone. so if you are using your own firmware, you can just add the above files and ignore the try-catch or remove them. if you are using pybytes firmware, you can import or and do subscribe, publish directly.

  • @ahmadelmasri Im using Google's IOT Core. Not pybytes.

    So only the file would apply to me. Just looking at the github, this code looks like it has tight coupling with pybytes and other unknown components.

    What is the deal with all these try exception blocks on imports? Is that so it can be run with regular python and micropython?

        from mqtt_core import MQTTCore as mqtt_core
        from _mqtt_core import MQTTCore as mqtt_core

    There is a subscribe method in and a subscribe method in How is this better?

  • Hello @netskink,

    I recommend checking the new MQTT protocol which is more reliable.

    files to check (work with):


    Best Regards,
    Ahmad EL Masri

Log in to reply

Pycom on Twitter