Which will be the best way to count time without rtc?

So I'm working on a project where I need to count time in hour format. Like a elapsed time counter. But there are many parts where I need to do the same conversion again and again in this way : millis/3600000
So I tried to make a extra function that'll return the 'time' variable if it gets hours as input. But I was trying to define the data type as unsigned long. Ide isn't compiling it showing error. What am I doing wrong? Can int data type do the job? I don't need 100% precision. So I'm ditching rtc. Any suggestions is appreciated.

I'm coding on Android. Here's the error picture

Start by posting your best attempt at writing a sketch to do what you want, using code tags when you do

Hi,
Help us help you, your 'project is in your head.
Post your code and error msgs (using the appropriate </> tags) .

In the IDE there is a "copy error messsage" button. That will copy the entire error message to the clipboard. Then you can paste the message into a post. Paraphrasing the error messsge leaves out important information.

Edited

I couldn't find copy message so I edited it with screenshot.

Hi, @imposterwolf
Your code missing the "void loop()" function, required in projects with the Arduino IDE.

Although your time function requires 2 parameters, you didn't supply them.
I tested your code in the simulator and it compiled without errors.

I suggest you learn how to post code and errors correctly.

A really, really good way to handle clock times without any RTC is the DateTime library.

I looked into it and I think rtc would be the best choice. Anyway how much current does an rtc 1307 draw?

Yeah thanks. I forgot the parameters. I'll buy a rtc ig

You may be disappointed with the DS1307. I have a couple and they do not keep great time. The DS3231 is much better.

1 Like

No wonder that has relatively low price. Damn I bought it before reading the comment.

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