Search code examples
movesense

Why is the debug log output of Acc data different from the showcase app results?


Currently, I am working on a Movesense acceleration sensor. I want the data for each axis inside the sensor to be the same as the axis data shown in the ACC graph in the showcase app. I'm getting the data. I checked that data in the debug log output but the values are different from the ACC graph. I'm not sure what I'm doing wrong.

In addition, there is another issue. I've declared the variables for each axis in float. For example, float x, float y, float z. If I'm printing each variable with %f or %0.6f, I'm getting an empty value in the debug log output. If I'm using %d instead of %f, it gives the result, but the values aren't matching with the showcase app output.

I'm attaching the debug log output video and the showcase app output screenshot. please check that as well.

video: Movesense ACC data debug log error

Showcase app Image: https://i.sstatic.net/Zueft.jpg

Code link: https://drive.google.com/file/d/1A29ZWY8E3oUsp0cfPqubfbApjoCYybWh/view?usp=share_link

So how can I get the correct x, y, and z-axis values inside the sensor?


Solution

  • The reason is that the snprinf formatting on sensor (which the DEBUGLOG macro calls) does not support formatting of floating point numbers (%f). The tries to print the same number as integer which is obviously wrong since it's a float.

    To get some kind of idea of sensor values, use the following style:

    DEBUGLOG("test: %d", (int)(acc.x*10))
    

    which prints out the numbers as integer (10 timest too big, but otherwise correct).