WiPy - MQTT - store message into variable



  • 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



  • 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")
    

Log in to reply
 

Pycom on Twitter