Sonar Range Finder SRF10
The SRF`s are mini Sonar Range Finders. They measure a distance to a reflecting object with (ultra)sound (wiki). Their range is maximal about 1 meter. In robots they are used for obstacle avoidance. Several different models of the SRF are offered. They can be divided into 2 groups. The one group (like the SRF10) has 5 pins and can be read out with I²C. The other group (like the SRF04) has 4 pins and can be read out by measuring a pulse length. This sensor is part of the 45in1 group.

Arduino offers info, but better use the sketches from this page. The default I²C address of the SRF-10 (manufacturer) is #E0, but this address can be changed so you can use up to 16 different SRF`s in one I²C chain. While powering up the SRF10 will show it`s I²C address by flashing it`s on-board LED. The LED always gives 1 long flash, which means the default address. If this long flash if followed by short flashes they will indicate different addresses.

Important: The SRF10 needs a TWI-restart command to be able to communicate. This is very well possible with the default installed library in spite of some internet pages that will tell you otherwise. Look at Wire.EndTransmission for the solution.

The SRF10 has 2 more parameters that can be set. If your are measuring so often that you are experiencing problems with returns from previous pings then you might want to set the gain. On every power-up the gain is automatically reset to no-gain (=16=700analog). Setting maximum gain-delay means that the gain will automatically rise from zero up to the standard 700analog in about 1.5 ms. You can shorten this rise time by setting a value larger then zero. Setting maximum makes short distance measurements difficult. Normally changing gain is not necessary but if you really are speeding things up you might want to tune a bit in the setup of your sketch.

After a ping the SRF10 waits for maximum 65 ms. This waiting time can be reduced but on every power up it will automatically be reset to maximum. During 65 ms sound travels about 22 meter. But we don`t need more the 1 meter for now. We can set what is called the range in steps of 43mm. So a value of 25 results in a bit more then 1 meter.