Hallo everyone,
I have interfaced LIS3DH with nRF52832 and reading a value as below
X 230
Y 249
Z 54

How to convert this value to standard acceleration unit?
(im using 100Hz sample rate and 2g scale.)
Hallo everyone,
I have interfaced LIS3DH with nRF52832 and reading a value as below
X 230
Y 249
Z 54

How to convert this value to standard acceleration unit?
(im using 100Hz sample rate and 2g scale.)
The LIS3DH is an independent 3rd-party product - nothing to do with Nordic.
You need to study the LIS3DH documentation to answer this.
https://www.st.com/en/mems-and-sensors/lis3dh.html
For support with the LIS3DH, you need to contact the manufacturer - ST:
can you include your code and include files to interface the lis3dh with the nrf52842 hopefully with the I2c Sda,Scl? I'm stuck at a lot earlier stage than you.
Actually sometimes confusing, so maybe this would be of help. The values on the LIS2DH are signed but held in 2 x 8-bit registers which have to be handled with correct shift and sign-extension. Have a look at this (working) code to see if that helps:
typedef struct {
uint8_t OUT_d_L; // LIS2DH12_OUT_XYX_L
uint8_t OUT_d_H; // LIS2DH12_OUT_XYZ_H
}__attribute__((packed)) axis_t;
typedef union {
axis_t Bytes; // LIS2DH12_OUT_X_L, H 0x28, 0x29
int16_t sWord;
}__attribute__((packed)) axisUn_t;
typedef struct {
axisUn_t rOUT_X; // LIS2DH12_OUT_X_L,H 0x28,29
axisUn_t rOUT_Y; // LIS2DH12_OUT_Y_L,H 0x2A,2B
axisUn_t rOUT_Z; // LIS2DH12_OUT_Z_L,H 0x2C,2D
}__attribute__((packed)) reg2_t;
STATIC_ASSERT((offsetof(reg2_t, rOUT_X) & 0x01) == 0);
reg2_t Sea2; // Sea of byte registers
int16_t x, y, z;
/**
* @brief Collect signed xyz registers and correctly align for signed 16-bit
* @param
*/
void ReadXYZ(void)
{
ReadAccRegisters(); // <== this is your code to read the 6 consecutive 8-bit registers forming X, Y and Z
// Ensure we have correct sign extension, also assuming even byte alignment
x = Sea2.rOUT_X.sWord / 16;
y = Sea2.rOUT_Y.sWord / 16;
z = Sea2.rOUT_Z.sWord / 16;
}
Some care is required on alignment, since 8-bit values (packed, or cuddled up) must be sent to even-byte aligned 16-bit signed result registers. You can see from the byte addresses on the LIS2DH12 that they are sequential (cuddled up). The LIS3DH is similar.
Edit: Just noticed this is 5 months old, <sigh>
Hello @hmolesworth,
Indeed this case is 5 months old, but you reply should certainly prove useful to others coming here with a similar issue in the future!
Best regards,
Karl