Giving The Nexus 4 A Serial Port

Having a serial port on any Linux box is always useful, but with the tiny computers we’re carrying around in our pockets now, that isn’t always an option. Some of the more advanced phones out there break out a UART on their USB OTG port, but the designers of the Nexus 4 decided to do things differently. They chose to put the Nexus 4’s serial port on the mic and headphone input, and [Ryan] and [Josh] figured out how to access this port.

Basically, the Nexus 4 has a tiny bit of circuitry attached to the microphone input. If the Nexus detects more than 2.8 Volts on the mic, it switches over to a hardware UART, allowing everything from an Arduino to an old dumb terminal to access the port.

The guys used a USB to serial FTDI board wired up to a 3.5 mm jack with a few resistors to enable the hardware UART on their phone. With a small enclosure, they had a reasonably inexpensive way to enable a hardware serial port on a mobile device with GPS, cellular, a camera, and a whole bunch of other sensors that any portable project would love.

EDIT: An anonymous little bird told us this: “You should add a note to the Nexus 4 serial cable post that TX and RX need to be 1.8V.  If you use 3.3V USB cables, you will likely eventually fry something.  FTDI makes 1.8V IO cables that work – you just need to make the trigger voltage for the mic line.” Take that for what you will.

28 thoughts on “Giving The Nexus 4 A Serial Port

      1. The code helped, as did some circuit tracing. We didn’t document the steps very well along the way so they’re omitted in the blog. We learned our lesson for next time though.

  1. I don’t understand why the 1K resistor on the MIC-IN line?

    And is the trigger voltage 2.8V or 3.08V? They state 2.8V in the summary but derive 3.08V in their calculations.

    1. The 1K resistor serves two purposes. The first is if you connect it to a device that shorts Vcc out to ground it prevents the FTDI chip from resetting. The second is if you plug it into the wrong device it makes it less likely that it will destroy the device. With the voltage calculation, 3.08V is the correct number.

    1. After reading this article and blog, I did a Google on Nexus 4 and a review complained about the screen and back plate (also glass) easily breaking, Your Mileage May Vary…

      1. I’ve had my Nexus 4 since early December and I haven’t had any problems with either the screen nor the back cover.

        There, you have two antidodal data points which mean nothing.

  2. I haven’t checked Nexus 4, but this is documented quite well in the Nexus 7 kernel code. No special circuitry there though – just standard SoC pinmuxing. Most of the time it’s pinmuxed to ‘nothing, and when it detects a special condition (if enabled), it pinmuxes the UART onto the pins and the audio off.

    1. My Samsung Galaxy can tell when the headphones are plugged in or not, when you unplug them it quits the FM radio. So there’s some smarts in there. It might just be detecting a signal from the headphones’ other purpose, an FM radio antenna, or maybe it’s quite a sophisticated jack socket.

      I wonder what you get from it? Boot debug data? A root shell?

  3. any body tested this?
    well,… i created the circuit and no luck,…
    my nexus restarted couple of times as soon as i plug the headphone jack , computer showed lot of clutter and finally nexus went in to continuous boot loop

    i had to re-flash factory image,.. lost every thing :(

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.