Learn how to make an Android G1 2.8v serial to USB Serial device adapter (using a 3.3v ttl to usb serial adapter). This can be used for kernel debugging/etc with your computer. This project shouldn't cost you more than 40 bucks if you already have basic electronic tools such as a soldering iron.

Notice: The ability to use 3.3v ttl level serial is based off of google group discussions and a picture of a serial cable used by an alleged android dev. 2.8v level serial was determined via someone using a voltmeter. Build/use at your own risk and check the comments of this instructable too before beginning!

Information may be applied to build a 2.8v serial to RS232 converter to interact with RS232 devices, or a 2.8v serial to serial 5v level converter to interact with microcontroller such as an Arduino. I may post instructables on how to make these once I play around with the G1 kernel some more. :)

This tutorial assumes basic knowledge of soldering. If you don't have this skill you should find an instructable regarding it and practice a bit. The soldering required for this project isn't difficult, but needs to be done in a small amount of space which could be difficult for beginners.

This cable was created based off of information received from the Android-Platform Google Group.

... Specifically these two threads:

...This picture of a "mystical" g1 serial cable helped (and confused!) too:

Please leave constructive criticism/comments if you find any steps wrong, confusing... or poorly written!

Step 1: Items Needed

To build this converter you will need the following:

Step 2: Soldering the HTC ExtUSB Breakout Board Data Wires

= 1. Using the wire cutters, cut three lengths of wire that are each about 5 inches long. If you bought more than one color of wire, make one black wire and two of your custom color.
= 2. With the wire strippers, remove about 5mm of insulation from each end of the three cables.

Now, before continuing, go grab your HTC ExtUSB breakout board and take a close look at it. One side will have tiny numbers on it that reflect the following:

6 9 11 5
78 10 4
1 2 3

The bold holes are what we are interested in. Those three holes represent GND (Hole 7), TXO (Hole 8), and RXI (Hole 9), all of which are necessary for the G1's serial communications. In case you were wondering what the other pins were tied to, this is what PodGizmo.com currently has listed:

1: USB VCC +5v
2: USB Data -
3: USB Data +
4: N / C
6: Left Audio +
7: Labeled "AG" (Serial 2.8v Level GROUND)
8: Audio - (GND) Labeled "CK" (Serial 2.8v Level TX0)
9: Switch (Talk) Labeled "OT" (Serial 2.8v Level RX'I)
10: Right Audio +
11: Mic +
12: Chassis Ground (GND)

= 3. Plug in your soldering iron and let it warm up.
= 4. Grab a wire you cut earlier (the black one if you have multiple colors) and solder it through hole 7 (GND).
= 5. Grab another wire you cut earlier and solder it through hole 8 (TXO).
= 6. Grab the last wire you cut earlier and solder it through hole 9 (RXI).

After that it should look something like the picture below.

Step 3: Soldering the USB to TTL-Level Serial Adapter Data Wires

Now that the ExtUSB board is soldered, the next step is to solder those wires into the respective holes in the USB to 2.8v serial board. Before continuing, it would be a good idea to grab this board and look carefully to find the GND, RX, and TX holes.

= 1. Solder the GND wire (The one Soldered in Hole 7 of the HTC ExtUSB board) in the hole labeled GND on your USB to 2.8v Serial adapter.
= 2. Solder the TXO wire (The one Soldered in Hole 8 of the HTC ExtUSB board) in the hole labeled RX on your USB to 2.8v Serial adapter.
= 3. Solder the RXI wire (The one Soldered in Hole 9 of the HTC ExtUSB board) in the hole labeled TX on your USB to 2.8v Serial adapter.

Step 4: Verify the Data Wire Connections

= 1. If needed, install any drivers necessary for the USB to 2.8v serial adapter you used.
= 2. Download a serial console app for your computer. For OS X/Linux users, the command line minicom or screen are good choices. I will be using minicom under Ubuntu.
= 3. Plug in the converter you made into a USB port on your computer. Do NOT plug it into the phone yet.
= 4. Open up your serial console app and see if the device is detected. For me it shows up under /dev/ttyUSB0 and minicom picked it up automatically. You may need to configure your software.
= 5. With the serial port now recognized, now you need to change the baud rate/stop bits, and flow control. To change these in minicom, type Ctrl-a then type Shift-O (O as in Obama). A configurations dialogue will pop up. You should choose "serial port setup", hit enter then change the values to be the following:
  • Bps/Par/Bits: 115200 8N1
  • Hardware Flow Control: No
  • Software Flow Control: No

= 6. Close settings and wait for a connection now. You can exit settings in minicom by hitting the escape button.
= 7. Go grab your G1 Phone and make sure it has a good charge. Once it does, you should go to Settings->Sounds and Display->Screen Timeout and increase it to 10 Minutes or Never Timeout. From preliminary tests, It seems serial doesn't work with the display off.. but this has not been verified.
= 8. Plug the HTC ExtUSB connector into the phone.. if you smell anything funny or see sparks, quickly disconnect the connector from the phone then the USB cable and review the prior steps to see what you missed.

= 9. If all looks and smells ok, take a look at the serial console output, it should say "debug>" immediately. This reflects that you at least soldered the GND and RX wires correctly, woo!**
= 10. Try typing "ps" and hit enter, if you see ps appear and lots of text scrolls by when you hit enter, that means you cable works fine. Neat!**

**If you do not see the expected "debug>" text or you don't see what you type, hit enter a few times. Sometimes the communications can get garbled since no software/hardware flow control is used. If that doesn't work, you can try restarting your console app, verifying serial communication settings, unplug/plug in the phone, and finally double checking what you soldered.

= 11. Trim the excess wires off both boards.

Step 5: Soldering the USB to TTL-Level Serial Adapter Power Wire (optional)

Now that you know your cable works you can either use it as is, make it provide power to the G1, or make it work as a dual standard USB and USB serial device. The following explains how to supply power to the G1 provided your adapter has a 5v hole to solder to.

= 1. Take a look at your 2.8v level serial to USB adapter and look for a something labeled 5V. It may also be labeled VCC but if this is the case, check your adapters data sheet to verify it actually does supply 5V directly from the USB bus. It also probably wouldn't hurt to double check this using a voltmeter.

If you do not have this connection, you will not be able to complete the next few steps. If you run into this situation you might want to consider just soldering a USB cable to the proper HTC ExtUSB pins as this should allow you to both power the G1 and also have standard USB access to the G1

= 2. Using the wire cutters, cut a wire that is about 5 inches long. If you bought more than one color of wire, use the red wire.
= 3. With the wire strippers, remove about 5mm of insulation from each end of the cable.
= 4. Solder the wire through the 5V (or VCC) hole on your adapter.

Step 6: Soldering the HTC ExtUSB Breakout Board Power Wire (optional)

Take a look at the HTC ExtUSB breakout board again. We are interested in the USB VCC +5v hole which is bolded below.

6 9 11 5
7 8 10 4
1 2 3

1: USB VCC +5v
2: USB Data -
3: USB Data +
4: N / C
6: Left Audio +
7: Labeled "AG" (Serial 2.8v Level GROUND)
8: Audio - (GND) Labeled "CK" (Serial 2.8v Level TX)
9: Switch (Talk) Labeled "OT" (Serial 2.8v Level RX)
10: Right Audio +
11: Mic +
12: Chassis Ground (GND)

= 1. Solder the other end of the (red) wire you just soldered in hole 1 (USB VCC +5v).

Step 7: Verify the Power Wire Connection

= 1. Plug in the adapter into your computer. If it starts to smell funny or spark, quickly remove it and check what you soldered.
= 2. Grab your phone, power it on if it is off, then plug the adapter into it. After about a second or two, the amber charging light should turn and stay on.. if it doesn't, quickly disconnect it and double check your connections.

That's it, go hog wild!

Step 8: Now What?

So now that you know how to interact with the serial port on the G1, you probably have a bunch of ideas floating around your head for how to take advantage of it, right?

Wouldn't it be nice to use this to:
-Control a robot
-Use the G1 as a serial console to connect to servers in a beowulf cluster like System-X
-Communicate with sensors/activators over a 3g network for remote monitoring/control
-Use the serial port to attach a blood glucose reader or other medical device (psst, any big medical companies hiring?) and combine two devices into one for many people?

Here's a project that explains how to compile the G1 phone's kernel so you can use the serial port from the userland. It also features an api so you can use the serial port directly from Android Gui apps!


Don't forget to post your projects here when you're done!
I have a Droid Bionic - anyone want to build one of these for? (with instructions on how to install driver, etc)
Thanks for great instructable.<br>I tried that I connected G1 with Cisco console.<br><br>Android (T-Mobile G1) -&gt; Serisl Port API -&gt; TTL -&gt; RS232C -&gt; Cisco console<br><br>(my scene)<br>http://youtu.be/t4EuB8qhTvA
Hi all,<br><br>I've connected mine G1 to the PC via FTDI Basic Breakout (http://www.dfrobot.com/index.php?route=product/product&amp;path=45&amp;product_id=147) and managed to get full output from 'ps. However, it seem that G1 could not received my input from the keyboard most of the times.<br><br>I need to repeatly hit the keyboard to get the terminal emulator to echo it back!<br><br>Did anyone experienced it? Any tips will be helpful. Thanks<br>
Thanks very much for the tutorial! I would like to know whether I&nbsp;can use this from a program on my g1, say, if i were to develop a program that could say to a picchip &quot;SEND&nbsp;ME&quot; then it could write back the values of its inputs etc. then the program could do something with them. would I have to use NDK? or does the SDK have some kind of serial control command?<br />
&nbsp; Yep, this allows 2-way communication via the serial protocol with a pic/avr/arduino, etc. That's actually my main reason for making this cable.<br /><br />To do this you need to configure and rebuild the kernel to disable the serial debugger and htc handset detection drivers. Consequently after doing this, you probably won't be able to use your headset. This requires you to have a rooted phone too, preferably with the dev spi.<br /><br />There's no android application level serial communication sdk stuff yet.. (Porting rxtx to android is on a todo list of mine) so you will need to compile a c app (search google for agcc.pl to learn how to compile c apps for android) in order to either use as a middle man between android apps and your uC.. or just to configure the serial port initially to whatever baud rate, stop bits, etc you need then interface with /dev/ttyMSM2 directly
Hey not sure you still interested but I just ported the RXTX library ( gnu.io.rxtx) to the android. More details here http://v-lad.org/projects/gnu.io.android/
Hmm, Cepr could you send me/post the code your using so that I can have a stab at it, and macpoddotnet are your steps nessery because I have a routed device so shouldn't I just be able to talk to /dev/ttyMSM2 using just command line (I will try this soon) because at the moment I'm testing using my actual phone I use on a day to day basis but I will buy a dedicated one I can break things like headsets and it doesn't matter.<br />
Hi jamescorbett,&lt;br /&gt;&lt;br /&gt;I just created a Google Code project to host the code:&lt;br /&gt;http://code.google.com/p/android-serialport-api/&lt;br /&gt;&lt;br /&gt;I will complete the wiki with compilation instructions soon.&lt;br /&gt;<br/>
My application is now stable, I uploaded an apk in the download section.<br />SerialPort_0.7.apk features:<br />- detect all the serial ports of the phone (most are internal, do not use)<br />- select baudrate (4800, 9600, 115200)<br />- detect missing file permissions, and try to change it with &quot;su&quot; (does not work on all phones)<br />- terminal screen to receive and send text through the serial port<br />- &quot;loopback test&quot;: the phone sends infinite 0x55555..., and display the count of received and sent bytes. If you connect RX and TX, you should have the same value.<br /><br /><br />
Great work! When I get home I'll check it out then throw a link up in this instructable. <br /><br />Hmm, the NDK has me really excited now.. it has made some other things I have wanted to do way easier now.
&nbsp;If you are satisfied with the default baud rate you set in your kernel config before building it, you don't need to route applications through a c serial program.. or even make one to set the baud rate. <br /><br />All you have to do is get the right permissions and talk to /dev/ttyMSM2 just like you would with any other linux serial port.<br /><br />The NDK stuff wasn't around when I played with this, but this might even offer a better solution provided you have privileges. If you can include serial libs, you could control the baud rate directly from an app which would be awesome. This would be really useful for porting the rx/tx java libs too... hmm<br /><br /><br />The config entries that should be disabled have changed since I first did this, but currently these should be it:<br />CONFIG_HTC_HEADSET<br />CONFIG_MSM_SERIAL_DEBUGGER<br />CONFIG_MSM_SERIAL_DEBUGGER_CONSOLE<br /><br /><br />... possibly this too:<br />CONFIG_MSM_FIQ_SUPPORT<br />
Thank you!<br />I have now ttyMSM2 :D<br />(it works also with CONFIG_MSM_FIQ_SUPPORT=y)<br />
I made an Android program to read/write to a Linux serial port.<br />It uses the SDK and a little the NDK.<br />Anyway, you need a rooted device because the /dev/tty* do not have the read/write permissions for Android applications.<br /><br />
For the newer generations of android electronics (phones and tablets) They come with USB host already built in&gt; Could i use the same programing cable for my arduino to connect to an android tablet? If i did, what app would i need to accomplish a serial port to the arduino? <br><br>Chow.
Thanks heaps for this instructable. After heaps of mucking around I managed to get the HTC Magic working with it using the stock headset (I cut it up).<br /> <br /> Few pointers for those interested:<br /> Headset cable already has the USB GND pin connected to what becomes the TX pin... obviously this won't work so I just hacked out all the normal usb pins (which solved the issue).<br /> <br /> I've recompiled the 2.6.29-donut kernel and confirmed this works.<br /> <br /> One issue though... when I use a custom kernel I cannot use it in normal USB mode :-(. Is this normal? Should you be able to use normal USB and this special serial mode at the same time?<br />
I have now confirmed that Pin 4 is the data high pin and I have achieved 2 way communication. <br /> <br /> http://garr.me/?p=315<br /> <br /> Instructable coming soon. <br />
Hey great work although I have noticed one thing that could be wrong.<br /> <br /> Pin 4 is actually 2.8v or Data High which is required for some 2 way logic level converters.<br /> <br /> Be warned, I haven't checked if it changes during data transmission. I will post my results when I get up to that stage.<br />
&nbsp;Would this work?<br /> <a href="http://www.ecrater.com/product.php?pid=1750401" rel="nofollow">www.ecrater.com/product.php</a><br />
The best way for me to see the phone sending commands to the PC was to type the following:<br /> <br /> $ su<br /> # echo 'hello' &gt; /dev/ttyMSM2<br /> <br /> It is also helpful to type 'ash' in so that you can recall commands:<br /> <br /> $ su<br /> # ash<br /> / # echo 'hello' &gt; /dev/ttyMSM2<br /> <br /> Then you can use ALT+trackball-up to recall previous commands.<br />
Dude,<br /> <br /> &nbsp; how to dump the data on PC side ? tks<br />
&nbsp;I had PuTTY open as a serial client on the PC. Other serial apps should work too but I've had issue with the built-in Hyperterminal so I prefer PuTTY.
thanks dude!!! any tip for linux (ubuntu) env ?<br />
minicom or <br /> screen /dev/ttyUSB0 (or whatever)<br />
Tried to upload but it won't work for me. What does 'Drag to Recorder' mean?
<div>Hi I am looking for some help with a USB to&nbsp;Serial device I bought from Maplin&nbsp;that I&nbsp;slightly damaged when breaking apart the sealed casing. I have damaged 2 resistors (I believe) and completely lost one.<br /> Can any of you clever bods suggest a fix for me please? I have lots of spare components but no clue as to what they should be.<br /> I have included some Pictures.<br /> Thanks alot.<br /> Sparkyuiop!</div>
Thanks for the great Guide.&nbsp;<br /> For those of us in the UK this seems to be the same board as the one used in the Guide&nbsp;<br /> <a href="http://www.coolcomponents.co.uk/catalog/product_info.php?products_id=100" rel="nofollow">www.coolcomponents.co.uk/catalog/product_info.php<br /> </a>:-)<br /> <br />
Has anyone been able to read incoming serial data on the G1?<br /> <br /> I've tried using &quot;cat /dev/ttyMSM2&quot; and it just hangs, as does doing file reads of that using Python from the Android Scripting Environment.<br />
Step 5 mentions 115200bps but that wasn't working for the Sparkfun CP2102 device. I used 9600bps and it then worked like a charm.<br />
I just found out accidentally that a normal miniUSB connector works just fine with the extUSB port on the G1 for normal data transfer from PC as well as charging from PC. Does this open up any new possibilities? As for me, I would like to have some way to have consistent serial I/O between the G1 and an arduino. At least, one way to output accelerometer/Gps/compass data from G1 to the arduino itself would be a great thing.
No, it doesn't. ExtUSB = extended USB, so the only thing using a miniUSB connector will do is restrict what pins are made acessible on the phone.&lt;br /&gt;&lt;br /&gt;<br/>
Hmm.. ok I&nbsp;did frequently corrupt my microSD card while trying to add files via the miniUSB cable. <br />
Using a miniUSB cable as opposed to an ExtUSB cable does not increase your risk of corrupt files. I'm guessing you are forgetting to eject the the volume before pulling the cable. If you don't do this, especially under an awful OS&nbsp;like Windows, your files will become corrupted.
Hey I&nbsp;know I&nbsp;have to &quot;Safely remove&quot; it. :)&nbsp;.. And I like windows :) .. Samething would happen on *nix if you didn't &quot;Eject&quot; the drive and maybe some buffer wasn't flushed. <br /><br />Anyway, its like, when I&nbsp;used the miniUSB, the &quot;USB cable connected notification kept coming on and off. Sometimes it kept getting disconnected after I had mounted the card and all. I&nbsp;guess it must have been something wrong with the cable. <br />
If you use a USB cable that has a ferrite RF choke on it you shouldn't have problems.<br /> <br /> I think electrical interference could be at fault for the data corruption and the cable disconnect/connect notification toggling.<br />
Thank you for this instructable and the api.&nbsp; Following these instructions I cut up the the headset that came with my g1 and connected it a usb-&gt;ttl and it seems to be half working.&nbsp; I made a modified cyanogen kernel and installed the SerialPort.apk but when I run the app I receive data on the g1 nothing seems to be going out.&nbsp; I wonder if you have come across this.&nbsp; I have noticed that the little headset icon is always present whereas before I disabled it in the kernel it only appeared when something was plugged into the usb port.&nbsp; Could this be related? <br />
The first time around I had installed the kernel from the google code page but it had the headset detection enabled in the config and I wasn't getting any serial communication.&nbsp; I used the instructions on the site for compiling the kernel and that gave me the serial reception.&nbsp; The wiring seems to be solid.&nbsp; I am wondering if headset vs serial state is somehow persistent?&nbsp; I'll try installing your kernel again later.&nbsp; Thanks for the responses.<br />
&nbsp;No, it shouldn't be persistent. I am also 100% confident that the two kernels I uploaded sofar let you do serial communications with cyanogenMod 4.1.999 because they were tested and confirmed to work by myself and two others. The firsk kernel did have the camera functionality related problem however.. That is why the second one was uploaded (and tested).<br /> <br /> Have you tried outputting /dev/urandom to /dev/ttyMSM2 then attaching a buzzer between the G1's TX0 and ground?<br /> <br /> Oh yea, cepr's comment earlier holds a good point. Headsets short a pin to ground on the g1 to allow the phone to identify that they are attached. If that pin happened to be the TX0 pin, that could cause problems. Off the top of my head I am not sure that it is though... I think grounding the audio ground to the chassis ground does the trick.&nbsp;<br />
Hi again.&nbsp; I tried your kernel again as well the two in the cyanogen repo to no avail.&nbsp; The cm kernels with the headset detection disabled allowed me to receive serial but nothing went out.&nbsp; I think that connector is grounding a pin and I destroyed it looking for it.&nbsp; Does the headset detection matter?&nbsp; If I get one of those little connectors they have on sparfun I should be fine with your kernel right?&nbsp; Thanks again.<br />
A recent cyanogen kernel commit which contained some code that messed with the camera and possibly more might be the culprit. At the very least I&nbsp;know it constantly displayed the headset icon. That code has since been pulled from the repo.<br /> <br /> I&nbsp;built and tested a new kernel for cyanogen mod which you can grab from the downloads section of the&nbsp;google&nbsp;code serial&nbsp;api website. Try that!<br /> &nbsp;<br /> I&nbsp;definitly think you need to install the new kernel, but I&nbsp;also think you have a second problem, and that is likely wiring (double check that everything is connected fine)
I did not have such issue. I have no headset icon, maybe your problem is linked. I am not sure, but when using a headset, the TX pin is set up as GPIO to gnd.<br />
Is software required to output the GPS / Accelerometer / Other sensor data, or can it be "pulled" from the phone using commands? I'd love to use my G1 as a sensor device interfacing with a PIC but I have no idea how to output all that useful data over the serial port. Any info would be appreciated, thanks.
You will need to write some software for android. Think of the phone as a tiny linux box with a serial port. <br />
&nbsp;Hi,<br />I dreamed of this serial port on the G1, so I am really happy finding this tutorial !<br />I am not really interrested by kernel debugging, but I would like to communicate with a microcontroller.<br />I have just finished a sort of hyperterminal for Android just to read and write some bytes to<br />the serial port, and it works on the emulator by connecting to /dev/ttyS2.<br />Nevertheless, on my HTC Magic (same hardware than the G1), I do not see any activity on this serial port.<br />I think my kernel must be misconfigured.<br />Did anybody already tried it ?<br />
Thanks macpoddotnet, I just read your post below :)<br />I will try to recompile a kernel without kernel debugging, and use ttyMSM2 (when I tryied ttyMSM0, it just crashed my phone ;))<br />
Funny I should be posting this from my g1 Could this not be made much simpler and cheaper by just using a mini usb jack and a max232 or similar chip? I never realised how simple and powerful that port on the bottom of the g1 was though. Gives me a few ideas of my own, thanks.
The CMOS-TTL Level serial pins on the G1 are located on the extended pins offered by the HTC ExtUSB connector. For this reason a mini usb jack will not work. <br/><br/>If you have a serial port on your computer or a usb to serial adapter already, you might be able to cut some costs by buying something like this (http://www.sparkfun.com/commerce/product_info.php?products_id=449) but then you will need to build a ~2.8 voltage regulator to feed the VCC port ~2.8v. That will probably cost you 20 bux so you wouldn't save much.. if anything really.<br/>
Our company is working on a project and we need help making a slightly exotic patch cable for HTC G1. Please contact johnm@rga.com for more information.
"...but then you will need to build a ~2.8 voltage regulator to feed the VCC port ~2.8v. That will probably cost you 20 bux so you wouldn't save much.. if anything really." I'm not sure why you say that a 2.8v regulator costs $20, a little variable voltage regulator and a couple of resistors will cost you less than $2... -Taylor
I don't mean the regulator alone will cost 20$, I mean the combined max232 board I pointed out (13.95$), and voltage regulator components (3$). I was also accounting for shipping. :)

About This Instructable




More by macpoddotnet:Android G1 Serial to USB Cable 
Add instructable to: