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,

    Seems like I have some misunderstanding about the device outputs. Please help me in clarifying few queries of mine.

    Expectation : I am trying to build a toy, which would measure the approximate force applied on this device from any direction.

    So my problem is to measure the change in acceleration. But this device is giving me acceleration only in range (0.0 - 1.0) and no negative values, from accelerometer. I tried to scale the values but it will be of not much help because of the range which is always positive.

    As you suggested I tried using gravity vector as well but below are my observations.

    1. Gravity vector is giving all the values in range -9.8 to 9.8. But how I measure the force/acceleration on the Z axis, gravity axis, as it is going to always a constant.

    2. Gravity vector will only help in identifying device orientation, but I need to identify the applied force to move this device.

    Please help in clarifying my queries.

    Thanks you in advance.

    Regards,

    K.Prabhakar

  • Thanks for clearing up. 

    Firstly. The documentation states that the raw data from the accelerometer is in Gs, just do make that clear. Hence, if you want m/s2 the raw data must be divided by 9.8. 

    However, the values you posted earlier does seem weird. Could you try to subtract 2 from every value and divide by 1G. It seems like the values are offset by 2G :) 

    Best regards,
    Carl Richard

  • Hi Carl,

    I have implemented as you suggested. Below is my code 

    peripheral.beginRawDataUpdates(withCompletoinHandler: { (success) -> (Void) in

                    NSLog("Raw Data Update")

                }) { (acc, gyro, compose) -> (Void) in

                    var trimmedX = (acc[0] - 2.0)/9.8

                    var trimmedY = (acc[1] - 2.0)/9.8

                    var trimmedZ = (acc[2] - 2.0)/9.8

                    if abs(trimmedX) < 0.05 {

                        trimmedX = 0.0

                    }

                    if abs(trimmedY) < 0.05 {

                        trimmedY = 0.0

                    }

                    if abs(trimmedZ) < 0.05 {

                        trimmedZ = 0.0

                    }

                    NSLog("trimmed X: \(trimmedX), Y: \(trimmedY), Z:\(trimmedZ)")

                }

    But I didn't see the output I was expecting. Please find the log below while I was shaking the device.

    2020-08-28 12:12:25.971478+0530 TestThingy[706:49448] trimmed X: -0.2040754, Y: 0.0, Z:-0.20095825

    2020-08-28 12:12:26.061594+0530 TestThingy[706:49448] trimmed X: -0.20329377, Y: -0.20396952, Z:-0.20080255

    2020-08-28 12:12:26.181168+0530 TestThingy[706:49448] trimmed X: -0.20334049, Y: -0.20303842, Z:-0.19916767

    2020-08-28 12:12:26.271155+0530 TestThingy[706:49448] trimmed X: 0.0, Y: 0.0, Z:-0.2011451

    2020-08-28 12:12:26.361205+0530 TestThingy[706:49448] trimmed X: -0.20364878, Y: 0.0, Z:-0.20216027

    2020-08-28 12:12:26.481102+0530 TestThingy[706:49448] trimmed X: -0.19780372, Y: -0.20232843, Z:-0.20008631

    2020-08-28 12:12:26.571227+0530 TestThingy[706:49448] trimmed X: -0.19770408, Y: -0.19878154, Z:-0.20184264

    2020-08-28 12:12:26.661201+0530 TestThingy[706:49448] trimmed X: -0.19885628, Y: -0.20355847, Z:-0.19991817

    2020-08-28 12:12:26.781093+0530 TestThingy[706:49448] trimmed X: -0.20280176, Y: 0.0, Z:-0.20059702

    2020-08-28 12:12:26.871109+0530 TestThingy[706:49448] trimmed X: 0.0, Y: 0.0, Z:-0.20178658

    2020-08-28 12:12:26.991072+0530 TestThingy[706:49448] trimmed X: -0.20233466, Y: 0.0, Z:-0.19944483

    2020-08-28 12:12:27.081696+0530 TestThingy[706:49448] trimmed X: -0.19770408, Y: -0.20360518, Z:-0.19858535

    2020-08-28 12:12:27.171119+0530 TestThingy[706:49448] trimmed X: -0.19770408, Y: -0.19770408, Z:-0.19949153

    2020-08-28 12:12:27.261592+0530 TestThingy[706:49448] trimmed X: -0.1988656, Y: 0.0, Z:-0.20040706

    2020-08-28 12:12:27.381122+0530 TestThingy[706:49448] trimmed X: 0.0, Y: 0.0, Z:-0.20167136

    2020-08-28 12:12:27.471149+0530 TestThingy[706:49448] trimmed X: 0.0, Y: 0.0, Z:-0.20258689

    2020-08-28 12:12:27.561099+0530 TestThingy[706:49448] trimmed X: -0.19964412, Y: -0.19770408, Z:-0.19770408

    2020-08-28 12:12:27.681090+0530 TestThingy[706:49448] trimmed X: -0.2024561, Y: -0.20305088, Z:-0.20010188

    2020-08-28 12:12:27.771100+0530 TestThingy[706:49448] trimmed X: 0.0, Y: 0.0, Z:-0.20204194

    2020-08-28 12:12:27.980452+0530 TestThingy[706:49448] trimmed X: 0.0, Y: 0.0, Z:-0.20107658

    2020-08-28 12:12:27.981793+0530 TestThingy[706:49448] trimmed X: 0.0, Y: 0.0, Z:-0.20020154

    2020-08-28 12:12:28.071640+0530 TestThingy[706:49448] trimmed X: 0.0, Y: 0.0, Z:-0.20079944

    2020-08-28 12:12:28.161182+0530 TestThingy[706:49448] trimmed X: 0.0, Y: 0.0, Z:-0.20103921

  • Hi Carl,

    Solving this problem is important to me. Request you to help.

    Thanks & Regards,

    K.Prabhakar

  • Hello again!

    My apologies. I mixed up my unit conversion. You should multiply by 9.8. Hopefully that will result in correct values.

    Best regards,
    Carl Richard

Related