i would like to concatenate 4 sensor values to create bytes to send via sigfox.
i would like :
temp=0b1001010001110010101110 10111011101111101001110 0 1010010
(capt1) (capt2) (capt3) (capt4)
i try with two but it's not working
this is my code :
class tools: def trame(capt1,capt2,capt3,capt4): temp = ((capt1 << 23) | capt2) print(capt1) print(capt2) result=hex(temp) return result
and the error :
TypeError: unsupported types for : 'str', 'int'
on this line :
temp = ((capt1 << 23) | capt2)
See also the BitString module for MicroPython.
robert-hh last edited by
This post is deleted!
I resolve my probleme, it was the bin function that returns a string of characters and not a binary number
thank you for your answer.
@quentho you can try with:
def trame(capt1,capt2,capt3,capt4): result = (capt1 << 22) | capt2 result = (result << 1 ) | capt3 result = (result << 7) | capt4 return result```