LoRa frame decoding for beginners

nguillou
Posts: 41
Joined: Wed Jun 05, 2019 9:58 am
Company: ANIAN

Re: LoRa frame decoding for beginners

Post by nguillou » Sat Aug 31, 2019 8:51 am

Hi,

In a previous post you mentioned following :
"This is an example of decoding the payload
04 - secuence number
1d - lenght
34 - battery level sensor ID
64 - 100%
82 - pH sensor ID - float (size 4 bytes)
87112641 - 10.3792791366 pH
84 - DO sensor ID - float (size 4 bytes)
3e83c842 - 100.2563323974 %
.... and so on"

How do you go from Hex 87112641 to 10.3792791366 pH?

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: LoRa frame decoding for beginners

Post by libelium-dev » Mon Sep 02, 2019 8:02 am

Hi,

We use the following code to convert from hex to float.

Code: Select all

void setup()
{
  uint8_t l[] = {0x87, 0x11, 0x26, 0x41};
  float var1;
  memcpy(&var1, l, 4);
  USB.println(var1);
}

void loop()
{
}

nguillou
Posts: 41
Joined: Wed Jun 05, 2019 9:58 am
Company: ANIAN

Re: LoRa frame decoding for beginners

Post by nguillou » Mon Sep 02, 2019 10:00 am

Thanks a lot,

Strangely, when I use an hex to float conversion tool from Internet, the results return is -1.09198e-34 for 0x87112641

I prefers not to touch the device standard code and rather push the hex to float decoding in the IoT platform

Kind regards.

nguillou
Posts: 41
Joined: Wed Jun 05, 2019 9:58 am
Company: ANIAN

Re: LoRa frame decoding for beginners

Post by nguillou » Mon Sep 02, 2019 10:40 am

Ok found ti; the hexa needs to be read in reverse order to convert to float

Then should read 0x41261187 that giver 10.37....

Thanks for your help

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: LoRa frame decoding for beginners

Post by libelium-dev » Tue Sep 03, 2019 7:57 am

Hi,

Glad to hear that you solved the issue!

Regards

nguillou
Posts: 41
Joined: Wed Jun 05, 2019 9:58 am
Company: ANIAN

Re: LoRa frame decoding for beginners

Post by nguillou » Tue Sep 03, 2019 9:21 am

Hi,

I am still facing an issue with temperature sensor
For following payload "211d34528258923041846495d8428513d3213f8ba8c4e83e86c05c5e41", i get following parameters
"battery": 82,
"ph": 10.93702232,
"do2": 11.21490276,
"ec": 10.59181331,

nguillou
Posts: 41
Joined: Wed Jun 05, 2019 9:58 am
Company: ANIAN

Re: LoRa frame decoding for beginners

Post by nguillou » Tue Sep 03, 2019 9:24 am

Sorry , continuation of previous message. The temperature return looks wrong
"211d34528258923041846495d8428513d3213f8ba8c4e83e86c05c5e41"
"temp": 10.96703168

According to your experience, how do you calculate the temperature?

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: LoRa frame decoding for beginners

Post by libelium-dev » Wed Sep 04, 2019 10:14 am

Hi,

The conversion of the temperature value is 13.8976440429. We have calculated it using the same code that we shared in our previous post.

Regards

nguillou
Posts: 41
Joined: Wed Jun 05, 2019 9:58 am
Company: ANIAN

Re: LoRa frame decoding for beginners

Post by nguillou » Thu Sep 05, 2019 5:56 am

Hello,

Can someone from Libelium answer ?
In order to make it simple, can you decode this frame for Smart water device
211d34528258923041846495d8428513d3213f8ba8c4e83e86c05c5e41

....And feedback if the values are i the range

We have5 more Libelium devices on the way to our office now and we need to make them work.

Kind regards

nguillou
Posts: 41
Joined: Wed Jun 05, 2019 9:58 am
Company: ANIAN

Re: LoRa frame decoding for beginners

Post by nguillou » Thu Sep 05, 2019 6:06 am

libelium-dev wrote:
Wed Sep 04, 2019 10:14 am
Hi,

The conversion of the temperature value is 13.8976440429. We have calculated it using the same code that we shared in our previous post.

Regards
Sorry have not seen your answer. Best is to have full decoding of payload and understand if data is in the range

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest