Requesting data from SRF02 Range finder via I2C

Thank you Nick :slight_smile: I've updated the program with your suggestion and it compiles now. For some reason it's not sending data; I've added in some text at different stages of the loop like so:

#include <Wire.h>

#define srfAddress (0x70)    //USV device address
const byte cmdByte = 0x00;     //Command byte
#define rangeByte (0x02)


//SETUP
//-----------------------------------------------------------------------------

byte highByte = 0x00;                             // Stores high byte from ranging
byte lowByte = 0x00;                              // Stored low byte from ranging

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
  delay(1000);
}


//MAIN PROGRAM
//----------------------------------------------------------------------
void loop()
{
Serial.println("Program starting");
int rangeData = getRange();
}

int getRange(){                                   // This function gets a ranging from the SRF08
  Serial.println("starting getRange");
  int range = 0; 
  
  Wire.beginTransmission(srfAddress);             // Start communticating with SRF08
  Wire.write(cmdByte);                             // Send Command Byte
  Wire.write(0x51);                                // Send 0x51 to start a ranging
  Wire.endTransmission();
  Serial.println("requested range sample");
  delay(100);                                     // Wait for ranging to be complete
  
  Wire.beginTransmission(srfAddress);             // start communicating with SRFmodule
  Wire.write(rangeByte);                           // Call the register for start of ranging data
  Wire.endTransmission();
  Serial.println("requesting range data");
  Wire.requestFrom(srfAddress, 2);                // Request 2 bytes from SRF module
  while(Wire.available() < 2);                    // Wait for data to arrive
  highByte = Wire.read();                      // Get high byte
  lowByte = Wire.read();                       // Get low byte
  Serial.println("finishing range data transmission");
  range = (highByte << 8) + lowByte;              // Put them together
  Serial.println(range);
  return(range);                                  // Returns Range
}

The serial monitor shows up to: Serial.println("requesting range data");

Does that mean that I'm correct in saying that when trying to exectute this:

  Wire.requestFrom(srfAddress, 2);                // Request 2 bytes from SRF module
  while(Wire.available() < 2);                    // Wait for data to arrive
  highByte = Wire.read();                      // Get high byte
  lowByte = Wire.read();

the program must get stuck because Wire never becomes available? i.e something wrong with the wiring or addressing of my sensor?