Pages: [1] 2   Go Down
Author Topic: Updated DS1307 simple library for arduino 1.0 and older  (Read 10987 times)
0 Members and 1 Guest are viewing this topic.
perpignan, france
Offline Offline
Sr. Member
****
Karma: 2
Posts: 337
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all

I just corrected a few bugs in the DS1307.h library found on this forum, and added 1.0 compatibility.

I added a new example sketch with detailled comments, in french and in english
(DS1307_demo_en or _fr)

You can find the archive here :
http://bricofoy.free.fr/forums/arduino/DS1307.zip


Please report bugs to bricofoy (at) free.fr

Enjoy
« Last Edit: February 21, 2012, 10:01:32 am by bricofoy » Logged

-tu savais que si tu passe le CD de windows à l'envers, tu entends une chanson satanique ?
-non, mais il y a pire : à l'endroit, ça l'instal

Coppell, Texas
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm relatively new to the Arduino platform and am trying to use the DS1307 for
a timestamp source.  I've downloaded the DS1307.h library and have tried to run
some of the examples.  The sketches compile and load without error
but the output is not a valid date (for example the  DS1307_demo_en sketch
produces the following timestamp: "Actual time : 45:85:85 7 165/45/2165")

What pins should I be using for SDA and SDC on the Arduino UNO?

Thank you,
Logged

perpignan, france
Offline Offline
Sr. Member
****
Karma: 2
Posts: 337
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sda is A4 and sdc is A5. You must have pullups resistors somewhere on the I2C bus, only on one device.

Regarding the program output, did you set time in the ds1307 first ?
When entering for exemple h00m00s00 R , and then some spaces, what is the next output ?

Logged

-tu savais que si tu passe le CD de windows à l'envers, tu entends une chanson satanique ?
-non, mais il y a pire : à l'endroit, ça l'instal

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bricofoy,

I just pulled out my DS1307 this morning and finally decided to hook it up.  It's good to see the community already active with support.  But, I, too, get the same results as miker.  To answer your question, when I enter 'h00m00s00 R  ' I get the following output:
Quote
Actual time : 45:85:85 7 165/45/2165
hours set to 0

Actual time : 45:85:85 7 165/45/2165
minutes set to 0

Actual time : 45:85:85 7 165/45/2165
seconds set to 0
Actual time : 45:85:85 7 165/45/2165

Actual time : 45:85:85 7 165/45/2165

Actual time : 45:85:85 7 165/45/2165

And here's what I get when I enter 'h08m59s00M03D25Y12':
Quote
Actual time : 45:85:85 7 165/45/2165
hours set to 8

Actual time : 45:85:85 7 165/45/2165
minutes set to 59

Actual time : 45:85:85 7 165/45/2165
seconds set to 0

Actual time : 45:85:85 7 165/45/2165
month set to 3

Actual time : 45:85:85 7 165/45/2165
day of month set to 25

Actual time : 45:85:85 7 165/45/2165
year set to 12

Actual time : 45:85:85 7 165/45/2165


Any idea what the problem might be?

Gene
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am getting errors like error wconstants.h: no such file or directory what is my problem pls help me
Logged

perpignan, france
Offline Offline
Sr. Member
****
Karma: 2
Posts: 337
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



Any idea what the problem might be?

Gene

I'm afraid not smiley-sad Seems the communication with the ds1307 is wrong. Are you sure about your I2C bus ? Do you have another I2C device to connect on the bus and try to see if it works ? Make sure you did not reverse SDA ans SDC pins between arduino board and DS1307.

I'm quite puzzled you got the exact same output Miker got... Looks like a software bug (or you both have the exact same hardware issue, but this sound strange). It should be interesting to know wich arduino version you and miker are using ? So you should also try with another library for the DS1307, maybe there is a large bug lurking around in the one I updated :/

i am getting errors like error wconstants.h: no such file or directory what is my problem pls help me

What arduino IDE version are you using ? I tested with both 1.0 (wich I use) and 0.22 and it worked fine.

Please include the complete error message and tell us what program are you trying to compile, one of yours or one of the examples provided with the library ?
« Last Edit: March 25, 2012, 01:46:14 pm by bricofoy » Logged

-tu savais que si tu passe le CD de windows à l'envers, tu entends une chanson satanique ?
-non, mais il y a pire : à l'endroit, ça l'instal

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm running Arduino v.1.0 software and the board is an Arduino Uno rev 3 board.  I checked the SDA and SDC pins the were correct.  I tried switching them anyways just in case and that didn't work.  I'll see if I can dig up another I2C device to see how that works.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13471
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Nick Gammon has a I2C scanner on his (very good) website - http://www.gammon.com.au/forum/?id=10896 - that might be of help...

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

perpignan, france
Offline Offline
Sr. Member
****
Karma: 2
Posts: 337
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just tried  to reproduce the error you got, and the only way to produce something like that (but not with the exact same output) was to short-circuit sda and sdc, or to use wrong pullup resistor value.

can you try the i2c scanner robtillaart mentionned ?
Logged

-tu savais que si tu passe le CD de windows à l'envers, tu entends une chanson satanique ?
-non, mais il y a pire : à l'endroit, ça l'instal

perpignan, france
Offline Offline
Sr. Member
****
Karma: 2
Posts: 337
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

okay, miker and gdahilig, I eventually got your exact same output :

Heure actuelle : 45:85:85 7 165/45/2165

I achieved this... when unpluging the DS1307 !

So this is exactly what I suspected : there is a problem in your I2C bus, perhaps wrong pullup resistors values, or more basically your ds1307 chip is just dead.

In the next release of the lib, I will include a communication test to verify DS1307 respond before any further operation, and output a warning in such case.
« Last Edit: March 28, 2012, 01:14:15 pm by bricofoy » Logged

-tu savais que si tu passe le CD de windows à l'envers, tu entends une chanson satanique ?
-non, mais il y a pire : à l'endroit, ça l'instal

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bicofoy,

Sorry it took so long for me to reply.  Pull up resistors did the TRICK.  I had none (doh!), but once those were put in, it all seems to work great! 

Thanks for the much appreciated help!

gene
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all

I just corrected a few bugs in the DS1307.h library found on this forum, and added 1.0 compatibility.

I added a new example sketch with detailled comments, in french and in english
(DS1307_demo_en or _fr)

You can find the archive here :
http://bricofoy.free.fr/forums/arduino/DS1307.zip


Please report bugs to bricofoy (at) free.fr

Enjoy

Quote
I tried to show the time and date in arduino with RTC 1307, but after I turn off the power and   turn it on  again the next day, hour and date don't update,, confused why
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13471
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Do you have a backup battery on the RTC?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Do you have a backup battery on the RTC?

yes I put 3.3 volt battery also in DS1307, but date not updating, the time updating but late from time actually...

why? i'm confused...
« Last Edit: May 07, 2013, 08:34:49 pm by Fightforjuly » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe your RTC is "broken".

I have a couple of tiny RTC bought on ebay and one of them works fine and the other one, when I poweroff external battery, loses the hour. So, external battery doesn't work. I tried with the other one's battery and same happends.

But the other one, works fine with and without external power.
Logged

Pages: [1] 2   Go Up
Jump to: