Extracting Int values from Ascii strings received for motion data[rawdata][RPi][Python3]

I am able to receive motion data [rawdata] from thingy52 on my RPi 4 using bluepy library in Python3.

I want to extract the raw values of Gyro/Accl/Mag from sensor.

The data is received as byte-strings:

Notification: Rotation matrix: b'\xb4\xd9\xe8+}\x1a\xcf.n+\xae\xfb\x0f\xeb\xca\x10\xe6\xc5'

Based on the documentation, the length of byte-string matches the data size(18 bytes), but where can I find the representation of this data?

How can I recover values in a format suitable for plotting?


No Data
  • There's some information missing here, like what exact register you're reading or what documentation you've found the '18 bytes' information in. However scanning the documentation of the mpu9250, which is the chip in the Thingy:52, it says 

    "Measurement data is stored in two’s complement and Little Endian format. Measurement range of each axis is from -32760 ~ 32760 decimal in 16-bit output."

    So that's 2 bytes per measurement, or 6 bytes for a complete XYZ sequence, so I'm guessing your 18 bytes are XYZ for gyro/accel/mag in which case you just need python unpack to unpack them

    import struct
    a = b'\xb4\xd9\xe8+}\x1a\xcf.n+\xae\xfb\x0f\xeb\xca\x10\xe6\xc5'
    --> (-9804, 11240, 6781, 11983, 11118, -1106, -5361, 4298, -14874)