How to change SRF235 Ultrasonic range finder I2C address

This post is about how to change the I2C address of theSRF235 Ultrasonic range finder from robot-electronics (SRF235 Ultra sonic range finder).

The device data sheet is not completely clear so hopefully this will save you some time trying to figure it out :slight_smile:

  Wire.beginTransmission(SRF_OLD_ADDRESS);  //  NB: 7 bit format e.g. 0x70 (default address)
  Wire.write(CMD);  // Send Command Byte (byte 0x00) NB: must #define as byte due Arduino bug
  Wire.write(0xA0);  // write the first change address command 
  Wire.endTransmission();  // and send the data on the bus
 
  Wire.beginTransmission(SRF_OLD_ADDRESS);  // as above
  Wire.write(CMD);  // Send Command Byte
  Wire.write(0xAA);   // write the second change address command 
  Wire.endTransmission();

  Wire.beginTransmission(SRF_OLD_ADDRESS);  // as above
  Wire.write(CMD);    // Send Command Byte
  Wire.write(0xA5);  // write the third change address command 
  Wire.endTransmission(); 

  Wire.beginTransmission(SRF_OLD_ADDRESS);   // as above
  Wire.write(CMD);  // Send Command Byte
  Wire.write(SRF_NEW_ADDRESS);  // write the new address NB: 8 bit format e.g. 0xE0 (default address)
  Wire.endTransmission();

Note that the old and new address formats are different and that you need 4 separate transactions, each including CMD and data.

after reading the page you linked to, I should say

void set_address(uint8_t old, uint8_t new)
{
  Wire.beginTransmission(old);  
  Wire.write(0x00);  
  Wire.write(0xA0);  
  Wire.write(0xAA); 
  Wire.write(0xA5); 
  Wire.write(new); 
  Wire.endTransmission();  
}

I have read datasheet but I cannot find precission or accuracy of this sensor.
Can you please explain your findings regarding this area?
I am looking to get 0.1mm acuracy - can I get so precise readings from this ultrasound distance sensor?

you can not, unless you compensate for temperature and humidity.