Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    WiPy - MQTT - store message into variable

    Scheduled Pinned Locked Moved Comments & Feedback
    2 Posts 2 Posters 19 Views 2 Watching
    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.
    • C Offline
      CL0ser
      last edited by

      Hi,

      I am trying to store a MQTT message (number) from topic "vlaky/speed" into the variable "speed_req" but I couldnt find any command how to save it. Do you know any solution to my problem? I am still learning python so I dont know many things.

      Thank you for your answer!

      27c73f33-a70f-4fae-b7cc-84983688d68d-image.png

      ea18156f-882f-4382-8eec-92d482cd82c8-image.png

      1 Reply Last reply Reply Quote 0
      • G Offline
        Gijs
        last edited by

        Hi,
        No worries (if, next time you could use the code tags, ie before, and after, that would be nice, so I do not have to hand-copy everything).
        It seems you are able to print the message right? You'll need to decode the message to a readable int.
        What you can do is the following:

        speed_req = msg.decode("utf-8")
        
        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom