3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Watts-your-consumption? - Wireless Power Meter

Step 3The time keeper

The time keeper
Having got the first building block in place my next step was to create a way to capture the date and time against the flash count so I could perform mathematically averages to determine power usage over time.

So I moved on to the Real Time Clock piece of the puzzle. At this point it is worth discussing why there is a RTC in the circuit. One approach to solving my problem would be to simply send a raw counter from the Arduino and then do all of the heavy lifting at the receiving end. However, on reflection I liked the idea that I could use the battery backed RAM on the DS1307 as a store for my counter and that my "packet" of data would be able to broadcast the time that the count was accurate. This may seem like an odd decision but I think in the long term its going to serve me well.

The DS1307 is an i2c device and there are a number of articles on the device on the internet (as well as interfacing to an Arduino), so I am not going to concentrate on the ins and outs of the device. Instead I shall illustrate a pitfall I came across and the eventual design I went for.

My initial idea was to have the DS1307 RAM be the store for the counter and that during the interrupt handling routine I would read and then update the counter. However, I discovered that whilst the Wire library in Arduino is really useful it won't work in an interrupt routine (which is fair enough).

My second approach, which worked, was to maintain a counter in the Arduino RAM and then, after a configured delay in the main loop, write the value out to the DS1307 RAM.

The circuit diagram shows the connections for the DS1307 and how I hooked it up to the Arduino (note that the Futurlec mini-board I used already has the required pull-up resistors and therefore they aren't shown on the diagram).

So now I had the second building block in place. I had a means of capturing a date and time and a counter value updated by an interrupt routine.

« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
2
Followers
1
Author:mcloke74
A frustrated geek who has a day job that doesn't allow for a great deal of tinkering