chipKIT® Development Platform

Inspired by Arduino™

Software I2C Library

Created Mon, 11 Jan 2016 18:26:51 +0000 by stark506


Mon, 11 Jan 2016 18:26:51 +0000


Has anyone here ever attempted to use the Arduino Software I2C Library? (available here: Users on Arduino's site, report it being relatively easy when implemented with the Arduino IDE. Perhaps switching to MPIDE is where my problems are coming from.

I am using a Chipkit WF32, and trying to get my I2C devices running on separate pins than the analog 4/5 pins, which I am using for something else.

Any help is appreciated!


Mon, 11 Jan 2016 18:38:05 +0000

I'm sorry, but you have absolutely zero chance of getting that working. It is written completely in AVR assembly language. It will only ever run on an AVR chip, and re-writing it for MIPS assembly would mean re-writing the entire library from scratch.


Did you know that your WF32 has three sets of I2C pins?

Pins 0 and 1 are SDA3 and SCL3 respectively. Pins 11 and 12 are SDA4 and SCL4 respectively.

Using the DTWI library (included with MPIDE) you can access those I2C channels as DTWI1 and DTWI2 respectively. Note the API for DTWI is different to the Wire library, so you will need to check out the examples.


Mon, 11 Jan 2016 19:07:40 +0000

Is there a way to go about being able to use any pins for this? More specifically for my needs, I am trying to use Pins 45 and 46, which are tied to Analog 4/5 pins unless I switch the JP4/JP5 jumpers to analog mode.


Mon, 11 Jan 2016 19:25:22 +0000

Only by bit-banging, and I am not aware of any library that is available for doing that at the moment.


Mon, 11 Jan 2016 19:28:33 +0000

Ok, thanks for the help!