mqtt and button on atomS3

  • Hi there,
    i have a problem with the button click event. I want to subscribe and publish to different mqtt topics and use the display button of the atomS3 to publish messages. The button works till i include the "mqtt apply for messaging" block. When i include that block the button event is not triggered anymore. Without the mqtt block i cant recive mqtt-messages. Here a short example:
    image url0_1701551167453_Screenshot_20231202_220057_Samsung Internet.jpg )

    What i have to do to get it work? Thanks for the help.

  • Hello @alwa123

    it looks like the MQTT library used is called umqtt. It has two methods to wait/check for server messages: wait_msg() and check_msg(). The former is blocking, the latter is non blocking. See here - section API reference.

    The block MQTT apply for messaging creates mqtt_client.wait_msg(), the blocking variant. In order for the button events to work the non blocking variant should be used in loop().

    This can be done with an Execute code block containing mqtt_client.check_msg(). See below.


    @m5stack : could you please add an MQTT block for the non blocking variant?


  • Great help, that did the job. Very thanks