i2c Scanning

Hi everyone, I've been attempting to connect an Arduino Lilypad with an MPU9250 and using an FTDI FT232R as a breakout board. The issue I would first like to address is that I can't even get simple i2c communication out. I've been using this code I found to check(Arduino Playground - I2cScanner):

//code begins here//

#include <Wire.h>

void setup()
{
Wire.begin();

Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}

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

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

nDevices = 0;
for(address = 1; 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("Unknown 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(5000); // wait 5 seconds for next scan
}

// end of code //

First I will list my connections:

Lilypad - MPU9250
VCC - 5V(+)
GND - GND (-)
SCL - SCL (A5)
SDA - SDA (A4)
INT - INT(Pin 2)
AD0 - GND (-)

I chose these connections by researching what others had done (http://www.instructables.com/id/MPU-91509250-IMU/?ALLSTEPS) Although it was not with a lilypad. The pins on the lilypad I checked with the datasheet.

Now for my issues:

  1. For any given Baud rate I begin with, my serial monitor must have double the baud rate, or my text would be garbled, e.g. for serial.begin(9600) I would need 19200. I have googled quite extensively and it's either beyond my understanding, or most of the others talk about the same Baud rate...so I'm not sure what to make of this.

  2. Even after installing all the FTDI drivers my arduino program occasionally refuses to reconize the port which can be very infuriating especially since I have already uploaded code a few times.

  3. When I do manage to communicate, I only manage to print up to : " Scanning..." part of code which i bolded in the code above, I am perplexed as to why it did not at least give me an error. I hope I have provided enough info, and someone could help me diagnose if this is a hardware/software or both issues. I am just a beginner and really need some help with this, thank you.

  1. For any given Baud rate I begin with, my serial monitor must have double the baud rate, or my text would be garbled, e.g. for serial.begin(9600) I would need 19200. I have googled quite extensively and it's either beyond my understanding, or most of the others talk about the same Baud rate...so I'm not sure what to make of this.

Did you compile for the Lilypad board? This looks like you compiled for a 16MHz Arduino but run that code on a 8MHz board.

  1. Even after installing all the FTDI drivers my arduino program occasionally refuses to reconize the port which can be very infuriating especially since I have already uploaded code a few times.

That sounds more like a Windows problem than one of the Arduino.

  1. When I do manage to communicate, I only manage to print up to : " Scanning..." part of code which i bolded in the code above, I am perplexed as to why it did not at least give me an error.

There are several possibilities why the Wire.endTransaction() call may not return. May we ask you to post a picture of your wirings? How do you feed your Lilypad? With 5V or with 3V3? The MPU9250 must not be signaled with more than 3.6V. A Lilypad with 5V and standard Wire library (internal pullups) have about 3.8V on the I2C lines.

Hi, Thank you for replying me so quickly, I am not sure of what frequency to use, I know the chip is ATMega328 and attached an image of my configuration on the software side. After your comment I realized my FT232RL output is still at 5V (Also I use a mac not windows, I realized I can solve the issue of weak connection by switching the usb port on my mac), which hopefully didn't damage my sensor....I am getting a FT232RL cable that will output at 3.3V, then I will reconfigure and take an image of my connections, however it would still quite difficult to see as it is sewn thread, and taking image of the exact connection would be difficult. Hope you could wait until I get the part, thank you again.

Hi, I changed my sensor to a MPU6050 as it is able to receive 5V, and yet I still have the same issue where there is nothing printed beyond "Initializing I2C Devices" I used Jeff Rowbergs library which most people have no issues connecting. My connections are as follows:

Vcc - 5V
GND - GND
SCL - SCL (A5)
SDA - SDA (A4)
INT - INT (Pin 2)

can anyone advise me as to where my connection went wrong? As mentioned earlier I am still using the FT232RL for serial communication, and although the images aren't clear I made sure that none of the wires overlapped. Been trying to work it out for very long and really need some help, almost at my wit's end with this, thank you.

Use the "Lilypad Arduino" option, not the AtMega328. The Lilypad doesn't have a 328, it is a 328V. According to the website, both versions of the LilyPad are 8Mhz.
If you're running with the wrong processor setting, apart from the Serial speed going wonky, it might also explain why you're not getting anywhere with the I2C scanner.

Pete

I am also having trouble with clock rates. If I choose Lilypad Arduino from boards my serial rate is half and FastLED doesn't work. If I choose Arduino Pro or Pro Mini (and ATMega328 5v, 16Mhz) from boards everything works fine.

The chip is marked MEGA328P, but all I can read on the crystal is either AI or AT, no numbers.

I haven't always had this problem. It seems to have started with a recent boards update. I checked the boards file and it says 8MHz, and Serial.println(F_CPU); shows 8MHz.