This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Thingy 52: Motion sensor (accelerometer) raw data in IOS is giving unit vector, I was expecting more of a m/s2 values. Is my assumption wrong?

Hi, 

I am using Thingy 52 to measure the acceleration from accelerometer. I was expecting values like m/s2 but I am seeing values in unit vector, ie, values between (0 - 1.0), I can't see negative values as well. How do I get actual values, ie, > 1? Please hep if my understanding is wrong.

  • Hi Carl,

    Thanks for the update.

    I have seen below code for Android

    final float mAccelerometerX = (float) (characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16, 0)) / (1 << 10);

    final float mAccelerometerY = (float) (characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16, 2)) / (1 << 10);

    final float mAccelerometerZ = (float) (characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16, 4)) / (1 << 10);

    And for IOS below is the code

    accelerometerData.append(Float(rawData.asValue(offset: 0) as UInt16) / Float(2 << 14))

    accelerometerData.append(Float(rawData.asValue(offset: 2) as UInt16) / Float(2 << 14))

    accelerometerData.append(Float(rawData.asValue(offset: 4) as UInt16) / Float(2 << 14))

    For android signed int is considered and for IOS it is unsignedINT. Please help me in understanding this part because I have to build the app for both IOS and Android. And if you notice the bit shifting is also different for both of the platforms.

    Regards,

    K.Prabhakar

  • Hello!

    I am not sure why this is,  but I guess is down to developer preference. To be sure that the conversion results are the same for both applications I recommend doing an output comparison if possible. For you info the values are encoded in the Q number format.

    Best regards,
    Carl Richard

Related