I have spent many hours trying to upgrade a Mega-based application to the Due. The application is heavily I2C dependent. The I2C devices include:
PCF8574 and MCP30317 I/O expanders
So far, everything works on the MEGA, nothing works on the DUE, either on SDA0/SCL0 or SDA1/SCL1. I have isolated the chips from the application bus and breadboarded them one at a time, tried a range of pullups, used every code snippet I could find on this forum. No luck.
Apparently, some users have eventually made some devices work with some Due boards, finding ways around the hardware and software issues. Some gyros, digipots, and some master-slave Due connections. Maybe the list of compatible devices is limited. If you have successfully interfaced an I2C device to a Due, please post a short description here.
About a year ago I made a system that involved many I2C nodes on a single bus. The chips included:
- plus LCD displays
This was an I2C multiplexed system with up to 16 multiplexers controlling I2C traffic to sub-branches (each sub-branch with many I2C devices).
I used only the first I2C bus, and the Ethernet shield interface.
I got it all to work, but I had to write a bunch of code because the Wire library is essentially broken for all but the most basic i2c transfers (and I believe that it still is).
It’s not a matter of “compatible chips”. It’s a matter of the interaction of the Wire library and the SAM chip hardware (the interface by Arduino was never completed).
Do some searching to find out what I2C modes are not supported (my user name may help, since I’m pretty good at crabbing about it).
Also, the I2C pins are FRAGILE. I cooked my fair share of DUE’s by abusing the I2C pins. (Is your DUE running HOT?)
I also recommend this:
There are others (many cheaper) too.
An overall schematic is attached. Do not trust it & confirm everything.
Schematic Prints.pdf (203 KB)
Thanks for encouraging me to persist.. Due is now acknowledging the addresses of my I2C devices.
I am using a DS1307 RTC module on my I2C bus. It requires Vcc of 5V. I am feeding its I2C lines at 3.3V with 2.2K pullups. The DS1307 wants to drive its own I2C pins at 5V, but I am assuming the pullups keep the Due from seeing the excess voltage. It appears to be working smoothly. But in the long term, will this cause trouble for the Due or the DS1307? I could insert a logic converter.
I have had no problems using i2c on th due. I have several i2c led displays as well as severaL sensors and the 1307 RTC. To get the RTC to work I had to use a proper level shifter (4050?). You could always switch to one of the variants that will work at 3.3v
Wandrson, thanks for your posts. I am using an arduino Due board and running i2c from a Pixy cam5. was wondering if you could give me a hand with it. I am really new to programming. I'd appreciate you help. Thanks in advance.
I've made a project where i use both i2c channels. But the primary dsa/scl has internal 1.5K ohm pullup and some i2c products can't drive that low resistor value. So by using det secondary i2c port (is without internal pullup - must apply extern f.ex. 2 x 4.7K) it now works with both 12c 20x4 LCD display and Pololu imu9-v2 sensor.
I don't know why the board is made different in this matter....