IC2 Scanner stops and finds nothing

Hi

I have a SRF10 range measure thing connected to my Arduino UNO as shown on the attached image. The specs can be found at Smart Programmable USB Hubs, Automation Sensors, Manufacturing Test Equipment

  • 5v to +
  • Ground to -
  • SDA to A4
  • SCL to A5

I have tried the example program for SRFxxx provided with the Arduino IDE. That did not work. The program stopped at Wire.endTransmission(); and did not go any further.

Then i thinked that it might be the adress that was wrong. Therefore I found a IC2 scanner, which unfortunatly also stops at this point. The output of the program below is

I2C Scanner
Scanning...

, so this also stops at Wire.endTransmission();

#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(9600);
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 0; address <= 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println(" !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknow error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(8000);           // wait 8 seconds for next scan
}

Can you help me find out why things just stops.

I have a SRF10 range measure thing connected to my Arduino

Take a peek at the Products tab on the home page. Count how many different Arduino models there are. Now, which of them have I2C on pins A4 and A5? All of them? No.

So, which model do you have? Are you using the analog pins 4 and 5? A very common mistake is to use digital pins 4 and 5, since I2C is not an analog function.

If one would look at the photo, which is incredibly easy to do, particularly by a poster with well over 30000 posts, in that case the UNO logo practically stares one in the face :wink:

The UNO has the The I2C pins on Analog Pins 4 & 5.

I2C problems are easiest to track down with an Oscilloscope. I have not looked and the spec sheet, however, are you sure you have pull-up resistors on the SCA and SCL lines ?

Edit:
Just could not shut my big mouth and missed the pull- up resistors also staring in my face :wink:

Edit2:
Bad contacts are a common issue with breadboards. If you have a multimeter, check at least that electrically everything is OK. 5V power at the sensor and signals at SCA and SCL. Then you can look at the software. Wiring looks OK to me and " should" work.

Cool :).

I just re-positioned the whole thing down one point on the bread board and now it works.

So the breadboard is not working 100%.

It looks to me from the photo you had the device on one side and the wires on the other.

Many bread boards fail for that reason. frequently re-positioning or pulling out parts and replacing them is required to make them work. Itusually is caused be corroded component leads. I've used LPS (a marine spray lubricant and contact cleaner) on really bad ones, works a charm. @ Nick, The SIRF device has those long R/A pins on it, it does plug into the right places.

Bob

I agree, you can see the SRF10 is plugged into one side of the centre divider the the wires in the other side. Well spotted Nick.