Hour Meter Output

I have searched and searched and cannot find any reference to an Arduino using any sort of hour meter. I am looking to read some type of digital hour meter, but I cannot find any hour meters with digital outputs (or any outputs for that matter). Any ideas?

Use the 1hz output from a DS1307 rtc to an interrupt in on the Arduino an have it count pulses.

What do you mean by a hour meter? a clock?

There are real time clock, the DS1307 that can be used by Arduino, - just search the forum or check the site of ladyada
There are sketches for decoding DCF timing signals - no link at hand,
There is a simple stopwatch class - Arduino Playground - StopWatchClass

or do you mean a KiloWattHour Meter?
Please describe more of your context, and publish your code sofar..

Sorry for taking so long to reply...didn't get any notifications that you guys had replied (thanks for being so prompt!).

I am looking to log hours that an engine has ran (think of a lawn mower logging hours vs a car logging miles). I want to be able to log the hours that the engine has ran and then be able to read the "hour meter" to see updated hours on the engine.

I had looked at the DS1307 but I am new to this and wasn't sure how to implement it. If the engine runs for 45 minutes, I want to store that. Then when it runs for 15 more minutes I want to add that to the previous 45 minutes (thus 1 hour of total time ran). If the engine runs for 2 more hours, then add that to the existing 1 hour for a total of 3 hours. I also want a physical hour meter to read the total hours with my eyes (again, think hours on a lawn mower) similar to http://www.redingtoncounters.com/lib/download.php?RF_ITEM[]=Entry$0@473;Entry.

Does that explain my scenario better? How would you implement such a device?

If you wanted to do it properly as in "Hours at xxxx RPM" you'd need some kind of connection to the engine flywheel / camshaft. If you just wanted how long it had been running regardless of how fast it had been running, you could just detect the voltage on the ignition circuit. You could store the total running time in eeprom so it survived the power being turned off. A small HD44780 compatible LCD display would be OK for displaying hours run. With careful coding and you could live with half a minute a day accuracy the standard Uno without an external clock would suffice. It wouldn't take much more to have 2 hour figures, one for this session and grand total.

Have a look at - Data-Logger Shield for Arduino
It contains a RTC and a SD card. the example program logs temperature but that should be adapted to your needs. Every time the lawnmower is used you can make an entry to a .csv file which you can process in Excel or so.

Another option could be writing the minutes the device is used in an EEPROM counter. EEPROM is a non volatile memory in which values stay persistant over reboots. See - http://www.arduino.cc/en/Reference/EEPROM for how to write and read from it. As it is 512 bytes you can log quite a lot in there e.g.

  • 1 byte for the days total

  • 1 byte for the hours total

  • 1 byte for the minutes total

  • start date DMY (3 bytes)

  • maybe the last 10 usages
    etc

Thanks Pluggy!

pluggy:
With careful coding and you could live with half a minute a day accuracy the standard Uno without an external clock would suffice. It wouldn't take much more to have 2 hour figures, one for this session and grand total.

When you say half a minute a day accuracy do you mean that it would write ever 30 seconds to the eeprom on the Uno? Therefore it would be no more than 30 seconds "off" every time the engine turned off? How long could I store this on the eeprom of the Uno with regards to storage space?

I honestly would prefer to buy a decent looking "hour meter" and just read from it to the Uno. Do you have any ideas of something that would do that (as opposed to me purchasing a HD44780 and building the hour meter myself)?

robtillaart:
Another option could be writing the minutes the device is used in an EEPROM counter. EEPROM is a non volatile memory in which values stay persistant over reboots. See - http://www.arduino.cc/en/Reference/EEPROM for how to write and read from it. As it is 512 bytes you can log quite a lot in there e.g.

  • 1 byte for the days total

  • 1 byte for the hours total

  • 1 byte for the minutes total

  • start date DMY (3 bytes)

  • maybe the last 10 usages
    etc

So then every time the ignition was turned on, I would read the hours from the eeprom and then every, lets say 15 seconds, write back to the eeprom total hours + 15 seconds? Then when the ignition turned off, I would be no more than 15 seconds off on the hours...

Millis() on my Uno will keep time to within 15 seconds a day. How accurate the hours run meter is depends on what resolution you store the numbers at. You could keep it to the second if you wish. The eeprom will keep the numbers for years, its limited to 100,000 write cycles. If you stored the 'hours' as an unsigned long (4 bytes) and kept it to the nearest second it would store values up to 136 years. Keeping the arduino powered whilst the engine was stopped would enable the eeprom just to be written when the engine is turned off. and the eeprom is kept in reserve should the power get disconnected.

Can't give you any guidance on a different hour meters, the ones I've seen on old tractors were mechanical cable driven from the engine (showing my age). The HD47780 displays are cheap especially on ebay which fits my way of thinking. :wink:

That would be the idea, however EEPROM can't be written to too often (10.000 times guaranteed) so every 15 seconds = 2500 minutes is only 40 hours.
So the logshield with an SD card is a far better option, a 4GB card can hold millions of records, so you can keep every individual entry. This amount of log space opens doors for extra sensors like a DHT11 to measure temperature and humidity while mowing, or a light sensor or an electricity meter or ...

pluggy:
Keeping the arduino powered whilst the engine was stopped would enable the eeprom just to be written when the engine is turned off. and the eeprom is kept in reserve should the power get disconnected.

So then how do you keep the Arduino powered? Battery of the lawn mower? Add battery to the Arduino? If the Arduino is powered all the time, then I am assuming it would keep the "running tally" of how many Millis() have passed since its last write to the eeprom? How often would you suggest writing to the eeprom in case of a power failure?

robtillaart:
That would be the idea, however EEPROM can't be written to too often (10.000 times guaranteed) so every 15 seconds = 2500 minutes is only 40 hours.

Pluggy said 100,000 writes. Is it 10,000 or 100,000?

robtillaart:
Have a look at - Data-Logger Shield for Arduino
It contains a RTC and a SD card. the example program logs temperature but that should be adapted to your needs. Every time the lawnmower is used you can make an entry to a .csv file which you can process in Excel or so.

Does the Arduino have access to read from the SD card so that I could send that information via XBee to a PC?

Pluggy said 100,000 writes. Is it 10,000 or 100,000?

Pluggy is right, 100.000 it is (my typo sorry)

Does the Arduino have access to read from the SD card so that I could send that information via XBee to a PC?

The Arduino can read and write to SD card, so you should be able to send it over XBEE. (but I never tried yet).

The eeprom is just to keep the total hours running. The arduino would only write to eeprom each time the engine is turned off. It would be possible to put the arduino to sleep to conserve the lawn mowers battery after it has completed this. It could be set up to wake up again when the Ignition system is next turned on. There is no 'real time' capability, the arduino doesn't know the present time or date. Keeping tally of when it last ran wasn't in the brief :wink:

Hi,
I know this is an old topic, but it's just what I'm looking for (also). My only question is (after looking at the Stopwatchclass) whether it would be possible to use this program without the delays. I've been trying to avoid delays in my program because it interrupts the other processes as I'm sure all you guys know. I'm new at this but I'd love to include a virtual hour meter in my program if possible. Thanks for any help!

salukikev:
Hi,
I know this is an old topic, but it's just what I'm looking for (also). My only question is (after looking at the Stopwatchclass) whether it would be possible to use this program without the delays. I've been trying to avoid delays in my program because it interrupts the other processes as I'm sure all you guys know. I'm new at this but I'd love to include a virtual hour meter in my program if possible. Thanks for any help!

This thread is about six xears old now.

Six years ago the topic starter DID NOT TELL what he means by writing "hour meter".

And you want to do the same: You want to have an "hour meter" without telling what it is?

In case you want to have the "power-on time" of your Arduino program (running time since the boards last reset or last power-on, the value will be returned from the "millis() function. You just have to convert the return value of "millis()" from milliseconds into hours, minutes, seconds and you know the time for how many hours your program is running uninterrupted.

Is that what you want? Having uptime of your Arduino program in hours/minutes/seconds?
Then simply use millis() and so some math!

Or what else do you want?

Do you possibly want to add up "power-on times, so that when the Arduino runs 5 hours today, 6 hours tomorrow and 8 hours on the day after tomorrow, then you want to get a total meter rading of 19 hours in three days. despite of the fact that the Arduino had been in power-off state most of the time?
Please explain!

I use the term "hour meter" in the conventional sense- if you google that term, you will see the first result lists 24 examples, all which record total time powered up. So, your second conclusion is correct. Otherwise I would call it a stopwatch.

salukikev:
I use the term "hour meter" in the conventional sense- if you google that term, you will see the first result lists 24 examples, all which record total time powered up. So, your second conclusion is correct. Otherwise I would call it a stopwatch.

Do you have any ideas for "timer resolution", "accuracy" and "max. timer capacity" for your hour meter?

When using EEPROM as the non-volatile storage area to store a timer value during power-off times, you have to be careful about the number of EEPROM writes. EEPROM is limited in its write cy cles. I have thought about it, how to use EEPROM with limited write cycles,
I have thought a bit about UNO R3 and think I could program some hour meter for an UNO with this features without writing EEPROM to death within the next couple of years:
resolution: 1 minute

  • accuracy 0.8% absolute

. maximum timing capacity: 34000 hours before wrapping over to 0 again.

Better accuracy than 0.8% absolute of total time would require to use a RTC module, I think.

What do you think about those data for an hour meter device?

Oops, sorry I don't have email notifications set so didn't see this reply till now. Anyway, yes, I've been thinking about that resolution as well. Fortunately I don't need that much resolution. One minute would be more than enough. I was actually thinking I'd just do six minute interval updates so that I could use .1 hours, but probably 1 minute interval is better. It's very unlikely these machines will never see 34000 hours of runtime.