Posted by Jonathan Oxer
The final project of the book is turning out to be epic. It's taken me far longer than I expected, and I've hit quite a few snags along the way. I've also had to make quite a few compromises because if I implemented everything I wanted it would take up half the book.
The big problem initially was communications with OBD-II, which was a piece of cake for my previous car datalogger (running on Linux) but turned out to be more tricky on an Arduino. Eventually it got to the point where I just cried and twitched a little bit whenever I thought about working on it, so to save my sanity I ditched my original codebase and switched to working on OBDuino instead.
OBDuino is an offshoot of the MPGuino project, which is primarily intended to be a tool for helping people drive more economically by providing real-time engine performance and fuel consumption information. It's developed collaboratively on the EcoModder website and it's a perfect example of what Arduino is really good at: providing a cheap, simple, flexible platform to allow people to develop something to suit their own requirements. There is now dedicated MPGuino hardware that has grown beyond its Arduino origins, but that's a good thing. It shows Arduino did its job.
Anyway, the point is that in the end it's been easier to take the functional code I had for GPS, flash memory storage, and a serial console, and graft those features onto the existing OBDuino codebase rather than graft OBD support into my codebase. So now I have an OBDuino variant that requires a Mega to run (unlike the original, which will run on a Duemilanove) but adds GPS and datalogging.
The datalogging feature is really cool, because it logs GPS plus OBD-II data which can then be correlated and converted to other formats. This afternoon I went for a little drive and when I came back I wrote a script to parse the CSV file stored by OBDuino and generate a KML file to pass into Google Earth, with the result that I can now generate things like this:
(Click the image to see the whole thing full size)
The track is generated from the lat and lon stored from GPS, and the height indicates the speed of the car. By switching the columns selected by the script I can plot position against RPM, load, temperature, or any other value logged from the OBD-II data. The prototype hardware is still a total mess and the code is only half done, but as long as I don't sleep for about the next 5 days the project should just sneak in within the publishing deadline.