Here were my design objectives:
- Use the Atmel AT45DB161D 16 MBit flash memory I've had laying around unused. This would involve writing my own serial interface code for hardware, something I had never done before.
- Use a real-time clock (DS1307) to generate the timestamps for the data logging.
- Log the temperature as well as the battery voltage to see what affects that may be having on the former.
- If possible, figure out a way to log at high speeds while the car is starting to see how far the voltage depresses.
Below is the circuit I ended up implementing.
On the left is the TMP36 temperature sensor, the workhorse of my previously implemented home temperature logging system. Again, not super accurate and, again, close enough for my purposes.
Down in the right corner is the new flash memory chip I learned to use. It took me too long and I made many, many mistakes trying to interface with it correctly. A logic analyzer would have saved me from hours of my mistakes and I may get something like the Bus Pirate before I undertake such a project again.
Part of my problem ended up being due to the Arduino clone I was using: the Ruggeduino. I don't know if there is something wrong with mine or if there is a design flaw but the SPI bus was not working with 100% accuracy. Bits were getting flipped and as soon as I tested the circuit on a standard Arduino, it started working. I haven't dug into the problem so I have no definitely answers as to what exactly is wrong. This is how superstitions get started.
The LED below the flash chip was used as a simple status light. The switch next to that was used to trigger a high-speed-logging mode during engine starts. I wanted to trigger this off the start relay but putting a lead on the relay prevented it from seating properly in its socket. I messed with it for an hour with no luck so had to settle on the manual switch. To trigger it, I would pop the hood, press the button, quickly close the hood and start the car. Needless to say, there were only a few engine-start events that got logged.
Lastly, the voltage divider on the right was used to measure the battery voltage.
And now the results.
As you look at these graphs, note the time scale. Each major division is one day and this is the car that my wife used for running errands. The drive time hardly shows up at all; just a series of spikes in temperature and voltage (due to the alternator charging) followed by long decays in both.
There are a few points of interest to me.
- The top graph shows a period when the car was unused for about three days. You can see the temperature rise and fall a little each day following the ambient temperature in the garage. The battery voltage on the car fell a few tenths of a volt over that time. Since the car is unused, this is the open-circuit voltage of the battery which I think we would expect to be much closer to 13V, even in the cold.
- The bottom two graphs do capture car start events (yeah!). Both show battery voltage falling below 9V. I don't have any idea how acceptable this is but it seems kind of low.
My plan is to maybe do a little more testing, at least next winter and perhaps now in the hot summer to collect a bit more data. Sometime this upcoming winter we'll replace the battery and I'll do more testing then to see how a fresh battery performs.