← home

Android Nexus S Car Dock System

Today I open-sourced a pet project alluded to in Flawless Systems, Android NFC Dock. It is one component of my car dock system. The primary goal is to enable playback of my music collection inside my car without having to think about it (ie, the collection is in sync with the one on my computer and phone and eliminates as much manual labor as possible). Below I detail each component:

Music Collection

Most importantly, I will start with the actual music collection. Only a few months ago this was a 10 GB collection which only resided on my desktop hard drive. With the advent of affordable and nearly-complete streaming music services, I have transitioned my music collection away from local media to the cloud. This is not entirely motivated by the car playback problem. Cloud services eliminate the need to collect, organize, and tag your own growing music collection. Upkeep of local media pushes against my goal to eliminate manual labor. I have used two services, Spotify and Grooveshark, and determined that Spotify is the superior choice because it integrates seamlessly with existing local media both on the desktop and mobile. Off-lining large chunks of music is also easier in Spotify.

Mobile Device

My mobile device is an Android Nexus S 4G (Sprint). This device serves as my primary music consumption device. It stays in sync with my desktop through Spotify (well, in sync with the cloud really) and it supports Bluetooth which is important for the next component. Additionally it has a 3.5mm headphone jack meaning I do not need a special adapter.

Headunit

A headunit is more commonly referred to as a car's “stereo”. I chose the Kenwood BT838U originally for it's ability to play music off of a local flash drive for an older mobile device I owned. The Bluetooth functionality was an afterthought; though now Bluetooth is used exclusively to connect to my Nexus S. The headunit has one USB port in the rear which is used to read local media. The USB port has one extra killer feature – it delivers power. Coupling the USB port with a car dock allows the mobile device to be charged while in the car. In reality with the Nexus S, I am able to _not lose_ charge while streaming music via Bluetooth from Spotify over a 3G/4G connection. The headunit automatically scans and connections to known Bluetooth devices. Additionally, the headunit saves the chosen media source (BT Audio vs Tuner vs CD vs USB) between power cycles meaning I do not need to manipulate buttons or knobs when I first enter the vehicle. A bonus feature is that in-car calling works perfectly over Bluetooth.

Car Dock

There are many choices for car docks, but I chose a Pro Clip/charging-holder-with-tilt-swivel-and-straight-power-cord-for-fixed-installation-513227-18507.aspx) with straight power cord based on the quality of my previous Pro Clip dock and built-in micro-USB connector. Pro Clip is a two-part system. They manufacture a custom part for every vehicle and every phone. These two parts connect to each other through a few screws yielding a very sturdy and functional car dock. I spliced the straight power cord into an regular old USB cable I had and plugged the USB cable into the back of the headunit. The dock looks great, stays out of the way, and provides power to the phone.

NFC Sticker

I have a single NFC sticker with a specially embedded string stuck onto the inside of the car dock. I used NXP TagWriter on my Nexus S to modify the contents of the sticker. The sticker is used to notify the software running on the Nexus S that the phone has been placed into the car dock.

Android Software

This software is a key component. Read Flawless Systems to learn what steps must be performed _without _this software. It is open-source and can be found here. Fair warning, this is my first endeavor into Android development and is certainly hacked together but it does work. Essentially, it registers for the “NFC Intent” and compares all incoming tags with an expected string. When the expected string is found, the software knows the phone is in the dock and does the following:

Putting it all Together

Each component listed above serves a purpose. It may seem like the entire system was “guessed” together but that is not so. I iterated through several mobile devices, head units, connections, and work flows before I finally arrived at an optimum solution. Here is how everything works:

I have a large collection of music already off-lined to my phone in case I do not have a mobile internet connection. When I am bored or would like to find new music, I browse for playlists through Spotify on my phone or desktop and subscribe. While entering my vehicle, I place the phone into car dock. Bluetooth automatically starts and opens Spotify. I start the ignition. About 5 to 10 seconds later the headunit connects via Bluetooth. I pull up the play queue and press play to have uninterrupted music for the ride.

Conclusion

I doubt anyone would re-implement what I have laid out above. In fact, the technology in this post may already be irrelevant. Hopefully there are some insightful takeaways if you are looking to build your own flawless system. I will be detailing more of these systems in the future.