I am encountering problems with I2C when trying to attach a 9DoF Sensor to my Arduino Uno. Following these instructions (the hardware setup I have is like in the schematic) I noticed the basic example not working. I've since debugged different aspects and when I use the "I2C Scanner" example from this page it seems something basic with I2C must be wrong. The code from there I am using is:

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;

  for (byte i = 8; i < 120; i++)
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

Instead of this suggested sample output:

I2C scanner. Scanning ...
Found address: 42 (0x2A)
Found 1 device(s).

The output I am getting is in Serial monitor on the correct baud rate is:

I2C s

With other examples I have tried I have similar results. As soon as something calls Wire.endTransmission() things start to crash and burn.

Any ideas what this could be or how to debug it?

  • Have you tried using a slower serial comms rate - ie: 9600 baud? That looks like lots serial bits. I would also add an LED heartbeat and boot indicator (flash pin 13 5 times quickly first thing in setup()) so you can detect resets or hangs easily)
    – patthoyts
    Feb 16, 2015 at 9:34

1 Answer 1


Wire.endTransmission() is where the action is. Nothing is actually sent until that point. Wire.beginTransmission just gets ready for sending and Wire.write (if used) adds stuff to an internal buffer.

If it hangs at that point you probably have dodgy hardware. Check the connections are correct (ie. SDA/SCL the right way around, and that it is powered, and that you have a common ground).

Then try a pull-up resistor between SDA and +5V, and SCL and +5V. A typical value resistor (for both resistors) would be 4.7k.

I see from the linked page that the board already has 10k resistors. Hopefully you did not cut the jumper links. Whether or not you did you might want to augment them with 4.7k resistors. Also keep the cable runs short.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.