Go Down

Topic: Updated DS1307 simple library for arduino 1.0 and older (Read 11 times) previous topic - next topic

bricofoy

Feb 21, 2012, 03:59 pm Last Edit: Feb 21, 2012, 04:01 pm by bricofoy Reason: 1
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
-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

miker

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,

bricofoy

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 ?

-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

gdahilig

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

santoshaxl

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

bricofoy

#5
Mar 25, 2012, 08:35 pm Last Edit: Mar 25, 2012, 08:46 pm by bricofoy Reason: 1



Any idea what the problem might be?

Gene


I'm afraid not :( 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 ?
-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

gdahilig

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.

robtillaart


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

Rob Tillaart

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

bricofoy

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 ?
-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

bricofoy

#9
Mar 28, 2012, 08:10 pm Last Edit: Mar 28, 2012, 08:14 pm by bricofoy Reason: 1
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.
-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

gdahilig

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

Fightforjuly


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

robtillaart

Rob Tillaart

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

Fightforjuly

#13
May 08, 2013, 03:30 am Last Edit: May 08, 2013, 03:34 am by Fightforjuly Reason: 1


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...

Suriken

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.

Go Up