Arduino Forum

Products => Arduino Due => Topic started by: Stan09 on Nov 18, 2012, 11:01 am

Title: How to use second I2C?
Post by: Stan09 on Nov 18, 2012, 11:01 am
I tried using accelerometer on pins 20 & 21 but it seems like there is something wrong with the board (no, I did not use +5V anywhere).
Somewhere it is mentioned DUE has two I2C interfaces, and there are pins SCL1 and SDA1 next to AREF pin.
How I can switch to using them?
Title: Re: How to use second I2C?
Post by: Markus_L811 on Nov 18, 2012, 11:18 am
Did you use Wire.send... and so for the I2C for the I2C on top behind Aref you need to use Wire1.send...

And by the way on SCL1 SDA1 you need Pullups about 1.5kOhm on both. SCL0 SDA0 did have them build in.
Title: Re: How to use second I2C?
Post by: Stan09 on Nov 18, 2012, 11:43 am
Thanks a bunch, this works!

Title: Re: How to use second I2C?
Post by: dougcl on Apr 07, 2013, 10:21 pm
So in summary, is this correct?

If using Pin 20 and 21:
Internal pullups are provided.
Use Wire.setup() to control these.

If using SCL1 and SDA1:
You must provide 1.5k pullup resistors
The pullup source is taken from the 3.3V pin near the RESET pin.
Use Wire1.setup() to control these.

If this is all true, then I am unable to get pins 20 and 21 working. They just stay at logic high all the time. Have I missed something? I'm just running the master code here http://arduino.cc/en/Tutorial/MasterWriter

Will this work with just one device? I am just using one device and a logic analyzer to monitor the pins.

Thanks,
Doug
Title: Re: How to use second I2C?
Post by: SomeRandomGuy on Apr 11, 2013, 10:36 pm

So in summary, is this correct?

If using Pin 20 and 21:
Internal pullups are provided.
Use Wire.setup() to control these.

If using SCL1 and SDA1:
You must provide 1.5k pullup resistors
The pullup source is taken from the 3.3V pin near the RESET pin.
Use Wire1.setup() to control these.

If this is all true, then I am unable to get pins 20 and 21 working. They just stay at logic high all the time. Have I missed something? I'm just running the master code here http://arduino.cc/en/Tutorial/MasterWriter

Will this work with just one device? I am just using one device and a logic analyzer to monitor the pins.

Thanks,
Doug


I went ahead and used the 1.5k pullup resistors on both pairs of inputs. This worked for me. Let us know if that fixes it for you.
Title: Re: How to use second I2C?
Post by: fuscof on Jun 26, 2013, 01:17 pm
Hi.
How to use Wire1.setup() or other? The compiler does not recognize "Wire1".
Then about the pull-up resistors, I have to add them phisically or can I enable them with software commands?
Thanks a lot
Francesco
PS: I would like tu use arduino due with SDA1 and SCL1 to make a shield working.
Title: Re: How to use second I2C?
Post by: johnflux on May 17, 2014, 02:01 am
> I tried using accelerometer on pins 20 & 21 but it seems like there is something wrong with the board

For those wondering, this is a confirmed bug in the arduino Wire library:  https://github.com/arduino/Arduino/pull/1994

Specifically:

Download:

https://raw.githubusercontent.com/bluesign2k/Arduino/d8d6d62853a5308c21b95dad4bdd64e358e857cc/hardware/arduino/sam/libraries/Wire/Wire.cpp

And overwrite in your arduino installation: hardware/arduino/sam/libraries/Wire/Wire.cpp

For me, this just fixed i2c on the Due.
Title: Re: How to use second I2C?
Post by: ECUni on May 21, 2014, 12:26 pm
Hi John,

I downloaded the code and when it compile it gave me errors:
Code: [Select]
C:\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\libraries\Wire\Wire.cpp: In function 'void Wire_Init()':
C:\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\libraries\Wire\Wire.cpp:368: error: 'WIRE_ISR_ID' was not declared in this scope
C:\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\libraries\Wire\Wire.cpp: In function 'void Wire1_Init()':
C:\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\libraries\Wire\Wire.cpp:395: error: 'WIRE1_ISR_ID' was not declared in this scope


Did you come across these errors?
Title: Re: How to use second I2C?
Post by: kkazakov on Jun 07, 2014, 08:54 am
This worked for me, too. I2CScanner works. Thank you!
Title: Re: How to use second I2C?
Post by: Heievacheza on Aug 27, 2014, 05:33 pm
Hi everybody,

I'm trying to connect three MPU6050 sensors to Arduino Due to read raw acceleration and angular velocity. I connected two of my sensors to SDA and SCL (pins 20 and 21) and got both of them to work. I mean I can read data from both of them simultaneously using primary I2C pins of Aruino Due and it works well.

However, for the third sensor, I have used secondary I2C (SDA1 and SCL1) pins but it always shows 'MPU6050 connection failed'.
I don't know what to do. For the sketch ('MPU6050_raw' written by Jeff Rowberg) I have replaced all wire....() with wire1....() but it is still not working. I also used pull up resistors, but no success!

On the other, when I use 'address scanner' sketch on SCL1 and SDA1, the Arduino Due recognizes the address of third sensor. It means that they can communicate with each other. But I don't know why I can read data!

I will be grateful if somebody helps me with this. 
Title: Re: How to use second I2C?
Post by: pouya444 on Feb 27, 2015, 06:15 am
Thanks John,
It worked for me too.
Title: Re: How to use second I2C?
Post by: cyclegadget on Mar 01, 2015, 04:24 am

 Could someone post the code they are using to get I2C scanner to work on the Due? I have downloaded the fix suggested above but, I am not having luck.

Thanks,
Mark
Title: Re: How to use second I2C?
Post by: germancorrea on Apr 12, 2015, 06:53 pm
Can any one post a code using SCL1 and SCA1 using wire1 to drive a LCD