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.
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.
DS1307
Arduino has no integrated RTC.
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?
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.
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.
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.
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.
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?