I2C on the Due

Hello all,

I've been writing code for some time on Arduino Uno and Mega units, but recently got a Due. I've been trying rather unsuccessfully to write some I2C code for a TI TMP421 thermometer, based on the example code linked from the GitHub repository for Modern Device from whom I purchased the component. Here is that code:

I can get the code to work perfectly fine with the Uno, and I am positive that the thermometer is working. However when I try the same code in the Due using the 1.5.2 Beta IDE, I do not get expected behavior at all. Essentially, nothing happens when I load the code--the normal pin 13 LED stays on, and there is no output from the serial port. I've loaded the executable code from a few different example sketches into the Due, and it seems to work exactly as expected--including the on-board LED and the serial port. So I believe that the Due is working correctly.

In researching the issue on the main Arduino site, I of course reviewed the documentation for the Wire library. I understand that there are two sets of I2C ports on the Due, and I am using SDA(20) and SCL(21), presumably with the pull-up resistors enabled by default? A couple of the threads I've found here on the subject seem to indicate that they are enable by default anyway.


The things I find curious are the mention of the Wire.send() and Wire.setup() methods in that second link, (presumably) in reference to setting up the Due for I2C. However there is no mention of either method in the current Wire library documentation--nor does my IDE seem to recognize either method.

So is there some special voodoo magic required to use I2C on the Due? I wouldn't have thought so in reading those two threads, but the fact remains that I can't get anything at all from the device using that sample code in the Due...however it works great with the Uno. Of note is that I've tried this several ways--I've wired the sensor directly from both 3V3 and (when that didn't work) 5V from the Due's headers, and of course GND from the Due header as well. I've also even tried to set up GND and VCC from pins A2 and A3, as is done in that code. Note that I have only tried pins 20/21 though, and not the SDA1/SCL1 pins ("Wire1") .

Can anyone offer any tips as to what might be going on with this device? I don't believe that the Due is faulty--it seems to have normal function when powered both from the programming port and 7.5VDC in the barrel jack. One thing I just realized that I did not do yet, is to measure the voltage from both the 3V3 and 5V headers, and I'll do that tomorrow. But I am really scratching my head as to why this isn't working, as the sample code seems pretty straightforward.

Anyway, I would be very appreciative of any additional information anyone could pass along. I'll continue researching the issue here in the forum archive, but nothing I've tried so far seems to work.

Thanks in advance.


Actually, this thread may give a clue as to a possible problem:


I'll have to try to wire in some 10k pull-up resistors tomorrow and see if it makes a difference.


Sort of answering my own question(s) here, but the more searching I do...the more it seems as though there are (or were, as recent as February) some significant problems with I2C on the Due. It does seem to involve the pull-up resistors as suggested in several posts, although it's unclear as to whether or not that has been resolved yet. I haven't found evidence of that yet however--and unless I missed it in the "Due working libraries" sticky, I don't see mention of a modified Wire library for the Due.


Hi All,

I have problems to interface the 6dofImu (https://www.sparkfun.com/products/10121).
This is a 3.3v device and should work with with the DUE.
I tested the device with the UNO and with the Arduino pro mini (3.3v version). With those boards the IMU works perfectly.

I tried all sugestions regarding the pull-up resistors. but without succes.

I believe the problem is related to timing. Today I make some tests with a logic analyser to see if there are differences in the timing.

Regds. B