🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    mqtt and button on atomS3

    UiFlow 2.0
    mqtt atom s3 button
    2
    3
    2.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      alwa123
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by felmue

        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.

        0_1701627232971_UIFlow2_MQTT_check_msg_20231203.png

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

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • A
          alwa123
          last edited by

          Great help, that did the job. Very thanks

          1 Reply Last reply Reply Quote 0
          • First post
            Last post