Go Down

Topic: IC2 Scanner stops and finds nothing (Read 1 time) previous topic - next topic

AnAmuser

Jan 13, 2013, 06:13 pm Last Edit: Jan 13, 2013, 06:21 pm by AnAmuser Reason: 1
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 http://www.acroname.com/robotics/parts/R241-SRF10.html
  - 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

Quote
I2C Scanner
Scanning...


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

Code: [Select]
#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.

PaulS

Quote
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.

Headroom

#2
Jan 13, 2013, 06:54 pm Last Edit: Jan 13, 2013, 07:09 pm by Headroom Reason: 1
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 ;-)

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 ;-)

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.

AnAmuser

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%.

Nick Gammon

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

Docedison

#5
Jan 13, 2013, 10:51 pm Last Edit: Jan 13, 2013, 10:57 pm by Docedison Reason: 1
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
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Riva


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

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.

Go Up