M5 Stack unable to subscribe and recieve new messages

  • Hello everyone, I am trying to print new messages on my m5 stick c plus, through hive mq. I am able to publish, but not able to subscribe. Not sure what is the issue here, please advise! Thank you in advance!

    Here is my code:

    from m5stack import *
    from m5ui import *
    from uiflow import *
    import time
    PASSW = None
    CLIENTID = None
    USER = None
    HOST = None
    label0 = M5TextBox(47, 49, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
    label1 = M5TextBox(47, 176, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
    PASSW = 'password'
    CLIENTID = 'm5stack'
    USER = 'user'
    HOST = '07ecd30c.s1.eu.hivemq.cloud'
    from m5mqtt import M5mqtt
    m5mqtt = M5mqtt(CLIENTID,HOST,8883,USER,PASSW,300,ssl=True,ssl_params={'server_hostname':HOST})
    label0.setText('Hello M5')
    a = None
    def callback(topic_data):
      a = topic_data
    while True:
      m5mqtt.subscribe(str('topic/1'), callback)

    My StickCPlus is currently v1.9.8-plus

  • Hello @sleepyfatcat

    any particular reason you subscribe in an infinite while loop? Last time I tried mqtt I called m5mqtt.subscribe() only once and just before calling m5mqtt.start().


  • what do you mean by "Not able to subscribe" ?
    Does it not connect or does it not return data?
    Does the data turn up in HiveMQ?

    This looks like Micropython but the functions look strange, you have SSL set to true but no keys and certificates set.