Problem with Ultrasound Sensor

Hello LMR.

I am working on a current project but seem to be having a ridiculous amount of difficulty implementing an SRF02 Ultrasound sensor. I am using it in serial mode and communicating with an Arduino Duemilanove. The problem is not in the wiring as I triple checked that.

The adruino is supposed to send 2 bytes to the SRF02 [ address, command ] and then receive 2 bytes in response giving the distance measured by the sensor.

In my setup the SRF02 blinks so I can see that it is receiving the command and doing a ranging operation. However for some reason I get no response from it. The problem is somewhere in the code and I could really use some help. I bet its something simple and silly.... Bellow is my code and the serial monitor output. Please tell me where I am wrong. My version of Arduino IDE is 17 but that shouldn't be a problem.

Documentation for SRF02
http://www.robot-electronics.co.uk/htm/srf02techSer.htm

Code:
//SRF02

#define srfAdrs 00 // Address of the SRF02
#define rangeCM 84  // Byte for start of ranging data


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


void loop()
{
  SRF_Range();
}

void SRF_Range(){
 
int incomingByte;

Serial.write(byte(srfAdrs)); // send address byte
delay(100);
Serial.write(byte(rangeCM)); //send command byte
delay(70);


if (Serial.available() > 0)
{
   incomingByte = Serial.read(); // read serial response
   Serial.println("Range: ");
   Serial.print(incomingByte); // write distance measured
   Serial.flush(); // clear buffer
   delay(5000);
  }

Serial Monitor Output:

 TRange:
0 TRange:
0 TRange:
0 TRange:

ect.

Different address formats?

I saw somewhere arduino uses 7 bit addresses and srf02 uses 8 bit. There’s a bit of info here. Hope it helps.

**It seems like youre using**<br><p>It seems like youre using the only hardware serial port to communicate with the PC and the SR02 at the same time. Try using the software serial library for one of them.

Ezekial is correct

I have almost the same setup and I used NewSoftSerial for the range finder. Also, depending on where you got yours, getting a bad one seems more common than with some components. I got mine cheap from China and when I had a problem, the forst thing they did was send another. It worked.