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

    Unable to subscribe to IoT topic (M5StickCPlus)

    M5 Stick/StickC
    2
    5
    2.5k
    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.
    • M
      mino91
      last edited by

      Hi all,
      I've been trying to subscribe to an AWS IoT topic but with no success... even after searching for solution in this forum and on the internet. This is how the code looks like using UIFlow v1.11.9

      alt text

      I can publish to topics without issues, but i'm unable to subscribe to topics :(

      The data defined for label0 to label2 shows as 'none' and the label3 that i included on the AWS subscribe loop does not show at all. Which makes me wonder whether the subscribe commands is even done or whether it is done with error... although i do not see any errors when i run the code.

      python code looks like this:
      alt text

      Anyone has faced this issue? is it a bug? Any help would be greatly appreciated.
      Thanks

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

        You have a wificonnect block but haven't placed a wifi block to say what SSID and password to use to connect to the wifi network.

        I have been getting some code fails when trying to decode JSON files, If I add the get key blocks as you have then it just doesn't work and wont even load the json stream.

        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!

        M 1 Reply Last reply Reply Quote 0
        • M
          mino91 @ajb2k3
          last edited by

          @ajb2k3

          Thanks for your feedback!
          The wifi connects fine, because of the wifi config you burn via the M5burner I think. But you are right I can add that wifi block just in case.

          Update: I've tried with HiveMQ broker and the subscription PARTIALLY works: only the first message is received.
          During the initial run (clicking run from the flow web UI), the code initializes then when publishing the first message to the topic via another client, the M5stick receive and display the message as expected. The get key part to get the values in the JSON data actually works fine if the message is received.

          However, the subsequent published messages to the topic are not received by the M5stick. I've tried to run the code under the subscribe block inside a loop but it doesn't work neither.

          I've also tested EMQ broker and with a self hosted Mosquito broker, same results: only first message published is received. So it is likely something misconfigured or bugged on the M5 side ? I've now tried with 4 different brokers lol.

          In the code, I've used the generic MQTT blocks this time instead of the AWS ones.

          alt text

          thanks for your help.

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

            0_1688014683644_Screenshot 2023-06-28 at 06.14.39.png
            This is the code I'm using on a core2 that sends to a self hosted Mosquitto server and so far had no issues.

            0_1688014882686_Screenshot 2023-06-29 at 06.01.10.png

            and this is my M5Paper receiver code that retrieves data from the server.

            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!

            M 1 Reply Last reply Reply Quote 0
            • M
              mino91 @ajb2k3
              last edited by

              @ajb2k3 I've physically restarted the device (power OFF and back ON with the side button) instead of just having it run / reset from the flow web ui, now it seems to work (with HiveMQ, i haven't re-tried the other yet)!
              Thanks a lot for your support and for sharing your code, much appreciated !

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