# Encoding message sent to TTN

**URL:** <https://www.thethingsnetwork.org/forum/t/encoding-message-sent-to-ttn/67609>\
**Category:** Heltec CubeCell\
**Tags:** end-devices\
**Created:** [April 16, 2024, 9:46pm UTC](https://www.thethingsnetwork.org/forum/t/encoding-message-sent-to-ttn/67609 "2024-04-16T21:46:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kriistobal](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kriistobal/32/46319_2.png) [@kriistobal](https://www.thethingsnetwork.org/forum/u/kriistobal)\
**Post date:** [April 16, 2024, 9:46pm UTC](https://www.thethingsnetwork.org/forum/t/encoding-message-sent-to-ttn/67609/1 "2024-04-16T21:46:23Z")

</div>

Hi folks 😁 i have a question and i’m a newbie with this lorawan stuff.

To put in context, i’m programming the heltec wireless stick board with the ESP-IDF framework and i use a component (ttn from manuelbl) for the connection to ttn. i also have an ug65 gateway from milesight.

I send the following string “ **102100 2.4 21.3** ” which are pressure, altitude and temperature respectively. But in ttn i get “ **31 30 32 31 30 30 30 20 32 2e 34 20 32 31 2e 33** ”.

My question is who does the encoding of the message to bytes so that it appears like this in ttn? and if there is another more optimal way to encode it before sending it?

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [April 16, 2024, 11:13pm UTC](https://www.thethingsnetwork.org/forum/t/encoding-message-sent-to-ttn/67609/2 "2024-04-16T23:13:21Z")

</div>

> [@kriistobal](#):
>
> I send the following string

Not very efficient use of the airwaves - search TTN Forum for “working with bytes” & check out the TTN Docs (ignore banner - works for V3 as much as old V2!) [https://www.thethingsnetwork.org/docs/devices/bytes/](https://www.thethingsnetwork.org/docs/devices/bytes/)

Also a text string is typically ASCII - look again at your output from TTN (as HEX) and follow the numbers (pairs) (Unicode would actually be worse needing 3 bytes/character!) [https://www.techonthenet.com/ascii/chart.php](https://www.techonthenet.com/ascii/chart.php)

---

<div class="post-metadata">

**Author:** ![Johan\_Scheepers](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/johan_scheepers/32/46550_2.png) [@Johan\_Scheepers](https://www.thethingsnetwork.org/forum/u/Johan_Scheepers)\
**Post date:** [April 17, 2024, 7:27am UTC](https://www.thethingsnetwork.org/forum/t/encoding-message-sent-to-ttn/67609/3 "2024-04-17T07:27:33Z")

</div>

There are a few extent post on working with bytes and how you should send your data over LoRaWAN.

If you encode your data to hex and decode, you save a lot on air time and battery life.

If you search the forum lots of recourses.

> [@Decrypting messages for dummies](https://www.thethingsnetwork.org/forum/t/decrypting-messages-for-dummies/4894/3):
>
> Thank you a lot, you have really clarified some basic facts. For this purpose is LoraEncoder function - for example to change measured value to number representation of this value, isn’t it? To be sure that this is the right way: way from measured Temp=23.45 to 0x09 0x29 on the TTN Application data page with as small payload as it possible is (from Arduino): float Temp = 23.45; LoraEncoder encoder(buffer); encoder.writeTemperature(Temp); LMIC\_setTxData2(1, buffer, strlen((char \*)buffer), 0)…

---

<div class="post-metadata">

**Author:** ![system](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/6/2/6250ea44fd2b0d6259489e1a92748df681e1f970.png) [@system](https://www.thethingsnetwork.org/forum/u/system)\
**Post date:** [June 12, 2024, 9:09pm UTC](https://www.thethingsnetwork.org/forum/t/encoding-message-sent-to-ttn/67609/4 "2024-06-12T21:09:05Z")

</div>

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