# Readings Coming Back As Random Numbers

**URL:** <https://www.thethingsnetwork.org/forum/t/readings-coming-back-as-random-numbers/55346>\
**Category:** End Devices (Nodes)\
**Created:** [February 20, 2022, 7:45pm UTC](https://www.thethingsnetwork.org/forum/t/readings-coming-back-as-random-numbers/55346 "2022-02-20T19:45:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [February 20, 2022, 7:45pm UTC](https://www.thethingsnetwork.org/forum/t/readings-coming-back-as-random-numbers/55346/1 "2022-02-20T19:45:23Z")

</div>

I’m trying to send a time packet to the things network. I’m doing this by using a NEO-6M GPS, with the Adafruit\_GPS library. However, say the time was 19:39:40, it will come back as this:  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/d/f/df4738a2b60e3b06d94a59d86bce4d1ae075b6e6.png)  
Not entirely sure why it’s doing this, as the serial monitor outputs the correct time.

I have combined the GPS.hour, GPS.minutes and GPS.seconds together like this:

```auto
timePacket = packetHour + packetMinute + packetSeconds;
uint32_t timeSend = stringToUint(timePacket);
uint32_t timePayload = timeSend;

```

I use a function to turn the data type from String to Long or uint32\_t:

```auto
uint32_t stringToUint(String s) {
  char arr[7];
  s.toCharArray(arr, sizeof(arr));
  return atol(arr);
}

```

Here is the payload formatter:

```auto
function decodeUplink(input) {
  var data = {};
  var sensorDistance = (input.bytes[0] << 8) + input.bytes[1];
  data.distance = sensorDistance;
  return {
    data: data,
  };
}

```

I’m not entirely sure why it’s doing this, as all other data reads correct. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![SEAN\_K](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/sean_k/32/35697_2.png) [@SEAN\_K](https://www.thethingsnetwork.org/forum/u/SEAN_K)\
**Post date:** [February 20, 2022, 8:02pm UTC](https://www.thethingsnetwork.org/forum/t/readings-coming-back-as-random-numbers/55346/2 "2022-02-20T20:02:37Z")

</div>

[https://www.thethingsnetwork.org/docs/devices/bytes/](https://www.thethingsnetwork.org/docs/devices/bytes/)

I’ve just stumbled across this, turns out the value I’m trying to send is higher than 255. I think it would be better splitting it up which is what I was trying to avoid.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [February 20, 2022, 10:36pm UTC](https://www.thethingsnetwork.org/forum/t/readings-coming-back-as-random-numbers/55346/3 "2022-02-20T22:36:47Z")

</div>

> [@SEAN\_K](#):
>
> I’ve just stumbled across this

Did you read the other materials suggested to you?

---

<div class="post-metadata">

**Author:** ![cslorabox](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cslorabox/32/35697_2.png) [@cslorabox](https://www.thethingsnetwork.org/forum/u/cslorabox)\
**Post date:** [February 21, 2022, 3:11pm UTC](https://www.thethingsnetwork.org/forum/t/readings-coming-back-as-random-numbers/55346/4 "2022-02-21T15:11:40Z")

</div>

> [@SEAN\_K](#):
>
> I’m trying to send a time packet to the things network.

Why would that be useful? The network already knows what time it is, and LoRaWAN networks require a strong focus on optimizing airtime, including by not sending unnecessary information.

The real solution to this is to focus on why there is a need for time information, and then figure out the most efficient way to accomplish that.

Why can’t the packet time metadata added on receipt by the network be used?
