connect 3 srf02 modules in 1 i2c port

hey guys,
I need to connect three SRF02 modules in one i2c port..Can you give me a way to do this..
thanks..

Use two pullups only, and make sure that the modules have different addresses.

Thanks Bro.....I 'm new guy to use SRF02 modules...Can u tel me, how can i address sensors? It will help me a lot...thanks

http://www.robot-electronics.co.uk/htm/srf02techI2C.htm

I have read it friend...bt only 1 srf02 module can adressed..

I don't know what an srf022 is, but that data sheet shows how to address multiple SRF02s on the same I2C bus.
FWIW, I've got four of them, all at different addresses, on a 50cm length of ribbon cable.

Can you tell me how to do it?...Can u send me a sample programme...Then I can get an idea....THnks 4 reply me friend...

The data sheet tells you what to do half-way down the page

Changing the I2C Bus Address

I can't post the sketch I used; it is on my desktop at home.

Thnks friend....Its kk..please send it to me later....////help me friend...

I think this is it:

#include <Wire.h>
#include <SRF02.h>

const byte LED_PIN = 13;

void setup(){
  Wire.begin();     
  pinMode (LED_PIN, OUTPUT);
  digitalWrite (LED_PIN, LOW); 
  delay (1000);  
//  SRF02::configureDeviceId (070, 0x71);
  reAddress (0x70, 0x73);
  digitalWrite (LED_PIN, HIGH);
} 

void loop(){
}

void reAddress (int i2cAddress, int newAddress) 
{
    Wire.beginTransmission(i2cAddress);
    Wire.send(0);
    Wire.send(0xA0);
    Wire.endTransmission();
    delay (5);
    Wire.beginTransmission(i2cAddress);
    Wire.send(0);
    Wire.send(0xAA);
    Wire.endTransmission();
    delay (5);

    Wire.beginTransmission(i2cAddress);
    Wire.send(0);
    Wire.send(0xA5);
    Wire.endTransmission();
    delay (5);

    Wire.beginTransmission(i2cAddress);
    Wire.send(0);
    Wire.send(newAddress << 1);
    Wire.endTransmission();
    delay (5);
}

OH ..iTs not working friend..Can u tell me how to do it..It is reaklly important to me...plzzz...

All I can say it, it worked for me - as I wrote earlier, I have four of these on a length of ribbon cable, all at different addresses (they're at home, I'm not)

I have conect 1 sensor and got readings...But the pronblem is I have only 1 i2c port..So i have to connect 3 sensors in to 1 port.plz help me friend..How can i address those sensors

You have to change their addresses using the sketch I posted above, recompiling the sketch each time to write a different address.
It's all clearly set-out in the sketch and the data sheet.

// I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder
// by Nicholas Zambetti http://www.zambetti.com
// and James Tichenor http://www.jamestichenor.net

// Demonstrates use of the Wire library reading data from the
// Devantech Utrasonic Rangers SFR08 and SFR10

// Created 29 April 2006

// This example code is in the public domain.

#include <Wire.h>

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
}

int reading = 0;

void loop()
{
// step 1: instruct sensor to read echoes
Wire.beginTransmission(112); // transmit to device #112 (0x70)
// the address specified in the datasheet is 224 (0xE0)
// but i2c adressing uses the high 7 bits so it's 112
Wire.write(byte(0x00)); // sets register pointer to the command register (0x00)
Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50)
// use 0x51 for centimeters
// use 0x52 for ping microseconds
Wire.endTransmission(); // stop transmitting

// step 2: wait for readings to happen
delay(70); // datasheet suggests at least 65 milliseconds

// step 3: instruct sensor to return a particular echo reading
Wire.beginTransmission(112); // transmit to device #112
Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02)
Wire.endTransmission(); // stop transmitting

// step 4: request reading from sensor
Wire.requestFrom(112, 2); // request 2 bytes from slave device #112

// step 5: receive reading from sensor
if(2 <= Wire.available()) // if two bytes were received
{
reading = Wire.read(); // receive high byte (overwrites previous reading)
reading = reading << 8; // shift high byte to be high 8 bits
reading |= Wire.read(); // receive low byte as lower 8 bits
Serial.println(reading); // print the reading
}

delay(250); // wait a bit since people have to read the output :slight_smile:
}

/*

// The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08)
// usage: changeAddress(0x70, 0xE6);

void changeAddress(byte oldAddress, byte newAddress)
{
Wire.beginTransmission(oldAddress);
Wire.write(byte(0x00));
Wire.write(byte(0xA0));
Wire.endTransmission();

Wire.beginTransmission(oldAddress);
Wire.write(byte(0x00));
Wire.write(byte(0xAA));
Wire.endTransmission();

Wire.beginTransmission(oldAddress);
Wire.write(byte(0x00));
Wire.write(byte(0xA5));
Wire.endTransmission();

Wire.beginTransmission(oldAddress);
Wire.write(byte(0x00));
Wire.write(newAddress);
Wire.endTransmission();
}

*/
Can you give me some advice how to change this programme to connect 3 srf02 modules...?

Sorry, I don't have code for three sensors, but I do have code for four.
(and I have code tags!)

#include <Wire.h>

const byte cmdByte   = 0x00;
const byte rangeByte = 0x02;
const byte cmRange   = 0x51;
const byte N_SRF     = 4;

unsigned long SRF_TIMEOUT = 70;
byte sonarUnit;

void setup()
{
  Serial.begin (115200); 
  Wire.begin();                               
  delay(100);
  startRange (sonarUnit);
} 

void loop()
{
    static unsigned long lastMillis;
    unsigned long now = millis ();
    
    if (now - lastMillis >= SRF_TIMEOUT) {
      lastMillis = now;   
      int range = readRange (sonarUnit);
      Serial.print (range);
      Serial.print (" ");
      sonarUnit++;
      if (sonarUnit >= N_SRF) {
        sonarUnit = 0;
        Serial.println ();
      }  
      SRF_TIMEOUT = 70;
      startRange (sonarUnit);
    }  
}

const uint8_t getAddress (uint8_t unit)
{
#if 0
  const uint8_t sonarLUT [N_SRF] = {0x70, 0x71, 0x72, 0x73};
  return sonarLUT [unit];
#else
  return 0x70 + unit;
#endif  
}

void startRange(uint8_t unit)
{
  const uint8_t address = getAddress (unit);

  Wire.beginTransmission(address);
  Wire.write(cmdByte);
  Wire.write(cmRange);
  Wire.endTransmission();
}

int readRange (uint8_t unit)
{
  const uint8_t address = getAddress (unit);

  Wire.beginTransmission(address);
  Wire.write(rangeByte);
  Wire.endTransmission();

  Wire.requestFrom(address, (uint8_t)2);
  while((Wire.available() < 2)){
    Serial.print (".");// hope we never see these
    delay (1);
  }  

  int retVal = Wire.read() << 8;
  return retVal | Wire.read();
}

#include <Wire.h>
#include <SRF02.h>

const byte LED_PIN = 13;

void setup(){
Wire.begin();
pinMode (LED_PIN, OUTPUT);
digitalWrite (LED_PIN, LOW);
delay (1000);
// SRF02::configureDeviceId (070, 0x71);
reAddress (0x70, 0x73);
digitalWrite (LED_PIN, HIGH);
}

void loop(){
}

void reAddress (int i2cAddress, int newAddress)
{
Wire.beginTransmission(i2cAddress);
Wire.send(0);
Wire.send(0xA0);
Wire.endTransmission();
delay (5);
Wire.beginTransmission(i2cAddress);
Wire.send(0);
Wire.send(0xAA);
Wire.endTransmission();
delay (5);

Wire.beginTransmission(i2cAddress);
Wire.send(0);
Wire.send(0xA5);
Wire.endTransmission();
delay (5);

Wire.beginTransmission(i2cAddress);
Wire.send(0);
Wire.send(newAddress << 1);
Wire.endTransmission();
delay (5);
}

THis is the code that u gave.When it compile,it gives an error

It's a very descriptive error too.

sketch_may06a:40: error: 'class TwoWire' has no member named 'send'

As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.

It doesn't get much clearer than that without actually Tippex-ing the error out for you and rewriting it.

Edit: You've wasted a lot of your time; On April 10th you wrote

OH ..iTs not working

.
Well, something that doesn't compile can't be said to work or not work, because if it doesn't compile, it doesn't upload, and if it doesn't upload, it doesn't run.

This is why "doesn't work" doesn't cut it around here.

Please help me guys

Help you with what?
Finding a new optometrist?