Programming my particular DS1302 RTC

I have spent days reading everything I could find and watching all the YouTubes that were even slightly relevant but am no closer to a solution.

I have this RTC

http://www.ebay.com.au/itm/121481908939?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

It is probably not a very good one and I would buy any other at the drop of a hat BUT for the 6 week wait cycle. So I'm stuck with it.

In my research I have read about 3 pin RTCs, 4 pin ones and 5 pin ones but never a 6 pin one (which mine is). Even the description in my item talks of "Simple 3-Wire Interface" but it has 6 pins/wires? These are - RST, I/O, SCLK, GND, VCC2 & VCC1. a few articles talk of using pins A4(SDA) & A5(SCL). None of my six pins is SCL nor SDA.

Some articles talk of SPI and I2C too. So I am totally confused. I have looked at the Rtc_Pcf8563 library and the DS1302 library. There is also talk about needing and NOT needing pull-up-down resistors :frowning:

I have a further complication in that I would like to leave my 128X64 OLED display attached (for debugging and feedback) and this DOES use SCL and SDA. Can 2 different devices use SCL and SDA at the same time?

I have Uno and Mega clones but would prefer to use my Nano clone if that makes a difference.

Could some kind, brilliant person tell me how to connect MY (6 pin) RTC (and leaving my OLED connected) and write a sketch to initialize MY RTC and read it back with indication as to what is plugged in where? The OLED works PERFECTLY with the u8glib library. (or point me at such a sketch) :o

I will wrap your sketch around my u8glib example....

Thank you kindly (in anticipation) :smiley:

from what I understand of the data this is an odd mix of I2C and SPI. It has a slave select pin the CE. but it needs to be made HIGH during wright and read instead of LOW like with SPI. the dataLine, the I/O is bidirectional like with I2C but there is no ACK bits mentioned or what so ever, so that excludes the Wire.h library for I2c. SPI uses 2 uni directional datalines the MOSI and the MISO.

this is the 3-wire interface, as I have no experience with this I'd like to point you to my first google hit :slight_smile:

http://playground.arduino.cc/Main/DS1302

this site should answer every question of yours. From a quick read of it I would say, throw it in the bin and buy a ds1307 with I2C

I would except I would have to wait at least 6 weeks for delivery :frowning:

Looking at your link (thanks) can I conclude that CE is the same as RST?
(I had read this thread(?) before)

Plus there is no indication what to plug where (digital pins? A4? or A5? etc)?

How will this (MY) RTC (or the DS1307 you suggest) co-exist with the OLED display on A4 & A5?

Plus will any DS1307 do or are there traps for the unwary (like the one I fell into)?

Thanks for your response :smiley:

Had a quick in eBay.... There was another exactly like mine but 5 pins this time!!!! Another trap!?

There is an I2C DS1307 with 7 connections on one side and 5 on the other!!!! How the *&^% do you connect THAT!?

Best way I found to run a DS1302 was with Henning Karlsen's library here. If yours is really a 1302, then there are no SDA/SCL lines since it's not an I2C device. 1302 datasheet

The DS1307 is simpler though because it's I2C, and just goes on the SDA/SCL bus along with other I2C devices as long as the addresses are different. I have an Adafruit AF931 and Sparkfun's DS1307 happily together on the same board sharing the SDA and SCL. See top left of attached photo. Sharing is the whole point of the I2C bus; in fact I've had that setup running with 2x I2C EEPROMs as well. All happy together....

funny i see many differnt DS1302

but i got it working last week with this libary
https://www.virtuabotix.com/virtuabotix-ds1302-real-time-clock-module-pin-out-coding-guide/
i also found other libarys but this one works the best

and mine doesnt use i2c or SPI its just 3 wires to any IO you like.

and to tell you how bad it is, i found a article that says it adds or removes 2second each day!

and as i sad i got it working a week ago and it got a offset of +-2min

as i see on the images your 6pin version as VCC1 and VCC2
one should be connected to the battery and the other one to the IC and you need the one thats connected to the IC.

Thanks for all your replies :smiley:

I went with JimboZA's as it was first.

I downloaded and copied the library and loaded the easy example....

Modified the date and time etc. Today is a good day as the are NO worries whether it is DD/MM/YY or MM/DD/YY.... 01/01/2015. I set the time to 11:39:00 and uploaded the sketch.

Activated the serial monitor and the time never changed :frowning:

Checked everything, all okay? There is NO CE so I connected pin 2 to RST! Right????
I also plugged 5V to VCC2 and left VCC1 unconnected????

Changed the time to

Thursday 01.01.2015 -- 11:47:00
Thursday 01.01.2015 -- 11:47:00
Thursday 01.01.2015 -- 11:47:00
Thursday 01.01.2015 -- 11:47:00

and that is what the serial monitor printed for a LONG time :frowning:

Help Please....

I thought I would move 5V to VCC1 but the COM dropped when I touched the terminal and the battery was too hot to touch!!!!

Any further thoughts? :o

Hi I just dug my 1302 out, setting it up. Will report once I had coffee..... (7am here)

Righto- I connected my 1302 to the pins as required by HK's sketch DS1302_Serial_Easy . Mine's a loose chip not on a little board, so I took Arduino 2 to 1302 5, 3 to 6 and 4 to 7. Jammed a crystal into 1302 pins 2 and 3; power and ground to 1302 pin 1 and 4. Opened sketch, changed delay to 10000 so it didn't whizz too fast for a screen shot.

Got the below output: time updating every 10 seconds.... left it until the minutes had changed too. All is good, I'm afraid.

Can you see the traces on that little PCB?- can you track them back to the chip to verify which pin on the edge is which?

Hour incremented properly as well...

1302 output2.JPG

Thanks a lot for your trouble. :slight_smile:

Bit disheartened at the moment so I just ordered 3 DS1307s from 3 different sellers due on the 19th (ha!ha!). Hopefully one of them will worked as specified as my 1302 is a bit disappointing. :frowning:

Will try spirit's suggested library in a bit. Can't understand why the battery got so hot????

Did you order loose 1307 chips or on boards like your 1302? Because if you get loose chips you'll need crystals as well.

No complete mounted chips just no batteries.... So have to buy some 2032's

Here's one of them

http://www.ebay.com.au/itm/201245272395?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

Hi,
I have always used the DS1307 and no problems at all, even it left for months the time holds well as long as you fit the CR2032/1220 back up battery... I have put on my own micro PCBs for controlleres, etc.

Yes I have a couple of those modules, they have memory on them too, but never used it. The DS1307 has a small amount of memory for holding alarm values, etc. I'm sure you will be Ok with them!!

Regards

Mel.

Attached images. My micro board.

I wonder though....

One side of the board, labeled P1, has BAT, the 4 I2C pins(?), DS and SQ. On the other side, labeled P2, has the 4 I2C pins and DS....
The setups I have seen just wire in the I2C terminals on the P2 side. Why not the DS? And if wired where does it connect to?
And what about the BAT, DS & SQ pins on P1? In fact, why P1 and P2?
With the standard i2c pins wired only will the battery trickle charge?
Questions? Questions? Questions? :slight_smile:

I got some weird ones from China that completely refuse to cycle time unless the backup battery is installed. You can set it but the battery is needed to make it clock.

Also, setting these things is a pain. My solution

I am kind if anal about the second being reasonably correct, so I can pick up the TV universal remote and set the time anytime I get frustrated!

Ray

Why not the DS? And if wired where does it connect to?

I have seen reference that the DS pin/pad is a breakout for the one wire connection on a DS18B20 temperature sensor. Urban legend?

Impressive solution Ray.... :sunglasses:

I'll have to look you up when I design and code my Mains relay to switch on TV LED strip backlight and soundbar when I press "ON" on my Sony TV remote.....

I'm converting a PICAXE BASIC program to a C++ sketch (for my brother) to kill time....

Thanks :smiley:

Hi louwin.

I'm converting a PICAXE BASIC program to a C++ sketch (for my brother) to kill time....

As an old Picaxer I still do that sometimes, Picaxe basic simple but confusing at times... "C" Well I'm still learning, just play with the code until it works, often a silly mistake. I have never used the DS1302 only the DS1307 which I find works fine.

Regards

Mel.