Parse pressure data from Telemetry pack

#1

Hello everyone,

I am currently trying to parse the raw hex Data advertised by the Telemetry Package. I can get the raw data and write it to a file that is no problem.
I managed to parse everything except for the pressure Data which is encoded in byte 16 to 19. Maybe some one can help me to understand the example given by estimote:

%% ***** ATMOSPHERIC PRESSURE
% added in protocol version "2"
% bytes 16, 17, 18, 19 => atmospheric pressure RAW_VALUE
% RAW_VALUE is an unsigned 32-bit integer, little-endian encoding,
% i.e., least-significant byte comes first
% e.g., if bytes are 16th = 0x12, 17th = 0x34, 18th = 0x56, 19th = 0x78
% then the value is 0x78563412
% RAW_VALUE / 256.0 = atmospheric pressure in pascals (Pa)
% note that unlike what you see on the weather forecast, this value is
% not normalized to the sea level!

For me it comes down to this:
16th = 0x12 = 0b00010010
17th = 0x34 = 0b00110100
18th = 0x56 = 0b01010110
19th = 0x78 = 0b01111000

So 0x78563412 should be:
0b 01111000 01010110 00110100 00010010 in binary which is
2018915346 in dec

But 2018915346/256 = 7886388,07 Pa which is 78,8638807 bar and that is way to much even if its not normalized to see level

I assume that my mistake lies somewhere with the little-endian encoding. Would be nice if you could help me out. :slight_smile:

#2

Do you really have 0x12 0x34 0x56 0x78 in your packet? In the description, those are just example bytes to explain the endianness (:

#3

Hello thanks for your answer!

No, in my packet I have 16th = 0xFC, 17th = 0x98, 18th = 0x88, 19th = 01. When I get the example right that would add up to:
0x018898FC in Hex
0b00000001 10001000 10011000 11111100 in bit
25729276 in dec

I found my mistake:
Somhow I messed up the conversion from hex to dec. I first got:
0x018898FC -> 1136152252 (wrong) which is each byte by itself :man_facepalming:
But now i get:
0x018898FC -> 25729276 (right)

Which leads to a pressure of 100504.9844 Pa (1.00504 bar) :+1:t3:
Thanks for giving me a hint in the right direction. I thought the example given would also end up in a realistic result.

#4

Glad to hear you’ve figured it out!

I updated the comment to use realistic values (your values ;))

How do you plan to use the pressure data? (:

#5

I am training an artificial neural network for indoor localization in an industrial environment.
Since pressure value relates to height my network might learn to use that data to get a better precision.

Good idea!

1 Like