Go Down

Topic: I2C via other available Pins (Read 3981 times) previous topic - next topic

Noak

hi,

I understand that the current "Wire" library sets Port C4 and Port C5 for I2C. Is there a way to set other ports as I2C comms? Thanks in advance!

Casey Gross

I dont think you can do that.

Professor Chaos

There are libraries that bit-bang I2C communication on other pins.  For example, the JeeLabs "Ports" library:  http://cafe.jeelabs.net/sw/library_-_ports/

capt.tagon

I2C is hardwired into the AtMega168 and 328 to use those pins. See the pin mapping diagram http://arduino.cc/en/Hacking/PinMapping168 for the functions available from these chips to show how they map to the Arduino pin layout. Port C4 = AD4/SDA and Port C5 = AD5/SCL.

Jee Labs has done work on an Arduino variant and uses software I2C to extend the number of I2C capable pins here http://news.jeelabs.org/2010/03/15/software-and-hardware-i2c/ and I think this http://cafe.jeelabs.net/sw/library_-_ports/ is the library that allows the JeeNode to do this. Instructions are given for adding it to the Arduino IDE.

Noak

hi  Professor Chaos and capt.tagon,

Thanks alot! It's exactly what I'm looking for, bit-bang I2C.

swbluto

Wait.. so can you redirect I2C to other digital pins and then use Analog_4 and Analog_5 as regular analog pins to measure voltages? Or would Analog_4 and Analog_5 still be hogtied by I2C?

Grumpy_Mike

If you bit banged the I2C and didn't use the internal I2C hardware then yes you could reclaim those two analogue inputs.

CharlieD

#7
Jul 01, 2010, 01:22 pm Last Edit: Jul 01, 2010, 01:25 pm by CharlesDavis Reason: 1
Just find "SoftI2CMaster.h" and its associated c - it works well.

Code: [Select]

#include <SoftI2cMaster.h>
#define SCL_PIN 9
#define SDA_PIN 8
SoftI2cMaster rtc;
#define DS1307ADDR 0XD0

Go Up