<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic MMA8451 on Raspberry Pi returns incorrect whoami in Sensors</title>
    <link>https://community.nxp.com/t5/Sensors/MMA8451-on-Raspberry-Pi-returns-incorrect-whoami/m-p/737829#M4747</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm currently working on connecting and reading an MMA8451 with a raspberry pi running C code. I've got the code up and running, and i can't find any reason why the accelerometer should be returning an incorrect whoami (currently sending 0xff). Here is the code i use to initialize the accelerometer:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE data-tab-size="8" style="color: #24292e; background-color: #ffffff; width: 757px;"&gt;&lt;TBODY&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 42px;"&gt;mma8451 &lt;SPAN class="" style="color: #6f42c1;"&gt;mma8451_initialise&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #d73a49;"&gt;int&amp;nbsp;&lt;/SPAN&gt;device&amp;nbsp;&lt;SPAN class="" style="color: #d73a49;"&gt;int&amp;nbsp;&lt;/SPAN&gt;addr)&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="107" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;{&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="108" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;mma8451 handle;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="109" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt; = -&lt;SPAN class="" style="color: #005cc5;"&gt;1&lt;/SPAN&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="110" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;handle.&lt;SPAN class="" style="color: #24292e;"&gt;address&lt;/SPAN&gt; = addr;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="111" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;char&lt;/SPAN&gt; buf[&lt;SPAN class="" style="color: #005cc5;"&gt;15&lt;/SPAN&gt;];&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="112" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="113" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"Initalising MMA8451 sensor at address &lt;SPAN class="" style="color: #005cc5;"&gt;%#02x&lt;/SPAN&gt;&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;, addr);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="114" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="115" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Open /dev/i2c-x file without a buffer&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="116" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;sprintf&lt;/SPAN&gt;(buf, &lt;SPAN class="" style="color: #032f62;"&gt;"/dev/i2c-&lt;SPAN class="" style="color: #005cc5;"&gt;%d&lt;/SPAN&gt;"&lt;/SPAN&gt;, device);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="117" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;if&lt;/SPAN&gt; ((handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt; = &lt;SPAN class="" style="color: #005cc5;"&gt;open&lt;/SPAN&gt;(buf, O_RDWR)) &amp;lt; &lt;SPAN class="" style="color: #005cc5;"&gt;0&lt;/SPAN&gt;)&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="118" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;{&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="119" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt; = -&lt;SPAN class="" style="color: #005cc5;"&gt;2&lt;/SPAN&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="120" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;return&lt;/SPAN&gt; handle;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="121" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;}&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="122" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="123" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Configure slave i2c address via ioctl&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="124" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;if&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #005cc5;"&gt;ioctl&lt;/SPAN&gt;(handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt;, I2C_SLAVE, addr) &amp;lt; &lt;SPAN class="" style="color: #005cc5;"&gt;0&lt;/SPAN&gt;)&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="125" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;{&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="126" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt; = -&lt;SPAN class="" style="color: #005cc5;"&gt;3&lt;/SPAN&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="127" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;return&lt;/SPAN&gt; handle;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="128" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;}&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="129" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="130" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Check if we read correctly from the sensor&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="131" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;char&lt;/SPAN&gt; whoami = &lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_read_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x0D&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="132" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"whoami read &lt;SPAN class="" style="color: #005cc5;"&gt;%#02x&lt;/SPAN&gt;&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;, whoami);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="133" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" data-line-number="134" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 50px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Undefined behavior for the rest of device operation if the device is not returning hex 1A&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" data-line-number="135" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 50px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;if&lt;/SPAN&gt;(whoami != &lt;SPAN class="" style="color: #005cc5;"&gt;0x1A&lt;/SPAN&gt;) &lt;SPAN class="" style="color: #005cc5;"&gt;perror&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"mma451_pi warning: Device correctly intialized but not returning 0x1A at WHO_AM_I request.&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" data-line-number="136" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 50px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 673px;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"Are you sure you are using a MMA8451 accelerometer on this address?"&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="137" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="138" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Send reset request&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="139" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x2B&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0x40&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="140" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"Waiting for accelerometer to be reset&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="141" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;while&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_read_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x2B&lt;/SPAN&gt;) &amp;amp; &lt;SPAN class="" style="color: #005cc5;"&gt;0x40&lt;/SPAN&gt;); &lt;SPAN class="" style="color: #6a737d;"&gt;//reset done&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="142" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"Done&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="143" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="144" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_set_range&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;2&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="145" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x2B&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0x02&lt;/SPAN&gt;); &lt;SPAN class="" style="color: #6a737d;"&gt;//high resolution mode&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" data-line-number="146" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 50px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x2A&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0x01&lt;/SPAN&gt; | &lt;SPAN class="" style="color: #005cc5;"&gt;0x04&lt;/SPAN&gt;); &lt;SPAN class="" style="color: #6a737d;"&gt;//high rate low noise&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="147" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="148" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Deactivate fifo&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="149" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x09&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="150" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//turn on orientation configuration&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="151" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x11&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0x40&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="152" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 75px;"&gt;&lt;TD class="" data-line-number="153" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 75px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 75px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"MMA8451 at address &lt;SPAN class="" style="color: #005cc5;"&gt;%#02x&lt;/SPAN&gt; configured for real time sampling, in high rate, low noise mode, at high resolution, on a 2G max range&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;, addr);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="154" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="155" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;return&lt;/SPAN&gt; handle;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="156" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;P&gt;}&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is directly from the mma8451_pi library found here:&amp;nbsp;&lt;A href="https://github.com/Ybalrid/mma8451_pi" target="_blank"&gt;https://github.com/Ybalrid/mma8451_pi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas what could be causing it to return an incorrect whoami?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Feb 2026 22:20:10 GMT</pubDate>
    <dc:creator>tsnealon</dc:creator>
    <dc:date>2026-02-03T22:20:10Z</dc:date>
    <item>
      <title>MMA8451 on Raspberry Pi returns incorrect whoami</title>
      <link>https://community.nxp.com/t5/Sensors/MMA8451-on-Raspberry-Pi-returns-incorrect-whoami/m-p/737829#M4747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm currently working on connecting and reading an MMA8451 with a raspberry pi running C code. I've got the code up and running, and i can't find any reason why the accelerometer should be returning an incorrect whoami (currently sending 0xff). Here is the code i use to initialize the accelerometer:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE data-tab-size="8" style="color: #24292e; background-color: #ffffff; width: 757px;"&gt;&lt;TBODY&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 42px;"&gt;mma8451 &lt;SPAN class="" style="color: #6f42c1;"&gt;mma8451_initialise&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #d73a49;"&gt;int&amp;nbsp;&lt;/SPAN&gt;device&amp;nbsp;&lt;SPAN class="" style="color: #d73a49;"&gt;int&amp;nbsp;&lt;/SPAN&gt;addr)&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="107" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;{&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="108" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;mma8451 handle;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="109" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt; = -&lt;SPAN class="" style="color: #005cc5;"&gt;1&lt;/SPAN&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="110" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;handle.&lt;SPAN class="" style="color: #24292e;"&gt;address&lt;/SPAN&gt; = addr;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="111" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;char&lt;/SPAN&gt; buf[&lt;SPAN class="" style="color: #005cc5;"&gt;15&lt;/SPAN&gt;];&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="112" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="113" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"Initalising MMA8451 sensor at address &lt;SPAN class="" style="color: #005cc5;"&gt;%#02x&lt;/SPAN&gt;&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;, addr);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="114" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="115" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Open /dev/i2c-x file without a buffer&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="116" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;sprintf&lt;/SPAN&gt;(buf, &lt;SPAN class="" style="color: #032f62;"&gt;"/dev/i2c-&lt;SPAN class="" style="color: #005cc5;"&gt;%d&lt;/SPAN&gt;"&lt;/SPAN&gt;, device);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="117" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;if&lt;/SPAN&gt; ((handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt; = &lt;SPAN class="" style="color: #005cc5;"&gt;open&lt;/SPAN&gt;(buf, O_RDWR)) &amp;lt; &lt;SPAN class="" style="color: #005cc5;"&gt;0&lt;/SPAN&gt;)&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="118" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;{&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="119" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt; = -&lt;SPAN class="" style="color: #005cc5;"&gt;2&lt;/SPAN&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="120" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;return&lt;/SPAN&gt; handle;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="121" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;}&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="122" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="123" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Configure slave i2c address via ioctl&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="124" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;if&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #005cc5;"&gt;ioctl&lt;/SPAN&gt;(handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt;, I2C_SLAVE, addr) &amp;lt; &lt;SPAN class="" style="color: #005cc5;"&gt;0&lt;/SPAN&gt;)&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="125" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;{&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="126" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;handle.&lt;SPAN class="" style="color: #24292e;"&gt;file&lt;/SPAN&gt; = -&lt;SPAN class="" style="color: #005cc5;"&gt;3&lt;/SPAN&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="127" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;return&lt;/SPAN&gt; handle;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="128" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;}&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="129" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="130" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Check if we read correctly from the sensor&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="131" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;char&lt;/SPAN&gt; whoami = &lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_read_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x0D&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="132" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"whoami read &lt;SPAN class="" style="color: #005cc5;"&gt;%#02x&lt;/SPAN&gt;&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;, whoami);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="133" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" data-line-number="134" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 50px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Undefined behavior for the rest of device operation if the device is not returning hex 1A&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" data-line-number="135" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 50px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;if&lt;/SPAN&gt;(whoami != &lt;SPAN class="" style="color: #005cc5;"&gt;0x1A&lt;/SPAN&gt;) &lt;SPAN class="" style="color: #005cc5;"&gt;perror&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"mma451_pi warning: Device correctly intialized but not returning 0x1A at WHO_AM_I request.&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" data-line-number="136" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 50px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 673px;"&gt;&lt;SPAN class="" style="color: #032f62;"&gt;"Are you sure you are using a MMA8451 accelerometer on this address?"&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="137" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="138" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Send reset request&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="139" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x2B&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0x40&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="140" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"Waiting for accelerometer to be reset&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="141" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;while&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_read_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x2B&lt;/SPAN&gt;) &amp;amp; &lt;SPAN class="" style="color: #005cc5;"&gt;0x40&lt;/SPAN&gt;); &lt;SPAN class="" style="color: #6a737d;"&gt;//reset done&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="142" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"Done&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="143" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="144" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_set_range&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;2&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="145" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x2B&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0x02&lt;/SPAN&gt;); &lt;SPAN class="" style="color: #6a737d;"&gt;//high resolution mode&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 50px;"&gt;&lt;TD class="" data-line-number="146" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 50px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 50px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x2A&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0x01&lt;/SPAN&gt; | &lt;SPAN class="" style="color: #005cc5;"&gt;0x04&lt;/SPAN&gt;); &lt;SPAN class="" style="color: #6a737d;"&gt;//high rate low noise&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="147" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="148" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//Deactivate fifo&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="149" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x09&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="150" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #6a737d;"&gt;//turn on orientation configuration&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="151" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;mma8451_write_byte&lt;/SPAN&gt;(&amp;amp;handle, &lt;SPAN class="" style="color: #005cc5;"&gt;0x11&lt;/SPAN&gt;, &lt;SPAN class="" style="color: #005cc5;"&gt;0x40&lt;/SPAN&gt;);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="152" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 75px;"&gt;&lt;TD class="" data-line-number="153" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 75px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 75px; width: 673px;"&gt;&lt;SPAN class="" style="color: #005cc5;"&gt;printf&lt;/SPAN&gt;(&lt;SPAN class="" style="color: #032f62;"&gt;"MMA8451 at address &lt;SPAN class="" style="color: #005cc5;"&gt;%#02x&lt;/SPAN&gt; configured for real time sampling, in high rate, low noise mode, at high resolution, on a 2G max range&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;"&lt;/SPAN&gt;, addr);&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="154" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="155" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;SPAN class="" style="color: #d73a49;"&gt;return&lt;/SPAN&gt; handle;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD class="" data-line-number="156" style="color: rgba(27, 31, 35, 0.3); padding: 0px 10px; height: 25px; width: 42px;"&gt;&lt;/TD&gt;&lt;TD class="" style="color: #24292e; padding: 0px 10px; height: 25px; width: 673px;"&gt;&lt;P&gt;}&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is directly from the mma8451_pi library found here:&amp;nbsp;&lt;A href="https://github.com/Ybalrid/mma8451_pi" target="_blank"&gt;https://github.com/Ybalrid/mma8451_pi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas what could be causing it to return an incorrect whoami?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2026 22:20:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MMA8451-on-Raspberry-Pi-returns-incorrect-whoami/m-p/737829#M4747</guid>
      <dc:creator>tsnealon</dc:creator>
      <dc:date>2026-02-03T22:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: MMA8451 on Raspberry Pi returns incorrect whoami</title>
      <link>https://community.nxp.com/t5/Sensors/MMA8451-on-Raspberry-Pi-returns-incorrect-whoami/m-p/737830#M4748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have an oscilloscope or a logic analyzer, can you please post here a plot illustrating what is going on the bus when you read the WHO_AM_I register?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also please make sure you are using correct slave address depending on the connection of the SA0 pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/61381i7F37A9B974746924/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Tomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2018 10:52:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MMA8451-on-Raspberry-Pi-returns-incorrect-whoami/m-p/737830#M4748</guid>
      <dc:creator>TomasVaverka</dc:creator>
      <dc:date>2018-05-31T10:52:08Z</dc:date>
    </item>
  </channel>
</rss>

