How to send bytes data to downlink

The screenshot shows you’re using payload_fields instead of payload_raw. The Base64-encoded payload should go into payload_raw. Only use payload_fields if you’ve defined an Encoder in TTN Console.

Your MHgwQjgxMDQwMDAwMDAxRQ== converts to hexadecimal 30783042383130343030303030303145 which is ASCII text. Converting that hexadecimal representation into an ASCII representation gives me 0x0B81040000001E again.

So, you’ve encoded twice. That’s wrong.

To send the byte 0x0B you should send a single value, basically the bits 00001011. But above you’re sending the human-readable ASCII characters 0 and B, which in hexadecimal notation are the bytes 0x30 and 0x78, or when displayed as bits are 00110000 01111000, so twice as many bits. See also https://www.thethingsnetwork.org/docs/devices/bytes.html

So, you should not Base64-encode the human-readable hexadecimal text representation, but you should Base64-encode the actual binary value. For manual testing use the Base64 encoder I already linked to in my answer above, which already expects human-readable hexadecimal text as its input. See also https://www.thethingsnetwork.org/forum/t/advantage-of-base64-encoding-in-mqtt/3425

In short, you should use the example I gave you:

How did you Base64-encode the value you’re using?

1 Like