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

    MQTT connection

    SOFTWARE
    3
    8
    1.1k
    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.
    • T
      travisstdenis
      last edited by

      I'm having difficulty connecting my Core Basic to MQTT using UIFlow 2.0. Here are the pertinent code blocks:
      uiflow_setup.png
      uiflow_subscribe.png

      When I run it, I get the following error.

      umqtt.py line 71. in connectOSerror: -203
      

      Looking at the github, this line is the middle line of this statement for the connection procedure Connect():

      if self.user is not None:
          sz += 2 + len(self.user) + 2 + len(self.pswd)
          msg[6] |= 0xC0
      

      It also references the line of code for this connection block in my setup:

      mqtt_client.connect(clean_session=True)
      

      I'm trying to connect to a Mosquitto broker on a raspberry pi that allows anonymous connection (no user/pass). It appears that error stems from the user/pass variables, but they are set as None in the block so why does this even trigger? Regardless, I'm at an impasse here on how to solve the issue. Any help would be appreciated.

      felmueF ajb2k3A 2 Replies Last reply Reply Quote 0
      • felmueF
        felmue @travisstdenis
        last edited by

        Hello @travisstdenis

        have you tried to connect to test.mosquitto.org? Does that work or are you getting the same error?

        Thanks
        Felix

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

        T 1 Reply Last reply Reply Quote 0
        • ajb2k3A
          ajb2k3 @travisstdenis
          last edited by

          @travisstdenis The connection blocks need to bee in the loop not the setup.

          UIFlow, so easy an adult can learn it!
          If I don't know it, be patient!
          I've ether not learned it or am too drunk to remember it!
          Author of the WIP UIFlow Handbook!
          M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

          T 1 Reply Last reply Reply Quote 0
          • T
            travisstdenis @felmue
            last edited by

            @felmue i couldn't get a connection to test.mosquitto.org but i could for Adafruit. I setup this connection
            uiflow_setup_2.png

            I get a nonsense error on the screen about some unrelated rectangle UI block in the setup about

            TypeError: extra keyword arguments given
            

            When I look at the serial data i get:

            >>> E (8014) mqtt_client: Error create mqtt task
            E (23515) mqtt_client: esp_mqtt_client_init(800): Memory exhausted
            E (23515) mqtt_client: Client was not initialized
            E (23516) mqtt_client: Client was not initialized
            

            I have tried this several ways. with and without the https:// in the server, with keepalive values of 0 or 300, in and out of the "if connected to wifi" block. The image shows the only way I've gotten some kind of response that gets me closer.

            1 Reply Last reply Reply Quote 0
            • T
              travisstdenis @ajb2k3
              last edited by

              @ajb2k3 I have the "MQTT Apply For Messaging" block in the Loop. Everything I have seen has the connection parts in the Setup. Are you saying I need to have the MQTT Init block from the setup in the Loop?

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

                Hello @travisstdenis

                please have a look at my example for test.mosquitto.org and io.adafruit.com in the UIFlow2 Project Zone called: M5Core_MQTT_WLAN_UIFlow2.1.4

                Thanks
                Felix

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

                T 1 Reply Last reply Reply Quote 0
                • T
                  travisstdenis @felmue
                  last edited by

                  @felmue that worked! So it was just the addition of those other WiFi blocks that did it. The Serial output had said Wifi connected before, but I guess not.

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

                    Hello @travisstdenis

                    thank you for reporting back. I am glad to hear you got it working.

                    Thanks
                    Felix

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

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