Add current time (changing) without RTC

I am making a weather station and am registering some data hourly, which is shown on the serial monitor. I need to display the current time and date every time I post the temperature etc. I do not have an RTC and I won't buy one. I have tried using __ TIME __ but apparently, that time doesn't change, it is just the time when the file is being compressed.
I have also tried the day(), year(), ... but that gives me 0/0/1970 and I can't seem to change that. I am using the UNO R3 so I don't have access to wifi or ethernet...
Can anyone help? I really appreciate any help you can provide.

Welcome to the forum

How accurate do you need the clock to be ?

How many seconds per day inaccuracy would be acceptable ?

To be honest it doesn't have to be super accurate. If it is off a few seconds that's perfectly fine.

You can use the Arduino Time library TimeLib.h to keep track of time, but with the Uno, it will probably be off by many minutes per day.

For accurate time on your weather station, add a GPS module, or use a DS3231 module (accurate to 1-2 minutes per year).

Thank you. What code would I be able to use of the TimeLib.h because I already downloaded the library but it didn't seem usable to me...

Without some external reference your options are limited to building your own RTC that counts clock cycles in some way, and has the ability to be reset with some buttons. But the internal crystal or resonator is neither very accurate or very stable so it will drift off quickly.

Why are you against buying an RTC? You can buy 3 DS3231s for £11 on Amazon mounted on PCBs and ready to plug in complete with battery. They are very stable and easy to use. You will still need setting buttons.

GPS would be good but fiddly and you'd need to have sight of the sky to get the satellites. Or you could use a VLF time source like MSF (UK) or DCF77 (EU/UK) or WWVB (US) - modules are available for all, they have a small ferrite rod antenna, and there are Arduino libraries available for decoding - no need then to set the clock but they can be fiddly to get working as your Arduino can interfere with the receiver.

There are good instructions and libraries for using the DS3231 linked from the AZ Delivery page

Real Time Clock RTC DS3231 I2C Echtzeituhr kompatibel mit Arduino und

To get started, run the excellent library examples and read the library documentation.

What you are saying is, you want your weather station to contain a clock.

As with the clock on your microwave oven, you will need some way of setting the time. How do you intend to set the time? Do you have buttons on your weather station that you could press to set the time, or anything like that that you could use?

Even with just two buttons, it is certainly possible to set the time. Old-fashioned digital wristwatches used two buttons to set the time and date. One button would move between the numbers (month, day, hours, minutes). The other button would change the value of the number.

Does this sound like something you would be able to program?

Hi @jaz_beginner ,
Welcome to the forum..

Toggle the Timestamp in the serial monitor..
Little clock icon..

good luck.. ~q

Where do you post your results?
Internet knows what time it is.
A web server knows what time it is.
Your computer knows what time it is.

You can use the arduino timer. It is not accurate. But if your arduino has a crystal and is at constant temperature, you can add or remove a few minutes every day automatically (once you have established the difference of timer and real time.

Or you simply log the arduino timer number and do the correction later.

You can get a RTC (Real Time Clock) module for less then a buck. I know nothing about this vendors; RTC DS1302 Real Time Clock Module For Arduino AVR ARM PIC SMD than DS1307 | eBay but they show a decent unit for less than a buck. Of course you could count the cycles of your ac power line isolated with a transformer of course.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.