In the file "MAX30105.cpp" in the function "readRegister8()" there is a delay with a timeout after the Wire.requestFrom(). There is no need to wait there.
The Wire.requestFrom() waits until the i2c session has completely finished. After that the data is in a buffer inside the Wire library. The Wire.available() returns the number of bytes that are in that buffer. There is no need to wait for retrieving data from that buffer, since the i2c session has already finished.
I did not check the datasheet. Some sensors do not acknowledge their i2c address when they are busy. In that case the Wire.requestFrom() should be repeated.
The Wire.available() could be used once, or the return value of Wire.requestFrom() could be used to check if no data was received and a fail (zero) should be returned.
_Copied from original issue: sparkfun/MAX30105_Particle_SensorBreakout#2
From @Koepel on December 12, 2016 13:53
In the file "MAX30105.cpp" in the function "readRegister8()" there is a delay with a timeout after the Wire.requestFrom(). There is no need to wait there. The Wire.requestFrom() waits until the i2c session has completely finished. After that the data is in a buffer inside the Wire library. The Wire.available() returns the number of bytes that are in that buffer. There is no need to wait for retrieving data from that buffer, since the i2c session has already finished.
I did not check the datasheet. Some sensors do not acknowledge their i2c address when they are busy. In that case the Wire.requestFrom() should be repeated. The Wire.available() could be used once, or the return value of Wire.requestFrom() could be used to check if no data was received and a fail (zero) should be returned.
_Copied from original issue: sparkfun/MAX30105_Particle_SensorBreakout#2