obd is a ruby gem that lets you communicate with a car's OBD-II port via an adapter that supports the ELM327 command set. A great choice is the STN1110-based OBD-II UART board from sparkfun (and cable).
Simply install the gem:
|gem install obd|
And you're ready to roll:
|require 'obd' obd = OBD.connect "/dev/tty.obd"|
We can send hex commands and get a response:
|obd.send("01 0C") #=> "41 0C 26 0D"|
But, that's not very useful. Fortunately, the obd gem will translate the result for us, as well as make it available with a simpler syntax:
|obd[:engine_rpm] #=> "2435.25rpm"|
You can also turn off that pesky “Check Engine” light:
|obd.send("4") #=> "OK"|
Grab the source code on github.