Hex message with UART

Hi! (again…)

I’ve looked around the internet a good bit, and can’t seem to figure out the right way to send a Hex message to another devices over UART. The code below is where I’m at, with no success. Any suggestions?

uart = UART(3, 19200)
message = b'\xaa\x00\x01\xBE\x00\x01\x00\x01\xC1'
uart.write(message)

Thanks!

This is a pure python question… Use the binascii module: binascii – binary/ASCII conversions — MicroPython 1.19.1 documentation

uart.write(ubinascii.hexlify(data))

Thanks for the tip! This is what ended up working for me:

message = 'AA0001BE00010001C1'
uart.write(ubinascii.unhexlify(message))