Go Down

Topic: RTC without hardware (Read 779 times) previous topic - next topic

Jeremytan

Hello, I'm new to arduino. I would like date and time stamp into the serial output.how can this be done without any extra hardware. if not possible, please do recommend me any rtc that i can use to do this.

liudr


Hello, I'm new to arduino. I would like date and time stamp into the serial output.how can this be done without any extra hardware. if not possible, please do recommend me any rtc that i can use to do this.


DS1307

Arduino has no integrated RTC.

Jeremytan

#2
Dec 19, 2012, 06:11 am Last Edit: Dec 19, 2012, 06:13 am by Jeremytan Reason: 1
Quote

DS1307

Arduino has no integrated RTC.


I have purchased the DS1307 from sgbotics.
http://www.sgbotic.com/index.php?dispatch=products.view&product_id=366
can i know how must i write the code in order to print the date and time? is there any sample code available?

CrossRoads

There is sample code in the Playground:
http://playground.arduino.cc/Main/InterfacingWithHardware%23Communication
Use "Edit: Find on this Page" to find DS1307 in the Time section.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

dhenry

Quote
how can this be done without any extra hardware.


It can be easily done with a timer counting cpu pulses. No need for extra hardware. And you can program in error correction (to compensate for crystal's tempco), making it potentially far more accurate than non-tempco corrected rtc.

Jack Christensen

The Time library is a software RTC. Additionally, it can be interfaced to a hardware RTC, but this is not required. As noted, without additional hardware, accuracy is dependent on the system clock.

A feature of the ATmega328 et al is a "Real Time Counter with Separate Oscillator", which does require an external 32.768kHz crystal. Using this feature, an RTC can be implemented that continues to run while the rest of the chip sleeps. See the datasheet, sections 9.5, 18.10.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

PeterH


Hello, I'm new to arduino. I would like date and time stamp into the serial output.how can this be done without any extra hardware. if not possible, please do recommend me any rtc that i can use to do this.


I assume that the serial output is going to a PC of some sort and that the output will consist of ascii text.

The Arduino can measure elapsed time but without an RTC or a network interface it has no way of knowing what date/time it is starting from. You could use the serial link to send it the initial date/time, but you'd need to do that every time the Arduino was restarted and to me that does not seem feasible. It is far more sensible to prefix the output with a timestamp on the PC side. What operating system is the PC running, and what are you trying to do with the serial data once it reaches the PC?
I only provide help via the forum - please do not contact me for private consultancy.

Go Up