title: int16_t to float MPU6050 accel reading overflow in arduino
body: <p>I'm having some trouble to identify why sometimes I get strange values and overflow from MPU6050 sensor. 
  I have an ATM328P micro reading values from a DROTEK 10 DOF IMU sensor, one of these values is the acceleration one, and it sometimes become ovf or behaves in a weird way. This is the code I'm using for it:</p>
  
  <pre><code>#include&lt;Wire.h&gt;
  const int MPU=0x69;
  int16_t ax,ay,az;
  float acc[3] = {0, 0, 0};
  float S = 0.00006103515625; // scale factor g/LSB 4/65536
  
  void setup(){
    Wire.begin();
    Wire.beginTransmission(MPU);
    Wire.write(0x6B);  // PWR_MGMT_1 register
    Wire.write(0);     // set to zero (wakes up the MPU-6050)
    Wire.endTransmission(true);
    Serial.begin(115200);
  }
  void loop(){
    Wire.beginTransmission(MPU);
    Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
    Wire.endTransmission(false);
    Wire.requestFrom(MPU,6,true);  // request a total of 14 registers
    az=Wire.read()&lt;&lt;8|Wire.read();  // 0x3B (ACCEL_XOUT_H) &amp; 0x3C (ACCEL_XOUT_L)    
    ay=Wire.read()&lt;&lt;8|Wire.read();  // 0x3D (ACCEL_YOUT_H) &amp; 0x3E (ACCEL_YOUT_L)
    ax=Wire.read()&lt;&lt;8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) &amp; 0x40 (ACCEL_ZOUT_L)
  
   acc[0] = ax*S;
   acc[1] = ay*S;
   acc[2] = az*S;
  }
  </code></pre>
  
  <p>Why would these last acc values from the array overflow or behave in a weird way (not expected values) sometimes, and why when it starts behaving weird it doesn't recover anymore? I've looked for problems regarding int16_t to float conversion but haven't found any clue that could help me. <a href="https://stackoverflow.com/questions/25064991/int16-t-to-float-conversion-weirdness">Here</a> there is another similar issue, but I think it won't apply to mine cause the ax, ay and az values I get from the sensor are far away from the limits, and I'm converting to a larger format number.</p>
  
  <p>Does a anyone have any idea?</p>
  
  <p>I'm starting to think that it may be hardware thing.</p>