Step 6: Connect a 3.3v to 5v Level Shifter to the Arduino

The Arduino used in the this tutorial is a 5v model so we need to convert the 3.3v signal coming out of the G1 using a level shifter. It should be possible to connect directly to a 3.3v Arduino but that was not something I tested.

There are several ways to approach this but we'll use a 74LS04 chip in this example. You can search for one here and they are likely under $1. Tim and I picked ours up from the Hacker Dojo in Mountain View, CA but these are VERY common and should be plentiful wherever chips are sold or donated.

At a high level we're simply going to send the TX signal from the HTS USB breakout board into pin 1 of the 74LS04 chip. To make it work we go through the chip twice and come out pin 4 to the RX pin on the Freeduino SB (your serial pin may be different if you have another Arduino board but all should support this).

Follow these steps to wire up the level shifter and connect the HTC USB board (do not plug it into the phone yet and unplug power to the Arduino):

1. Insert the 74LS04 chip onto your breadboard. Make sure the chip hurdles the center break so the pins aren't shorted (a dumb move I made at first)
2. Soldier two wires to the HTC USB board as described in this instructable, but we'll only be using pins 7 (Ground) and 8 (TX0) since we're only doing one-way transmission for this tutorial.
3. Connect the other end of the ground (pin 7) wire to a ground on your breadboard (which should be connected to a ground on your Arduino)
4. Connect the other end of the TX0 (pin 8) wire to the breadboard where it runs into pin 1 of the 74LS04 chip. (do an image search for a full diagram of the chip)
5. Use a wire to connect pin 2 and 3 of the chip
6. Connect pin 4 of the chip to the Arduino RX point (pin 0 on the Freeduino SB and Arduino Duemilanove)
7. Connect pin 7 (GND) on the chip to the ground for your breadboard (which also connects to the Arduino ground)
8. Connect pin 14 (VCC) to the 5v power on your breadboard (which gets the power from the Arduino 5v output)

You should now be ready to plug in the HTC USB break-out board into the bottom of the phone and power on the Arduino. Check for sparks and smells and touch things to make sure they are cool.

Note: The current cellbot code turns on LED #13 when the servo motors of the robot should be running. If you don't have a robot yet you can check to see that the LED turns on and off to confirm it is working.

<p>hi great work , i need to controll my Microconroller Atmega8 with Serial communication in android any API or Links please ?</p>
<p>i am using cyanogenmod11 ported to chinese phone. i only see ttyMSM0 when i grep /dev/. will ttyMSM0 works too?</p>
Can't seem to get &quot;chmod 777 /dev/ttyMSM2&quot; to work. <br>Keep getting &quot;Operation not permitted&quot;. <br> <br>I am rooted and running Cyanogenmod 6.1.0 on my G1. <br> <br>Would love to get this working for a personal project.
<p>I know this is way old, but in case people follow the same steps and end up with what vince086 had, simply enter super user by typing </p><p>&quot;su&quot;</p><p>This will allow access to enter the command &quot;chmod 777 /dev/ttyMSM2&quot;</p>
Hey, so I'll be trying this out soon, but wanted to let you and others know about other, cheaper and possibly useful options for the extUSB breakout board. I picked up three of these headphone charger combos hoping they'd be all pinned out, and they certainly are! (http://www.amazon.com/HTC-Multifunction-Adapter-T-Mobile-Shadow/dp/B001QD3MQE) I do enjoy sparkfun's products but it seemed the breakout board just had a bit of too much breakability for my clumsy fingers. a simple squeeze with some channel locks opened up the top and gave access to the inner workings.
Sorry, forgot pic
can i do this with another android phone running cygenmod 10 and i a micro usb slot
I want to try this but don't have much ideas on coding for this kind. anybody can help me out? I am new so just little help would be great.
Ok.. Cellbot.py is running on HTC Thunderbolt.. BUT it freezes phone when telnet connection made from computer. Any ideas?
Awesome ! :D <br>I'll try it with my Samsung Galaxy Mini. Many thanks !
Hello, <br> I am trying to use an HTC Thunderbolt with my Arduino project. I have rooted the phone, I have cellbot.py running on the phone. But when I try to send a command to the Arduino, the phone freezes up. The command is never relayed to the Arduino. Any suggestions on how to cure this. I read in another blog that multithreading the python program will help. Not sure if that is true. I am not that familiar with Python. I am trying to learn multithreading on python now. Am I wasting my time? <br>Much thanks in advanced.
Hi??? this project can use android experia 10 mini pro???
it looks nice sir,,we would like to implement this project...from wher we can get the components for this project?
Do you have to have the arduino at all? <br>Could you not just have the phone do all the processing (after all, they do have pretty good processors) and have the micro-controller just relay the commands to the motors etc,
my android phone doesn't have serial port. Can i use a usb to srial converter to <br>connect it to the arduino... please reply
No android phone has a direct serial port, heck, I don't think you can buy a proper computer with a serial port anymore.<br>What some android phones do have is the usb port used for connection to a computer, can be used the other way by the phone. This means that you take a special plug (the HTC usb break-out board) that lets your phone talk to a micro-controller.<br><br>So google your phone and see it if has a &quot;proper&quot; usb port. Mine doesn't, and I think they are quite rare, but you may be lucky.<br><br>(I think, someone correct me if I'm wrong)
i have a samsung galaxy y s5360. how to connect this phone serially to robot. is it hrough usb data cable.. i desprately want to this project.. please provide with a solution.<br>
This is brilliant, I plan to do a similar thing though have it controlled via the left and right channels of the headphone jack. It's not an original idea, though it's certainly an easy way out.
I have HTC Wildfire Android mobile.<br><br>Is it possible to built with this phone?<br><br>A. S. Bhasker Raj<br>Secunderabad<br>India<br>Mobile: +919247332574
i don't see /dev/ttyMSM2 on my phone. It is rooted though. what can I do?
how did you connect android to arduino ? using serial ttl ?<br>does android has a serial ttl port ?<br><br>sorry, because i only have symbian s60 5th
great work!
Nice Project! i think i will build this!<br><br>But just got a question before i build that<br><br>1) i just have a look on the datasheet of 74ls74, isnt that the 74ls04 have a output level of 3.3v but not 5v???So are we converting 3.3v(from phone) to 3.3v(to aridno) agian using the 74ls04?<br><br>2) And will G3 and upper version not works with that? since they are using the standard usb again and separate the audio(tx) + Switch(rx) pin to an 3.5mm jack ?<br><br>Thank You
Beginning of 2011 inopiaaardbei made a solution called: &quot;Microbridge&quot; using the Arduino USB host bridge and wrote the software to use the Android Debug Bridge to communicate from and to the Arduino.<br><br>See more here - http://wp.me/pCAFq-h5. Links to his google code solution are in the post.<br><br>A direct link to the google code repository is here: http://code.google.com/p/microbridge/
is it possible with HTC Wildfire. Wildfire has another USB break-out.. Can you please help me about this.,
hey, can i run my camera app that i have built using the ecclipse , the same time when this appp on python is running....illl be glad if some body helps me on this
For the newer generations of android electronics (phones and tablets) including the Droid. 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.
it not goes nothing?
One of my last projects was a 4x4 differential drone, built from scratch, remotely controlled via Bluetooth using an Android smartphone.<br>Schematics / demo video here: http://www.pocketmagic.net/?p=1398<br>Besides ultrasonic sensors, the robot is about to be equipped with a homemade geiger counter sensor to detect &quot;exotic&quot; environment parameters <br>like the dangerous ionizing radiation. There are quite a few possibilities since the robot has an ATmega microcontroller that can easily <br>support additional sensors. <br>The data is sent back to the Android device, via bluetooth.
Can I buy a kit?
You can also choose the latest<strong> Super D 1.10.2</strong> as well while older version 1.9.3 does not support the feature.<br />
COOL!I wanna try it!&nbsp;
is it necessary for the phone on the bot to have service turned on??<br /> <br /> are there ways to control the bot through satellite instead of using cellphone service. that way you wouldn't be dependent on a service.<br /> <br /> Is there any way to bypass the use of cell phone towers all together???<br />
&nbsp;We typically test with phones that have no SIM card and use wi-fi for local communications.
what if you wanted the bot to travel across several states?<br /> <br /> and i've been looking into flying bots, it's been hard to find anything here on instructables.<br /> <br /> how hard is it to send live video and sound feed from the bot to your PC??<br /> <br /> i'm trying to gather info for a different project i'm working on??<br />
&nbsp;We just added XMPP support so as long as the phone has a data connection (any kind will do), you can command it from anywhere.<br /> <br /> Feel free to start a thread here with ideas: http://groups.google.com/group/cellbots<br />
Thanks for this nice Tutorial - I can confirm that the latest kernels of Cyanogen have Serial enabled. (I'm personally using a HTC Magic - not a G1)<br /> <br /> I did a bit of research as well and found out that Arduino sees 3,3V from the Phone as valid &quot;high&quot; state, so you would not need the <a href="http://www.google.com/products?q=74ls04" rel="nofollow">74LS04</a> in between for sending the data to the arduino.<br /> This is of course different in the other direction - there you have to reduce from 5V to 3,3V :) <br /> <br /> Cheers<br />
Great find captFuture. I'll update the instructable to reflect that. Still trying to get two-way working but the issue isn't hardware so much as making an incoming serial socket using Python when pySerial isn't in ASE.<br />
&nbsp;Maybe it would be an option to do it in java - some guys are developing a serialport API for the SDK.<br /> <br /> <a href="http://code.google.com/p/android-serialport-api/" rel="nofollow">code.google.com/p/android-serialport-api/<br /> <br /> <br /> </a><br />
&nbsp;but you need the serialport dll..... can you send me?? i can't compile it!!! (rice103@gmail.com)
&nbsp;You'll have to reach out to the Android Serialport API project team for the code they are using. My work has been using Python on Android via the Android Sripting Environment.
Good to see someone else looking at this... I'm planning on interfacing to an AVR soon for a couple of projects soon (one is a universal IR remote - sending serial commands to the AVR which flashes an IR&nbsp;LED... the other involves the USB host support on the AT90USB1287.. but that ones a secret ^_^)<br />
&nbsp;That is pretty awesome.... perhaps programming on the android to the arduino is on the horizon?
&nbsp;That could certainly be possible. If not programming on the phone it would certainly be nice to send new programs remotely to it instead of plugging it in each time.<br /> <br /> Glad you like the tutorial and hope you make something cool with it.<br />

About This Instructable




Bio: Husband and father of two. Product Manager at Google.
More by mranalytical:Android G1 Serial To Arduino Robot 
Add instructable to: