Problems when beginning with I2C

Dear all,

I just got my new Arduino Duo and I am trying to use I2C communication to command an 8-bit expander. But I can not make it work :frowning:

So the first thing I am trying is to see the I2C signal going out from the Arduino in a Scope, but I can not see anything. In the scope SCL and SDA are fixed at 5v and I can not see any frame in the screen.

My code and my HW configuration are as follows:

#include <Wire.h>

void setup() {                

  Wire.begin();

}

void loop() {

   Wire.beginTransmission(4);
   Wire.write(3);                      
   Wire.endTransmission();

}

This is all the code I have. Is there something missing?

For the Hardware I have only my Arduino Duo with pins SCL1 and SDA1 connected to the scope. For the moment the I/O expander is not connected to it because I just want to see SDA and SCL in the Scope.

I have tried with and without 10 kOhm pull-up resistors and nothing.

I am using SDA1 and SCL1 pins in the Arduino Due.

After reading a lot of literature I have several questions:

-Is the code I have enough for making the Master (arduino Due) transmit a frame to the slave (still no slave connected for now).

-Do I need to connect a slave to be able to see any frame transmitted by the master? I haven't tried yet because I still don't have my expander.

-Do I need to initialize the Serial port with: Serial.begin("some speed")? Which speed? I saw it in some examples but I don't understand why should I do that. Also, I tried and I does not work.

Is my first time working with Arduino, so maybe I am missing something really basic. What else can I try??

Thanks for the help,

Pep

Hi pepesolde

I am using SDA1 and SCL1 pins in the Arduino Due.

That's pins 70 and 71, I think?

I don't have a Due to try this on, but does this work?

#include <Wire.h>
extern TwoWire Wire1;

void setup()
{
  Wire1.begin();  
}

void loop() 
{
   Wire1.beginTransmission(4);
   Wire1.write(3);                      
   Wire1.endTransmission();
}

Regards

Ray

Have you got pullups in place ?.

Essef 8)

Hello Hackscribble,

I tried your suggestion and it seams to work, at least I can see a kind of Clock and Data. Thank you very much for your help. Can you explain me what does: "extern TwoWire Wire1;" does, please? I don't understand what does your solution do. Answering your question, from here I see that SDA1 is PIN9 and SCL1 is PIN70

Hello ESSEF,

Yes I am using pull-up resistors, but thanks for the reminding :slight_smile:

I will continue working and I will come back to you if I have more questions.

Thank you very much guys!

From posts on the forum earlier this year, it looks like there is a bug in the Wire library for Due that means that the second I2C object "Wire1" is not properly defined. The workaround creates this second object.

Which version of the Arduino IDE are you using?

What value are your pull-up resistors? The onboard resistors on SDA0 and SCL0 are 1.5k to the +3.3V supply, so I guess you should use the same on SDA1 and SCL1.

Thanks Hackscribble.

I am using Arduino 1.5.8 and 4.3 kOhm for the Pull-up resistors.

Soon I will receive the expanders and I will try to communicate with them. Thank you very much for the help!

Pep