Pages: [1]   Go Down
Author Topic: DS1307 RTC + Due + i2c  (Read 3500 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need a little bit of guidance.  I want to use Adafruit DS1307 shield, connected to Arduino Due board, using i2c.

Arduino Due i2c is setup to use:
Logic Low: 0 volt
Logic High: 3.3 volt

Looking at DS1307, its i2c is setup to use:
Logic Low: 0 volt
Logic High: 5 volt

So.  When I sent date and time from DS1307 to Due, I will be sending 0 volt and 5 volt.  I assume 5 volt will be too much for Due.  I don't want to break my Due.  What are my options?
Logged

White River Junction, Vermont USA
Offline Offline
Full Member
***
Karma: 5
Posts: 106
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need a voltage translator to interface the DUE's 3.3V logic to the DS1307's 5V logic.

Something like this should work (but there are also many, many others):
http://www.nxp.com/documents/data_sheet/P82B96.pdf

See fig 10 of the P82B96 datasheet.  The +5V pullup you see on the left of this figure is already taken care of on the DUE board (it is actually pulled up to 3.3V on the DUE pcb).
Apply 5V (Vcc) to the P82B96 ("pin 8"), and add your own pullup resistors to 5V for SDA and SCL that go to the DS1307's I2C interface (10k are usually fine).
This figure shows one-half of the connections.  You would need to connect the SCL line in a similar manner.

The DS1307 maxes out at a 100KHz I2C clock.  The DUE's default I2C clock rate is 100KHz.

Some warnings about I2C on the DUE:
  • The DUE board has crazy-low-value pullup resistors on the TWI (I2C) lines.  Be aware of this.  Any more current load on these pins (from additional pullups) can destroy your board.  See the wonderful pin-out diagram at the top of this forum for pin capabilities.
  • The I2C library in 1.5.2 is still very limited.  Search the forum for issues.  It looks to me that this gadget should work fine, as long as you avoid the protocol shown on "Figure 6. Data Read (Write Pointer, Then Read)—Slave Receive and Transmit" in the DS1307 datasheet.

I can't believe I mentioning this, but:
The DS1307 may work if you attach the I2C lines (SDA and SCL) to the DUE directly (without using the translator chip).  Be absolutely certain that there are not any existing pullup resistors on the DS1307 I2C lines. If there are existing resistors, then you need to remove them completely from the DS1307 board, as these resistors are probably connected to +5V (which is undesirable/dangerous for the DUE).  I am not familiar with the adafriut DS1307 board, you will need to figure this out yourself. http://www.adafruit.com/products/264?

Not using a proper voltage translator chip may result in inconsistent operation of the DS1307, but no damage should be done to either the DUE or the DS1307 (as long as the warnings shown above are understood and followed).

If you don't understand these issues, then please Google some more, and then ask more questions here...

Good luck!

-Chris
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Chris, thank you for your help.  The Adafruit DS1307 shield does have two pullup resistors, 2.2 kOhm each.  I just double checked it.  So yes, I was hooking up the DS1307 shield to Due with the 2.2 kOhm external pullup resistors and it worked, but yes, I don't know how long the Due would have lasted, and I want it to last for a long time..

In the Raspberry Pi pdf, page 4, I found this information, apparently Pi is also 3.3 volt system:
Quote
To make the job really easy, we'll use the the Adafruit
DS1307 RTC Breakout Board Kit (http://adafru.it/264)- it comes with all the parts you need,
even a coin battery!
The Kit does require a little light soldering. In theory you could use all the parts and build them
onto a breadboard, but the coin holder is a little difficult since its not breadboard-friendly, so
please go ahead and build the kit. (http://adafru.it/aPf)

When building the kit, leave o ut the 2.2K&o hm; resisto rs - by leaving them o ut,
we fo rce the RTC to communicate at 3.3V instead o f 5V, which is better fo r the
Pi!

Wiring is simple:
1. Connect VCC on the breakout board to the 5.0V pin of the Pi
2. Connect GND on the breakout board to the GND pin of the Pi
3. Connect SDA on the breakout board to the SDA0 pin of the Pi
4. Connect SCL on the breakout board to the SCL0 pin of the Pi

DONT FORGET TO POWER IT FROM 5V - THIS IS FINE AND SAFE FOR THE PI - JUST
MAKE SURE TO REMOVE THE 2.2K PULLUPS AS MENTIONED IN THE LARGE RED
BOX UP ABOVE TO KEEP THE I2C PINS AT 3.3V LOGIC LEVELS

The diagrams below show the 2.2KΩ resistors in place - but plleasse rremove tthem
eiittherr by nott ssollderriing tthem iin orr cclliippiing tthem outt iiff you diid ssollderr tthem iin!! Thiiss
way,, we''llll usse tthe Pii''ss 1..8K pullll--up rressiissttorrss tto 3..3V
http://learn.adafruit.com/downloads/pdf/adding-a-real-time-clock-to-raspberry-pi.pdf

This is the clearest explanation I have found so far of what to remove and where.  So I am going to remove the two 2.2 kOhm resistors from the Adafruit DS1307 shield. 
Logged

Cookeville, TN
Offline Offline
Newbie
*
Karma: 3
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have gone through this too. Yes, the two resistors on the DS1307 breakout board pull the I2C lines up to 5V. This is NOT what you want. Remove/Don't Install those resistors and connect your own from the 3.3V supply on the board to the I2C lines. You can do this on a proto shield or something, on the arduino side of the I2C lines. The DS1307 will need 5V connected to its VCC pin, but it will not bleed over onto the I2C lines with those resistors on the breakout board removed  smiley

In summary, do not attach these resistors


Instead, attach resistors from the 3.3V supply of the Due to the Due's I2C pins.

On the breakout board:
VCC = 5V
GND = gnd
SDA = Due SDA pin
SCL = Due SCL pin.

The resistor values on the Due side will require some playing with. As mentioned above, the Due will not drive/sink much current at all. Let me know if you find a combination that works best. It will also depend on the length of your wires.

Best of Luck!
Logged

Pages: [1]   Go Up
Jump to: