<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to convert the value read by LIS3DH</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62970/how-to-convert-the-value-read-by-lis3dh</link><description>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.)</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Nov 2020 08:47:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62970/how-to-convert-the-value-read-by-lis3dh" /><item><title>RE: How to convert the value read by LIS3DH</title><link>https://devzone.nordicsemi.com/thread/280045?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2020 08:47:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5e55d27-5fa1-40bb-8cc1-65786a37b939</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello @hmolesworth,&lt;br /&gt;&lt;br /&gt;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! &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert the value read by LIS3DH</title><link>https://devzone.nordicsemi.com/thread/280025?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2020 00:13:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8883756a-4c88-4e9f-9165-f220571b0c4c</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;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) &amp;amp; 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(); // &amp;lt;== 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;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;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&amp;nbsp; that they are sequential (cuddled up). The LIS3DH is similar.&lt;/p&gt;
&lt;p&gt;Edit: Just noticed this is 5 months old, &amp;lt;sigh&amp;gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert the value read by LIS3DH</title><link>https://devzone.nordicsemi.com/thread/280006?ContentTypeID=1</link><pubDate>Sun, 15 Nov 2020 00:00:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4059c67b-9dcd-45db-afe3-a67fa020ed8d</guid><dc:creator>Mar</dc:creator><description>&lt;p&gt;can you include your code and include files to interface the lis3dh with the nrf52842 hopefully with the I2c Sda,Scl?&amp;nbsp; I&amp;#39;m stuck at a lot earlier stage than you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert the value read by LIS3DH</title><link>https://devzone.nordicsemi.com/thread/256646?ContentTypeID=1</link><pubDate>Wed, 24 Jun 2020 10:19:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8409e58-b248-4412-8586-1eb4eafcdc05</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;The LIS3DH is an independent 3rd-party product - nothing to do with Nordic.&lt;/p&gt;
&lt;p&gt;You need to study the&amp;nbsp;&lt;span&gt;LIS3DH&amp;nbsp; &lt;strong&gt;documentation&lt;/strong&gt; to answer this.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.st.com/en/mems-and-sensors/lis3dh.html"&gt;https://www.st.com/en/mems-and-sensors/lis3dh.html&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For support with the&amp;nbsp;LIS3DH, you need to contact the manufacturer - &lt;strong&gt;ST&lt;/strong&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://community.st.com/s/"&gt;https://community.st.com/s/&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>