Logging Car Data on Android

By Eric Lathrop on

An example graph of your data

I'm interested in the quantified self and I wanted to log data about my car and how I drive. I'm also concerned about privacy, and wanted to keep my data private and not rely on a company or service. Since I already had a Android smartphone, I was able to put together a fully automated system for only about $35!

Connect to your car with an OBD-II Adaptor

All cars sold in the U.S. after 1996 have a OBD-II port that lets you talk to the computers built inside of your car. If you have a smartphone, you can buy a cheap OBD-II to bluetooth adaptor for $25 or less. Make sure you read the reviews carefully because the quality varies wildly.

These adaptors are all based on the ELM-327 chip that converts the OBD-II port into a wireless serial device. If you have a serial terminal you can actually type commands into a prompt running on the chip and read data all by yourself!

Log the OBD-II Data with TouchScan

You can find a multitude of apps on the Play Store to interface with your OBD-II adaptor. After surveying several, I settled on the TouchScan app for $3.95.

TouchScan

TouchScan had the most polished, responsive, and intuitive user interface of all the apps I tried, (including the more popular Torque Pro app).

After installing your OBD-II adaptor in your car, turn your key so the accessories power on. This usually powers on the Engine Control Unit (ECU) in your car, which is the main computer that will send data to your OBD-II port. Now, you should be able to pair your Android phone with the OBD-II Bluetooth adaptor. If you're asked for a PIN, it's probably "1234". Once paired, you can launch TouchScan and connect it to your adaptor.

With TouchScan connected, navigate to Settings->Communications, and enable "Connect On Startup" and "Connect Silently".

TouchScan communications settings

Next, navigate to Settings->Log Setup, and check "Logging Enabled". If you want the log to include your GPS coordinates, enable the "Log GPS Items" setting. Now you can click on "Select Items to Log", and select from a list of all data points you want TouchScan to log.

TouchScan logging settings

Now, whenever you open the TouchScan app in your car, it will log at OBD-II data you configured to your phone's internal storage.

Automate Data Logging with Tasker

I don't want to have to remember to launch TouchScan every time I get in my car, so I used the wonderful Android automation tool Tasker to automate it for me.

Tasker

Open Tasker, switch to the Tasks tab, and add a new task called "TouchScan". Add an action, under the "App" category, of type "Load App". Select TouchScan from the list of apps.

Press the back button to return to the main screen.

Switch to the Profiles tab, and add a new profile with a context of type "State" in the "Net" category under "Bluetooth Connected". You should be able to press the magnifying glass icon to detect the OBD-II adaptor for both the name and address fields.

Tasker profile for Bluetooth Connected to the OBD-II adaptor

At this point, your Android phone will automatically log OBD-II data whenever it connects to the Bluetooth adaptor. The catch is that Android will not automatically connect to the Bluetooth adaptor!

Automate the Bluetooth Connection with Bluetooth Auto Connect

The Bluetooth Auto Connect app fills in a missing gap in Tasker's functionality: it forces the phone to connect to a Bluetooth device that the phone is paired with.

Bluetooth Auto Connect

Since Bluetooth Auto Connect is also a Tasker plugin, you don't need to interact with it directly. Inside of Tasker, add a new profile called "Connect to OBD-II". Add an action, under the "Plugin" category of type "Bluetooth Auto Connect". Click on the pencil icon on the Configuration heading. Under "Devices", make sure your OBD-II adaptor is selected.

Tasker configuration for Bluetooth Auto Connect

Now you need to add a profile to trigger the "Connect to OBD-II" task you just created. This will be different for everyone. I created three profiles to trigger the task:

  1. "Headset Plugged" for when I plug my phone into my car's AUX port.
  2. "Power" for when I plug my phone into my car charger
  3. "Display On" for when I just turn on my phone's screen.

You may want to create tasks to trigger the profile off a car dock or NFC tag, it's up to you! Now your phone is automatically logging data whenever you're in your car, and you don't even have to think about it!

Export the OBD-II Data with Syncthing

I configured the Syncthing app to share my car's data with my home PC for backup and analysis.

Syncthing

The TouchScan app stores the data logs in the Android/data/OCTech.Mobile.Applications.TouchScan/files/vehicles/[VIN]/CSVLogs/ folder. Simply share an empty folder on your PC, and sync it to this folder on your phone.

Summary

You are now logging tons of interesting data about your car, all without ever having to think about it or take any explicit action. It's all running on software and computers under your own control, and you never have to worry about some service shutting down, or someone selling your data to advertisers. Make sure to encrypt all your devices!