ebay clock module "I2C RTC DS1307 AT24C32 Real Time Clock Module"

g6ejd

Senior Member
Mine cost £1.98 and has a rechargeable battery in it. Works well, keeps time and the storage is really useful. I added the optional 18B20 to read temp.

I use it on my Arduino too, setting / clearing any time drift with NTP, which triggers about once every week when time difference is > 8 secs. I'm very pleased with the module. I suspect they are sold untested and sometimes they work (you get lucky) and sometimes not.
 

premelec

Senior Member
Just what is required to set my off beat DS1307 module with the editor Wizard? I.e. If I'm using 14M2 or 20M2 do I have to have the I2C coms to particular pins? [or is there a way to specify what pins are I2C connected] Thanks...
 

nick12ab

Senior Member
Just what is required to set my off beat DS1307 module with the editor Wizard? I.e. If I'm using 14M2 or 20M2 do I have to have the I2C coms to particular pins? [or is there a way to specify what pins are I2C connected] Thanks...
What?? Yes, you need to use the designated i2c pins.
 

westaust55

Moderator
Just what is required to set my off beat DS1307 module with the editor Wizard? I.e. If I'm using 14M2 or 20M2 do I have to have the I2C coms to particular pins? [or is there a way to specify what pins are I2C connected] Thanks...
See PICAXE manual 1 pages 10 and 11 for the correct pins to use for i2c comms.
These pins are fixed with no PICAXE command to allocate alternate pins unless you are keen enough to bit-bash your own i2c comms routines (hippy and others have done/posted some code snippets on this previously)
 

premelec

Senior Member
Yes I know to use I2C pins on chip - I thought Wizard was for logger module which is not an 14M2 or 20M2 chip - though perhaps the pins are the same designation as the logger chip [will look that up!] - thanks for your replies... the Wizard is likely smarter than I am and perhaps looks to see what chip is connected...
 

russbow

Senior Member
I have used the wiz to program 08m2,20m2 and 18m2 chips. It works ok. The I2C functions are not chip dependant.
However the program used will fail on the 08m2 because some pin statements are not supported. ( Like hi c.3 ).
Just delete these lines or rem out any syntax failures. The I2C will still work.

Might be useful to set time manually and add a minute to that displayed.

Clearly a case of an extra wizard to extract the PC time and paste it to your own prog.

There is a forum member good at adding extra wizards. Hint,hint :)
 

premelec

Senior Member
Thanks... I think I've got some misconceptions straightened out now - on to empiricism and blinky module!
 

nick12ab

Senior Member
Clearly a case of an extra wizard to extract the PC time and paste it to your own prog.
The DS1307 isn't accurate enough to justify skimping on proper facilities to set the time, nor can it automatically compensate for DST.

If you really must go without proper facilities for setting time, then you could use an applet such as this one I did a while ago to synchronise the time with the computer over the serial connection. Some example code for the PICAXE is seen earlier in that thread.

And there was probably a better way of dealing with the serial port than the way I did in the VB code.
 

IronJungle

Senior Member
I have a few project that use the DS1307. My experience is that they keep time incredible well; very accurate.

I mean, they can't replace GPS timing, etc., but they hold time better than other clocks in my house.
 

russbow

Senior Member
I wasn't questioning the accuracy of the clock chip, only suggesting that, to my mind, a simplified time setting procedure would be very useful.

The current data log wizard works but entails some fiddling when using the 08m2 chip. I also use the M41T81 RTC. The registers are different to the DS 1307. No problem writing the program to set the chip, but to get the time, I invoke the datalog routine and make sure it fails. Then I copy the time / date information and paste to the M41 program. I get the results, but maybe a minute or so out.

I see something like the PWMOUT wizard. Run it, gets current time / date from PC in hex and then gives an option to paste into the program.

Far too advanced for me, but just a coffee break exercise for those who know what goes on inside the Windoze box. :)
 
Last edited:

John West

Senior Member
The DS1307 doesn't determine the accuracy of the clock. It's just a sophisticated counter chip. Clock accuracy comes from the clock crystal itself, and its interaction with the 1307 clock chip, as well as fluctuations in ambient temperature. You get what you get, unless you're willing to play around with bd trace capacitance and such, as I tend to do when fooling around with clock circuits. I'm fussy about clocks.
 

davidwf

Senior Member
Just discovered (!!!) that there is a RTC module available from fleabay which will greatly simplify my lights timer project.
Is there an idiot guide to using it and, specifically reading from it anywhere.....basically I need to switch something off at a set time every day, I am using an 18M2
Thanks
 

hippy

Ex-Staff (retired)
Just discovered (!!!) that there is a RTC module available from fleabay which will greatly simplify my lights timer project.
Is there an idiot guide to using it and, specifically reading from it anywhere.....
Without knowing what that RTC module is it is hard to say, or what "reading it from anywhere" means.
 

davidwf

Senior Member
oops my apologies.... the module is the one on ebay referred to in an earlier posting - same as this
http://www.ebay.co.uk/itm/DS1307-I2C-RTC-Real-Time-Clock-AT24C32-Board-Module-Arduino-ARM-PIC-UK-SELLER-/181981338821?hash=item2a5eeedcc5:g:atIAAOSwZG9WisPU

"reading it from anywhere" actually meant is there an article detailing how to read from the RTC using a PICAXE .........anywhere (meant is there such a guide anywhere !) ... again apologies for not making that clear ..... feeling silly now :)
 

davidwf

Senior Member
Thanks hippy.... am I making this too complicated for myself ?.... all I need to do is trigger an event to happen at a fixed time of day..... would just the basic DS1307 chip do what I need ?
 

hippy

Ex-Staff (retired)
Thanks hippy.... am I making this too complicated for myself ?
I don't know. You resurrected a thread which is three years old and there is not a lot of context to what you want.

all I need to do is trigger an event to happen at a fixed time of day..... would just the basic DS1307 chip do what I need ?
Used with a PICAXE then very probably. Once the RTC is programmed with the correct time you can then read the time as that advances and then do whatever action you need to do at the trigger time. You can probably even program the RTC to give an alarm activation at the time you want, you would just need to look for that activation.
 

westaust55

Moderator
As hippy has indicated, there is many threads on the PICAXE forum providing examples of code to set up a DS1307 and read the time from the RTC.

An alternative RTC is the DS3232 which also provides an inbuilt temperature sensor, two Time-of-Day (TOD) alarms and a
greater amount of battery backed RAM with 236 bytes of RAM memory (compared with the 56 bytes of RAM in the DS1307 and DS1338 chips).
I have previously posted some information and demonstration code for the DS3232 here:
http://www.picaxeforum.co.uk/showthread.php?23739-Getting-Started-with-the-DS3232-RTC-and-a-brief-comparison-of-some-other-RTC-chips
 

neiltechspec

Senior Member
Forget the DS1307, I found they are too inaccurate.

A better choice, as has already been suggested, is the DS3232. Or as I use, DS3231, if you don't want all the extras.

Neil.
 

hippy

Ex-Staff (retired)
Counting mains cycles is a fairly accurate way of doing timed events. That could be very easy and safe to do with just one resistor if driven from a Walwart PSU which gives low voltage AC. The disadvantage is that it will probably need resynchronising if mains power goes out.
 

westaust55

Moderator
Would appreciate any guidance to the use of and setting up of this http://www.ebay.co.uk/itm/111869733216?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT which I have ordered
As previously mentioned all I want is one or possibly two timed outputs to happen at the same time each day
Have you looked at the thread via the link I provided back in post 58.
The difference between the DS3232 and the DS3231 is that the DS3232 includes some memory and a temp sensor.
The code in the thread I linked to covers setting the time and date, setting an alarm (1 of the 2 available), displaying the time and acting when a time of day event occurs.

Have a read of my information, the DS3231 datasheet and try a few experiments.
 

davidwf

Senior Member
looks like that post will be useful... are there any connection diagrams available ?
I'd like to use it on an 18M2 pin 6 if possible
 

westaust55

Moderator
looks like that post will be useful... are there any connection diagrams available ?
I did not prepare a schematic diagram as the i2c bus pins are fixed by default. (Refer to PICAXE manual 1 page 10 or the Pinout diagrams here: http://www.picaxe.com/What-is-PICAXE/PICAXE-Pinouts/

The first line in my program indicates it was the the 18M2 chip.

Line 45 in the program indicates the pin used for the interrupt: SETINT %00000000, %10000000 ;set up for an interrupt on pin C.7 going low

I'd like to use it on an 18M2 pin 6 if possible
You cannot use physical pin/leg 6 which is logical pin B.0 with the SETINT command for the M2 PICAXE parts.
Refer to PICAXE manual 2 under SETINT or http://www.picaxe.com/BASIC-Commands/Interrupts-and-Multi-Tasking/setint/

The setint command causes a polled interrupt on a certain input pin condition.
This can be a combination of pins on the default input port (portC).
[only] X2 parts can also be redirected to look at a different port if required.
 

PhilHornby

Senior Member
Other choices

Forget the DS1307, I found they are too inaccurate. A better choice, as has already been suggested, is the DS3232. Or as I use, DS3231, if you don't want all the extras.
The DS1307 in my 'Hot water controller' loses 17 seconds a day, so it's 'corrected' at 04:00 every morning. It was last set on Oct 25th (end of British Summer Time) and is currently 1 minute fast. The main issue I faced was in setting (and verifying) the time. I ended up setting it via an IR remote, and pulsing out the current time using a buzzer when required - lots of hardware and code that are definitely peripheral to the task in hand.

My next project that needs an accurate time source will be using an ESP8266. At around the same price as the DS3231-based modules, it can sync using NTP over the built-in wifi and auto-correct for daylight saving. From power-up to having accurate time is around 5 secs, so I see no need for battery backup. Admittedly, there is the small issue that it needs programming to do this...

I'm wondering if I can squeeze an ESP8266 module onto a 'TinyRTC' compatible board and retrofit it ... thus avoiding my twice-yearly visit to the airing-cupboard with the TV remote!
 

davidwf

Senior Member
basic things

I am struggling with the basics here :( .... how do I set and later read the time back to my PIC editor / i.e. the laptop display ?... I don't need a separate LCD display etc.

Thanks and apologies for what,I am sure is something very simple !
 

westaust55

Moderator
I am struggling with the basics here :( .... how do I set and later read the time back to my PIC editor / i.e. the laptop display ?... I don't need a separate LCD display etc.
firstly it would help if you summarize and indicate what RTC you are now using (DS1307 or a DS32xx type, etc)

In the PE there is a wizard to generate code to set the RTC time based on current PC time.

In the PE by pressing the F8 key you open a terminal window where by using the SERTXD command you can pass data via the serial programming cable to the PC and display in the PE terminal window.
 

davidwf

Senior Member

Attachments

hippy

Ex-Staff (retired)
Using the example / sample code I can read the time but it seems to stop when the power is disconnected
It would help if you could explain exactly what you mean by that, exactly how it behaves. It could be a hardware issue if the battery is being problematic or the module is trying to charge a non-rechargeable, or it could be the PICAXE resetting the original time when power is turned back on.

Or it could be a bug in your code. It might be worth starting with simpler code to test the clock functions before including more complex functionality.
 

davidwf

Senior Member
.................Or it could be a bug in your code. It might be worth starting with simpler code to test the clock functions before including more complex functionality.
Thanks hippy..... "simpler code " ?... I'm afraid that is beyond my abilities :(

I'd of thought the battery (which is OK) would have kept the RTC running so that upon re-power of the PIC it would have read the correct time..... seems rather academic having a RTC if it doesn't do that.
 

PhilHornby

Senior Member
Charged?

Is the battery actually charged? If it's anything like the modules I bought, it's a very simplistic charging circuit.
 
Last edited:

lbenson

Senior Member
The DS3231 modules which I've bought use the rechargeable LIR2032, and the batteries on two of them have failed. I don't know if I've shorted them out with careless handling or what. They work fine when powered, but after power is removed, they forget the date and return things like 01 for date & time variables.

If the circuit is good, and the battery is good, it should not forget the date when the picaxe is powered off.
 

PhilHornby

Senior Member
It's a non-rechargeable CR2032... and yes, it is good :)
So ... you've disconnected the charging circuit?

The module I bought was the DS1307-based TinyRTC. I converted it from LiR2032 to CR2032 operation, but there was more to do than simply swapping the cell.

I removed the sophisticated Lithium-ion charge-controller circuit (i.e. R5 and D1!) :rolleyes: and also the voltage divider (R4/R6), that allowed for the higher voltage of the rechargeable call. Are you sure you don't need to make similar changes to your module?

TinyRTC.png
 
Last edited:
Top