Arduino I2C pin inputs

157 views
Skip to first unread message

Adrienne Humblet

unread,
Mar 20, 2012, 9:00:07 PM3/20/12
to NYCResistor:Microcontrollers
Hi,

I'm trying to hook up a DS1307 RTC chip to an Arduino Uno. The DS1307
uses the I2C bus which requires 2 connection to the Arduino. The
Wire.h library (which is what the Arduino uses for I2C protocol)
expects the SDA (serial data) and SCK (serial clock) connections in
the Analog 4 and Analog 5 pins of the Arduino.

Does anyone know how to make it such that the Wire library expects SDA
and SCK in other pins? Pins A4 and A5 are already taken up by other
non I2C devices.

Does anyone know what I'm talking about?

I thought it would be easy, but when I look in Wire.h I don't see any
pin assignments.

Thanks!
-Adrienne

katz...@aol.com

unread,
Mar 20, 2012, 9:25:13 PM3/20/12
to nycresistormi...@googlegroups.com
I don't think you can it has something to do with internal timers on the chip I would recommend using a arduino mega because it has multiple i2c connections if you look up the datasheets on the chip i think it only lists one i2c port you can try looking for a software based one but that's a bit risky but it depends on the code that's running

Sent from my iPhone

> --
> You received this message because you are subscribed to the Google Groups "NYCResistor:Microcontrollers" group.
> To post to this group, send email to nycresistormi...@googlegroups.com.
> To unsubscribe from this group, send email to nycresistormicrocon...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nycresistormicrocontrollers?hl=en.
>

Chris Clearfield

unread,
Mar 20, 2012, 9:43:13 PM3/20/12
to nycresistormi...@googlegroups.com, NYCResistor:Microcontrollers
Not sure of this is on point, but I used the OneWire library to hookup a temperature sensor to arbitrary pins on the arduino. If I recall I instantiated the pins as part of the class.

I'm guessing that this is different, though.
C

Guan Yang

unread,
Mar 20, 2012, 10:11:52 PM3/20/12
to nycresistormi...@googlegroups.com
I am pretty sure Wire uses hardware support for I2C that requires those particular pins. In theory you could implement I2C like SoftwareSerial for async serial, that would run on any pin (or any pin with an interrupt), but I haven't seen such an implementation.

What's on those pins? Can you move it?

Joel Murphy

unread,
Mar 20, 2012, 11:18:46 PM3/20/12
to nycresistormi...@googlegroups.com
I2C is implemented in hardware on arduino pins A4 and A5. A whole pile of control registers make it easy to run the protocol with internal flags and interrupts. Its fairly complex The back and forth -ness of it, with acknowledge bits flying (or not flying) every where and changing pin MODE statesWire library mucks about in those control registers, so it's not possible to run Wire on anyy other pins. 
Your next recourse software. There's plenty of I2C waveform data out there and in the datasheet for the DS1307 to make it doable. The bits and bytes commands in arduino make the code easy to debug.

Making the world safe for robots
-----------
Any noise in the prior signal has been inserted by the iThing

Joel Murphy

unread,
Mar 20, 2012, 11:33:39 PM3/20/12
to nycresistormi...@googlegroups.com
Meant to add the only other issue is timing. datasheets will have a good starting point for trial and error to get a workable clock with delays. Longer transmission streams, longer tweeking.... But totally doable. I wrote a software I2C in PICBasic years ago.


Making the world safe for robots
-----------
Any noise in the prior signal has been inserted by the iThing

derek enos

unread,
Mar 21, 2012, 12:04:36 PM3/21/12
to nycresistormi...@googlegroups.com
Sparkfun's ADNS2620 Arduino Library serves as an example of a software I2C-esque implementation that allows for arbitrary SDA/SCL pin assignment.  It's a good starting point, but will require modification to communicate with the DS1307.  For example, the ADNS2620 does not support multiple slave devices, so its protocol doesn't include a 'slave address' field, which the DS1307 requires.

If your application can afford to sit idle and wait for each transaction to complete, bit-banging (implementing in software) a synchronous protocol like I2C is relatively straightforward.  There's information to be found on the subject by searching for things like "bit-banging I2C", "bit-banging serial", etc.

If you decide to attempt it, the "I2C Data Bus" section of the DS1307 datasheet describes the DS1307's I2C protocol and the "AC Electrical Characteristics" section lists the SDA/SCL timing requirements.


Derek


-Adrienne

Guan Yang

unread,
Mar 21, 2012, 12:12:38 PM3/21/12
to nycresistormi...@googlegroups.com
Here's a more ridiculous idea that might be easier: Get a second Arduino (or just a bare ATmega328P, much cheaper) and have that talk I2C to the device. Talk to it with whatever pin you have left, SPI or pin 0/1 UART or SoftwareSerial on an arbitrary pin.

On Wednesday, March 21, 2012 at 12:04 , derek enos wrote:

> Sparkfun's ADNS2620 Arduino Library (http://www.sparkfun.com/datasheets/Widgets/ADNS2620.zip) serves as an example of a software I2C-esque implementation that allows for arbitrary SDA/SCL pin assignment. It's a good starting point, but will require modification to communicate with the DS1307. For example, the ADNS2620 does not support multiple slave devices, so its protocol doesn't include a 'slave address' field, which the DS1307 requires.


>
> If your application can afford to sit idle and wait for each transaction to complete, bit-banging (implementing in software) a synchronous protocol like I2C is relatively straightforward. There's information to be found on the subject by searching for things like "bit-banging I2C", "bit-banging serial", etc.
>

> If you decide to attempt it, the "I2C Data Bus" section of the DS1307 datasheet (http://datasheets.maxim-ic.com/en/ds/DS1307.pdf) describes the DS1307's I2C protocol and the "AC Electrical Characteristics" section lists the SDA/SCL timing requirements.

>
>
> Derek
>
>
> On Tue, Mar 20, 2012 at 9:00 PM, Adrienne Humblet <amhu...@gmail.com (mailto:amhu...@gmail.com)> wrote:
> > Hi,
> >
> > I'm trying to hook up a DS1307 RTC chip to an Arduino Uno. The DS1307
> > uses the I2C bus which requires 2 connection to the Arduino. The
> > Wire.h library (which is what the Arduino uses for I2C protocol)
> > expects the SDA (serial data) and SCK (serial clock) connections in
> > the Analog 4 and Analog 5 pins of the Arduino.
> >
> > Does anyone know how to make it such that the Wire library expects SDA
> > and SCK in other pins? Pins A4 and A5 are already taken up by other
> > non I2C devices.
> >
> > Does anyone know what I'm talking about?
> >
> > I thought it would be easy, but when I look in Wire.h I don't see any
> > pin assignments.
> >
> > Thanks!
> > -Adrienne
> >
> > --
> > You received this message because you are subscribed to the Google Groups "NYCResistor:Microcontrollers" group.

> > To post to this group, send email to nycresistormi...@googlegroups.com (mailto:nycresistormi...@googlegroups.com).
> > To unsubscribe from this group, send email to nycresistormicrocon...@googlegroups.com (mailto:nycresistormicrocontrollers%2Bunsu...@googlegroups.com).


> > For more options, visit this group at http://groups.google.com/group/nycresistormicrocontrollers?hl=en.
>
>

> --
> You received this message because you are subscribed to the Google Groups "NYCResistor:Microcontrollers" group.

> To post to this group, send email to nycresistormi...@googlegroups.com (mailto:nycresistormi...@googlegroups.com).
> To unsubscribe from this group, send email to nycresistormicrocon...@googlegroups.com (mailto:nycresistormicrocon...@googlegroups.com).

doug brantner

unread,
Mar 21, 2012, 1:39:58 PM3/21/12
to nycresistormi...@googlegroups.com
If you need the analog pins for analog inputs, couldn't you get an
external Analog-To-Digital Converter to add inputs to the arduino
somehow?

> nycresistormi...@googlegroups.com.


> To unsubscribe from this group, send email to

> nycresistormicrocon...@googlegroups.com.


> For more options, visit this group at
> http://groups.google.com/group/nycresistormicrocontrollers?hl=en.
>
>

--
Sent from my mobile device

Doug Brantner
doug.b...@gmail.com
pretendtodiy.blogspot.com project blog

Reply all
Reply to author
Forward
0 new messages