# How to send payload in Hex-format?

**URL:** <https://www.thethingsnetwork.org/forum/t/how-to-send-payload-in-hex-format/8534>\
**Category:** End Devices (Nodes)\
**Created:** [July 18, 2017, 12:33pm UTC](https://www.thethingsnetwork.org/forum/t/how-to-send-payload-in-hex-format/8534 "2017-07-18T12:33:45Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [July 19, 2017, 1:22pm UTC](https://www.thethingsnetwork.org/forum/t/how-to-send-payload-in-hex-format/8534/4 "2017-07-19T13:22:06Z")

</div>

> [@denis](#):
>
> What do I have to do that “data\_raw” doesn’t get Base64 encoded?

You cannot change that. But why would you? Just decode it, and you’ll get the binary data, exactly as the node has sent it.

Like, for example, the 32 bits binary data `00001001 10100110 00001100 11010010`2:

- cannot be printed on the screen as plain text, as in [the ASCII standard](https://en.wikipedia.org/wiki/ASCII) binary `00001001`2 is the tab character, `00001100`2 is a form feed, and `10100110`2 and `11010010`2 are too large and not defined (but in [ISO/IEC 8859-1](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) could [be](https://www.ascii-code.com/) `¦` and `Ò`, or in [ISO/IEC 8859-2](https://en.wikipedia.org/wiki/ISO/IEC_8859-2) would be `Ś` and `Ň`, and in [ISO/IEC 8859-5](https://en.wikipedia.org/wiki/ISO/IEC_8859-5) be `І` and `в`; even for “plain” text, one would need to agree on the _exact_ encoding that is used)

- could be two [unsigned](https://en.wikipedia.org/wiki/Signedness) 16 bits [integer](https://en.wikipedia.org/wiki/Integer) numbers [`2470`](https://www.rapidtables.com/convert/number/binary-to-decimal.html?x=0000100110100110) and `3283`, when assuming [MSB](https://en.wikipedia.org/wiki/Bit_numbering) (or `2470`10, or `2470`dec to make it very explicit it’s decimal)

- could be four unsigned 8 bits integer numbers `9`, `166`, `12` and `210`

- could be four signed 8 bits integer numbers, `9`, [`-90`](https://www.rapidtables.com/convert/number/binary-to-decimal.html?x=10100110), `12` and [`-46`](https://www.rapidtables.com/convert/number/binary-to-decimal.html?x=11010010)

- could be a single 32 bits integer number `161877202` for MSB, or either [`3524044297` or `-770922999`](https://www.rapidtables.com/convert/number/binary-to-decimal.html?x=11010010000011001010011000001001) for LSB

- could be a 32 bits [floating point value](https://www.binaryconvert.com/result_float.html?hexadecimal=09A60CD2) `3.997510e-33`, or `0.0000000000000000000000000000000039975`

- could be any combination of the above, like one 16 bits signed integer, a 8 bits unsigned integer, and a signed 8 bits integer, and in any order

- could be written as hexadecimal `09A60CD2`16, `09a60cd2`16, `09a60cd2`hex, or `0x09A60CD2` and so on (much shorter and easier to read than ones and zeroes, isn’t it?)

- could also be written in Base64 as `CaYM0g==`, and that is what TTN uses

- …and could be written in many other ways in many more encodings

But no matter how you print it on the screen, when being transmitted and in your computer’s memory it’s still the binary ones and zeroes `00001001 10100110 00001100 11010010`2.

Decoding the Base64 value will give you the binary data again, which you can then decode into, for example, the two integer numbers 2470 and 3283 (which [could be temperature and humidity](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224)).

Like to see the hexadecimal representation of the Base64 encoded binary data, on a Mac one could type:

```
echo -n CaYM0g== | base64 --decode | xxd
0000000: 09a6 0cd2 ....

```

or:

```
echo -n CaYM0g== | base64 --decode | hexdump -C
00000000 09 a6 0c d2 |....|
00000004

```

…or to see it in bits:

```
echo -n CaYM0g== | base64 --decode | xxd -b
0000000: 00001001 10100110 00001100 11010010 ....

```

The 4 dots `....` indicate that the Mac cannot print the given bytes as plain text. That would be different if your node would send plain text (which it [should never do](https://www.thethingsnetwork.org/forum/t/best-practices-to-limit-application-payloads/1302)):

```
echo -n MjQ3MDszMjgz | base64 --decode | xxd
0000000: 3234 3730 3b33 3238 33 2470;3283

```

or:

```
echo -n MjQ3MDszMjgz | base64 --decode | hexdump -C
00000000 32 34 37 30 3b 33 32 38 33 |2470;3283|
00000009

```

How the Base64 decoding is done in your application depends on the programming language you’re using; Google Search is your friend for that.

---

_[View the full topic](https://www.thethingsnetwork.org/forum/t/how-to-send-payload-in-hex-format/8534)._
