I was using NetHoncho’s library, and was getting only maybe one out of ten readings correct. The rest were sync timeout errors.
I modified his library to retry up to 70 times instead of 35 times, and that did the trick. Look for this line in his lib:
if (retryCount > 35) //(Spec is 50 us, 352 == 70 us)
— and change it to this —
if (retryCount > 70) //(Spec is 50 us, 352 == 70 us)
— and change it to this —
if (retryCount > 50) //(Spec is 80 us, 50x2 == 100 us)
(There are no mentions of 50us in the datasheet - looks like a misreading of "80" as "50")
Also all of the timing is a bit off in that library as the assumption of 2us round each loop is a poor one (each loop has several other tests in it, not just a call to delayMicroseconds(2) - probably more like 2.5 to 3us round each loop, and worse on an 8MHz board like the Lilypad...
Did you ever find out a solution to this problem? I'm trying to use the same sensor and encountering problems. I'm using a Arduino Fio and getting the following from the serial port after uploading: