cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DH12 Measure conversion

P M
Associate II
Posted on June 06, 2017 at 09:20

I am having some problems when I try to get data from my sensor. I can read registers and get some data but I don't know how I should do the covnersion to get a real value.

I am using an arduino and I found some libraries. Those libraries tend to use this format:

x = ((int8_t)sensorData[1])*256+sensorData[0];

y = ((int8_t)sensorData[3])*256+sensorData[2];

z = ((int8_t)sensorData[5])*256+sensorData[4];

Where position 0 of sensorData starts at OUT_X_L (28h) and goes up.

Is this right? I have read something about left justified of LSB and I think it should be like:

Is it the same?

Apart from that, they use a formula to get mg values from the x,y and z values:

x = (int32_t)x*1000/(1024*mgScaleVel); //transform data to millig, for 2g scale axis*1000/(1024*16),

y = (int32_t)y*1000/(1024*mgScaleVel); //for 4g scale axis*1000/(1024*8),

z = (int32_t)z*1000/(1024*mgScaleVel); //for 8g scale axis*1000/(1024*4)

What is this about? where does this formula appear? Is it correct? How should I parse the data?

#lis2dh12
10 REPLIES 10
Posted on June 12, 2017 at 14:10

To activate ZH and ZL at the same time doesn't make sense, if you use OR combination the interrupt will be always triggered (acceleration is always higher or lower than threshold), if you use AND combination it won't be never triggered (acceleration cannot be higher and lower than threshold at the same time).

You can set the duration to 0, it means the interrupt is triggered immediately when the threshold is reached.