I’ve spent untold hours trying to get range data from this ultrasonic device. I2C communications appear to function for e.g. reading the firmware version, or changing the device address. And judging by the blinking LED on the SRF10 and the serial output, the ranging function is being started. But the Wire.available(), Wire.read() command sequence always returns 0.
Wire.requestFrom(SRF_ADDRESS, 2); // Request 2 bytes from SRF module while(Wire.available() < 2) // Wait for data to arrive highByte = Wire.read(); // Get high byte lowByte = Wire.read(); // Get low byte range = (highByte << 8) + lowByte; // Put them together return(range); // Returns Range
This is straight from example code provided for SRF I2C sensors.
I also tried using the SoftI2CMaster.h library; which always returns 1280 ( I suspect this represents the firmware version (5, from register 0x00) x 256 operation which is supposed to produce the high byte of the range ). Changing pull-up resistors, gain, delay intervals (“waiting for the ranging to be complete”), power supplies, and even downloading and using the version 1.0 Arduino IDE has been fruitless. I have two of the devices that I’ve tested and they both behave the same way.
My online research made me suspect that the Wire.h library could be broken in some sense – and that these problems started with a release in the 2011 - 2012 timeframe. Going back to version 1.0 seemingly would discredit that theory. I’m not really at a level where I can rewrite libraries in any case. I could surely use some help.