Strange error from Wire.endTransimmsion() on LSM6DS0

Hello,
I try to use the Sprakfun LSM6DS0 breakout, but I got errors interfacing with it.
I quickly saw that I can get acceleration values and temperature, but not gyro data.
Investigating in the problem, I discovered the problem comes from I2C communication.
The board is connected to an ESP32 FireBeetle.
I already used this board with a Sparkfun ICM-20948 breakout but looking at the library, I saw that I2C errors are not checked so, maybe I also have the problem, didn't check, but that works.

So, back to my problem with the LSM6DS0, I Investigated a bit deeper 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

Nothing about error code 8.

So, I don't really understand what happens here.

Globally, communication works, but something is bad anyway and because of that, I suspect some initialization code fails and gyro may be not enabled.

Any idea?

Are you sure the results you're sharing are from the code you shared?

What makes you think that a Wire.requestFrom() should be followed by a Wire.endTransmission()?

1 Like

Sparkfun LSM6DSO module: https://www.sparkfun.com/products/18020.
Sparkfun LSM6DSO library: https://github.com/sparkfun/SparkFun_Qwiic_6DoF_LSM6DSO_Arduino_Library

So I'm reading the code of the library and then :face_vomiting: O no, not again, and it is recent code from Sparkfun :man_facepalming:
Here we go again, yet another Issue about the Wire library on Github: https://github.com/sparkfun/SparkFun_Qwiic_6DoF_LSM6DSO_Arduino_Library/issues/2

My Issue answers the question by @DrDiettrich
I don't know if that fixes the problem with the gyro data, perhaps there are more bugs in it.

They will never learn, but some of their stuff is OK.

What other thing can set status?

Oh, good to know, I test it.

Wire.requestFrom() returns the number of bytes received. If it is the requested count then everything is okay.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.