Pages: [1]   Go Down
Author Topic: Change I2C-address of the srf08 with arduino  (Read 706 times)
0 Members and 1 Guest are viewing this topic.
Berlin
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Go outside, the graphics are amazing!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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(){

}
Logged

Gruß

iToby

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
#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).
Logged

Berlin
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Go outside, the graphics are amazing!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is still not working.  smiley-slim

Code:
#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(){
}
« Last Edit: October 23, 2012, 01:52:00 am by iToby » Logged

Gruß

iToby

Berlin
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Go outside, the graphics are amazing!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
#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(){
}
Logged

Gruß

iToby

Pages: [1]   Go Up
Jump to: