Go Down

Topic: Change I2C-address of the srf08 with arduino (Read 795 times) previous topic - next topic

iToby

Hi,

I want to change the I2C-address of a srf08 ultrasonic sensor with an arduino UNO.

I shifted the Codes but it does not work:

Code: [Select]

#include <Wire.h>

#define Old_Address 0x70
#define New_Address 0x72

void setup() {

  Wire.begin();
 
  delay(100);
 
    Wire.beginTransmission(Old_Address);
    Wire.write(0);
    //Wire.write(0xA0);
    Wire.write(0x50);
    Wire.endTransmission();
    delay(60);
     
    Wire.beginTransmission(Old_Address);
    Wire.write(0);
    //Wire.write(0xAA);
    Wire.write(0x55);
    Wire.endTransmission();
    delay(60);
   
    Wire.beginTransmission(Old_Address);
    Wire.write(0);
    //Wire.write(0xA5);
    Wire.write(0x52);
    Wire.endTransmission();
    delay(60);
   
    Wire.beginTransmission(Old_Address);
    Wire.write(0);
    Wire.write(New_Address);
    Wire.endTransmission();
    delay(60);
}
 
void loop(){

}
Gruß

iToby

pylon

You have to send it in one sequence, not 4 and use the correct values as the datasheet describes:

Code: [Select]
#include <Wire.h>

#define Old_Address 0x70
#define New_Address 0xF2

void setup() {

  Wire.begin();
 
  delay(100);
 
    Wire.beginTransmission(Old_Address);
    Wire.write(0);
    //Wire.write(0xA0);
    Wire.write(0x50);
    Wire.endTransmission();
    delay(60);
     
    Wire.beginTransmission(Old_Address);
    Wire.write(0xA0);
    Wire.write(0xAA);
    Wire.write(0xA5);
    Wire.write(New_Address);
    Wire.endTransmission();
}
 
void loop(){
}


After that you have to use the new address, which will be 0x79 (8bit 0xF2 shifted to the right one bit).

iToby

#2
Oct 23, 2012, 08:44 am Last Edit: Oct 23, 2012, 08:52 am by iToby Reason: 1
It is still not working.  :smiley-slim:

Code: [Select]

#include <Wire.h>

#define Old_Address 0x70
#define New_Address 0xF2

void setup() {

 Wire.begin();
 
 delay(100);

   Wire.beginTransmission(Old_Address);
   Wire.write(0xA0);
   delay(50);
   Wire.write(0xAA);
   delay(50);
   Wire.write(0xA5);
   delay(50);
   Wire.write(New_Address);
   Wire.endTransmission();
}
 
void loop(){
}
Gruß

iToby

iToby

Ok. I have it. Thank you for your help!

Code: [Select]

#include <Wire.h>

#define oldad 0x70
#define newad 0xE4

void setup() {

  Wire.begin();
 
  delay(100);

    Wire.beginTransmission(oldad);
    Wire.write(0x00);
    Wire.write(0xA0);
    Wire.endTransmission();
    delay(60);
   
    Wire.beginTransmission(oldad);
    Wire.write(0x00);
    Wire.write(0xAA);
    Wire.endTransmission();
    delay(60);
   
    Wire.beginTransmission(oldad);
    Wire.write(0x00);
    Wire.write(0xA5);
    Wire.endTransmission();
    delay(60);
   
    Wire.beginTransmission(oldad);
    Wire.write(0x00);
    Wire.write(newad);
    Wire.endTransmission();

}
 
void loop(){
}
Gruß

iToby

Go Up