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:

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 />
here i do not&nbsp;post my comment <br /> <a href="http://www.ledtv.asia" rel="nofollow">led display</a>
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

About This Instructable


33 favorites


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