Search code examples
pythonhexbyteraw-data

What kind of data is this, and how do I turn it to human readable form with python?


I'm pulling data out from DA-14585 IoT device. I'm getting a report from the temperature sensor which is as follows:

a50f060203d10900000b020390290000

Reading the documentation (search for table 12) tells me that

a5 is preamble

0f is timestamp

06 is the sensor id (temperature)

02 is the sensor state (always 2)

03 is the sensor value (always 3)

d10900000b020390290000 is the actual sensor data, which is listed as "Val32".

Mainly I'm wondering, what format is this data in, and how would one go with turning this into a human readable form? Same goes for the timestamp, which is 0f.

I'm mainly working with Python.


Solution

  • Val32 is a 32-bit integer (little-endian by the look of things). In your example, d1090000. What follows thereafter is a subsequent message which will need to be decoded separately (it has the same format and is of type GAS_REPORT_ID).

    Since 0x000009d1 = 2513, if I were to guess I'd say this is in hundredths of degrees C, i.e. 25.13C (assuming this is ambient temperature and not, say, a reading from an oven). Please don't rely on my guesswork though and read the relevant specs. :)

    You could use the struct module to unpack the binary data in Python.