Sunday, December 4, 2011

CP2102 USB to rs232 for Arduino Clone

CP2102 driving a Modern Device BBB board

I saw a Chinese USB to rs232 adapter based on the CP2102 chip on eBay for $5.95 with free shipping and thought to myself - "At this price how can I go wrong" (they have since gone on sale for $2.95)

The Problem is I have 3 Modern Device BBB Arduino clones, an Adafruit DC Boarduino and three Evil Mad Scientist Diavolinos but only one USB FTDI TTL-232 cable.  Oh Yea - I do have one official Arduino - albeit an older one. :-) I have been meaning to get another cable - but when I can get another Diavolino for less money it has stopped me every time.  There are other USB RS232 boards - Modern Device has one - so does Spark fun - but there are only a few dollars cheaper than the FTDI Cable.

So I took the plunge and ordered a couple of the CP2102 boards - then promptly forgot I did it.  I was pleasantly surprised this week when a box arrived - it only took 2 weeks, less than normal in my experience.

I downloaded the driver and installed it on three of my computers without problem.  Then I tried hooking it up to an Arduino - it took a bit of head scratching but it finally worked, once I figured out how it should be wired. I thought I would share with you how to do it.

The Board has a 5 pin connector with RST, 3v3, 5V, TXD, RXD, and GND. There is a series of holes along the side that says DTR, DSR, RTS, and CTS.  The Arduino software uses DTR to reset the chip and start the bootloader when uploading a sketch.  I soldered a 4 pin header into the holes and put on on the pins with the included cable on the DTR and tried an upload - I got the out of sync message, and put on my thinking cap - I tried burning the bootloader for the version of Arduino I was using - then tried again, no luck - then I changed the properties used as default for the CP2102 by setting the flow control to hardware in the drivers properties screen. I figured that the Arduino software would reset these values anyway during the sketch uploading,  but what the heck. Still no luck.  I switched the TX and RX pins on one of the boards, and voila - the sketch uploaded. 

The one downside of the adapter board is that the included jumper wires are too short.  I was going to make a long cable out of a piece of cat5 cable , but then remembered I saw a USB extension cable at the local Dollar General store - and got two (how much did they cost - everything is a dollar :-).

So now I can get the adapter up to the bench and am happily burning sketches for a total of 6.95 each cable.

So this is how it is connected. I included the colors of the jumpers I used - and the colors used for the same connection using the FTDI cable.

BBB                    FTDI cable colors          Jumper colors        CP2102
1)GND --------black---------black---- gnd
2)            brown                   n/c
3)+5  --------red-----------white---- 5v
4)TX  --------orange--------purple--- RXD
5)RX  --------yellow--------grey----- TXD
6)    --------green---------blue----- DTR

Pins all hooked up

NOTE on setting driver properties....
When the driver installs it show up as COM11 on my shops XP computer. Looking at the properties the driver installs by clicking on Start,  then right clicking on My computer, and selecting properties. Then on the Hardware tab I click on Device manager (almost there) and select ports (COM and LPT).  Right clicking on the list item and selecting properties you get a screen with the default values - I always set flow control to hardware.

My default Properties for the CP2102