Problem in showing results in python

Also not working with mqtt and modified script???

I think I know what is causing this...

This line in your python script
mens=bytes(payload).decode("utf-8",'ignore')
is creating a python bytes object

Try this code

        BOARD.led_on()
        #print("\nReceived: ")
        self.clear_irq_flags(RxDone=1)
        payload = self.read_payload(nocheck=True)
        send_mqtt_message('loramessage', str(payload))
        #print ("Receive: ")
        mens=bytes(payload).decode("utf-8",'ignore')
        mens=mens[2:-2] #to discard \x00\x00 and \x00 at the end
        print(mens)
        send_mqtt_message('loramessage', str(mens))
        BOARD.led_off()

I'm working on it, but as I am installing and using paho for the first time, it takes some time to solve errors, and the latest one is :


As you also guess, I have used str() lately to solve the problem in pythonshell and daemon,but face no change in answer there !

Sorry, I missed a part in the script, I have updated it now

1 Like

@tarahi
I have updated the script further, I believe I have solved it, when I simulate the data it works but you should run it with python3, like "python3 scriptname.py"
This is because python3 handles bytes/bytearray differently than python2

vow !
excellent !
It works correctly
Thanks for your help :heart: :heart: :heart:

1 Like

Nice to hear!!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.