Wire.available() returns true without i2c device

While playing with a Texas TMP100 i2c temperature sensor and Arduino, I encountered a problem with Wire.available().
It seems that even if there is no i2c device connected to SDA/SCL lines, Wire.available() always return true for the number of bytes requested.

For instance, consider the following code :

// Wire Test

#include <Wire.h>

// device address
#define TMP_ADDRESS (0x9 << 3 | 0x0)

void setup()
{
  Wire.begin();        // join i2c bus
  Serial.begin(9600);  // start serial for output
  Serial.println("Hello World!");
}

void loop()
{
  // Start transmission and say we're interested in the temperature register
  Wire.beginTransmission(TMP_ADDRESS);
  Wire.send(0x0); // temp reg
  Wire.endTransmission();
    
  // Request the 2 bytes from slave device's temperature register
  Wire.beginTransmission(TMP_ADDRESS);
  Wire.requestFrom(TMP_ADDRESS, 2);    

  // If some bytes are available, loop over each byte, read it and print it
  while(Wire.available()) 
  { 
    byte b = Wire.receive(); // Get byte
    Serial.print(b,HEX);      // Print it in Hex
  }
  Wire.endTransmission();
  // End line
  Serial.println();
  delay(500); 
}

This code, even with no i2c device connected, output the following in the UART terminal :

Hello World!
00
00
00
00
...

This means the while loop is entered, and thus that Wire.available() returned non-null value.
Is this behaviour normal ?
This is quite a pain, because I can not make any difference between a ‘non-existent device’ condition and a zero reading in the temperature register.

Thanks for your suggestions.

If you change the value you're sending, you'll notice that that's the value you're getting back from read(). You can compare the two (send some bogus byte to begin with) to make sure you're getting real data back. Oddly enough, my arduino blocks when I do beginTransmission() and there are no wires connected to the SDA/SCL lines, but does not block when there are wires connected, but floating. (i.e. not connected to slave.)

Just a note - You don't need a begin/endTransmission around the requestFrom(), but you do need a delay between send() and requestFrom().

!c

If you change the value you're sending, you'll notice that that's the value you're getting back from read(). You can compare the two (send some bogus byte to begin with) to make sure you're getting real data back. Oddly enough, my arduino blocks when I do beginTransmission() and there are no wires connected to the SDA/SCL lines, but does not block when there are wires connected, but floating. (i.e. not connected to slave.)

Just a note - You don't need a begin/endTransmission around the requestFrom(), but you do need a delay between send() and requestFrom().

!c

Indeed, if I do a :

Wire.beginTransmission(device[i]);
Wire.send(B1000000); // temp reg
Wire.endTransmission();

I get B1000000 back if the device is not responding. Well, this is a weird behavior. I can easily be done with a temperature sensor (the value used here B1000000 maps to -128 °C, which is not very common here :) so that ok), but can yield problems with other sensors, like a compass.

Do you know where this behaviour comes from ? Is this in the i2c specs or is it related to Wire.h ?

Anyway, thanks a lot for your suggestion ! It does the trick !