Cannot get gyro values from LSM6DS0

Hello,

I try to use the LSM6DS0 breakout but using basic reading example, I get correct accelerations and temperature, but gyro values remain to 0.

Trying to investigate, I also cannot get getAccelRange()or getGyroRange()value because in readRegister(), or any other similar low level function, the following code returns IMU_HW_ERROR.

if( _i2cPort->endTransmission() != 0 )

return IMU_HW_ERROR;

So, in readRawAccelX() that doesn’t cause a problem because it only increments the nonSuccessError counter and returns the read value anyway, but I suspect the IMU initialization failed somewhere for that reason and gyro could be disabled.

I looked at ICM_20948 library I already used and return of _i2cPort->endTransmission() is not tested so, maybe I also have the same problem but that doesn’t cause any trouble.

Any idea?

Alain

I Investigated a bit deeper in my problem with the following code, which is equivalent to imu.getAccelDataRate()call.

void loop()
{
  uint8_t status;
  uint8_t regVal;
  
  blinkState = !blinkState;
  digitalWrite(LED_BUILTIN, blinkState);

  Wire.beginTransmission(0x6B);
  Wire.write(CTRL1_XL);
  if( (status = Wire.endTransmission(false)) != 0 ) {
    Serial.print("Status1 : ");
    Serial.println(status, HEX);
  }

  Wire.requestFrom(0x6B, 1);
  regVal =  Wire.read(); 

  if( (status = Wire.endTransmission()) != 0 ) {
    Serial.print("Status2 : ");
    Serial.println(status, HEX);
  }

  Serial.println(regVal, DEC);
}

And the result is:

status2 = 8

120

So clearly, the problem comes from call to Wire.endTransmission()only, not Wire.endTransmission(false).

But according to Arduino doc, returns of Wire.endTransmission() can be one of:

  • 0:success

    1:data too long to fit in transmit buffer

    2:received NACK on transmit of address

    3:received NACK on transmit of data

    4:other error



  • So, I don’t really understand what happens here.

    Any idea?

    Wire.requestFrom() is a complete transaction, and is not followed by Wire.endTransmission().

    Yes, it’s what I saw in Arduino Forum https://forum.arduino.cc/t/strange-erro … ds0/888589

    I’m going to test it. Thanks.