Srf02 config ID

Hi wondering if any one has had experience changing the ID's of the SRF02's

robot-electronics.co.uk/htm/srf02techI2C.htm#Address

using i2C and the SRF02 library

grapelabs.de/index.php?id=51

here is my latest attempt, i think either i have my hex values wrong or something obvious is blocking my path

comments appreciated!

include "Wire.h"

//byte x, y; int currentDeviceId = 0x70; int newDeviceId = 0x71;

void setup() { Serial.begin(9600); Wire.begin(); configureDeviceId; }

void loop() { Serial.println(newDeviceId); }

void configureDeviceId(int currentDeviceId, int newDeviceId) { Wire.beginTransmission(currentDeviceId); Wire.send(0); Wire.send(0xA0); Wire.endTransmission(); Wire.beginTransmission(currentDeviceId); Wire.send(0); Wire.send(0xAA); Wire.endTransmission(); Wire.beginTransmission(currentDeviceId); Wire.send(0); Wire.send(0xA5); Wire.endTransmission(); Wire.beginTransmission(currentDeviceId); Wire.send(0); Wire.send(newDeviceId); Wire.endTransmission(); }

i then try the single sensor on the new ID (0x71) default (0x70)

include "Wire.h"

include "SRF02.h"

SRF02 sensor(0x71, SRF02_CENTIMETERS);

unsigned long nextPrint = 0;

void setup() { Serial.begin(9600); Wire.begin(); }

void loop() { SRF02::update(); if (millis() > nextPrint) { Serial.println(sensor.read()); nextPrint = millis () + 1000; } }

Within I2C there exist two ways of determining an I2C address: 7-bit addresses and 8-bit addresses. The 7-bit addresses are simply 8-bit addresses shifted one bit right. The right-most bit in an 8-bit address determines whether data should be written to the device or read from the device. Arduino uses 7-bit addresses while an SRF02 uses 8-bit addresses. So if you send data to an SRF02 on id 0x70, you actually send it to device 0xE0 (0x71 is 0xE2, 0x72 is 0xE4, 0x73 is 0xE6 and so on).

So to configure a SRF02 to use id 0x71, we must actually send it the id 0xE2. Version 1.2 of the SRF02 library contains a fixed configureDeviceId() function that sends the correct device id when called with two 7-bit addresses.

Dirk

Hi Dirk,

Version 1.2 of the SRF02 library contains a fixed configureDeviceId() function that sends the correct device id when called with two 7-bit addresses.

Did you upload this updated library somewhere? The download on your website still seems to be 1.1.

(thanx for the excellent lib, anyway!)

Aart Jan