Using A Second (Software) Serial USB To Debug Your Arduino

For my upcoming project, I wanted to connect my Arduino to a computer and use the serial port, yet somehow debug the code. Obviously, if the serial port was in use, trying to fit in Print() statements would be a bit awkward – so I needed an alternative way to communicate.

For a while, I was wondering if connecting a second Arduino would be the key, or if I’d need a Mega (which has 4 serial ports). But after some research, I found out the Arduino can have more than one serial connection (USB) to a computer, if you used some sort of hardware convertor, and if you used a serial software library to manage the second terminal.

So, after asking around the Arduino forum, I found out that a USB to TTL serial convertor was the name of what I wanted. But there’s various flavors:

  • The Nokia CA-42 cable was popular and cheap, but suffered from timing issues according to one person, and some may (or may not) be incompatible with 5.0v.
  • Another choice was one with the PL2303 chip in it, but being the same chip as was used in the CA-42, it might or might not be a 3.3v version (note that apparently a 5v chip works fine with the 3.3v; it’s the 3.3v versions that can’t play safely with the bigger kids).
  • In the end, the CP2102 chips seemed to be the safest for voltage, so I ordered one off of eBay for under $5.

When it arrived, I took one look and thought “very small” – but despite that, it did the job admirably. Here’s how I got mine to work:

  • First off, I ignored the Arduino. I plugged in the device to a USB port all alone. Windows had no trouble finding a driver online for it, and hooked mine up straight away, connecting me to COM port 6 with my new device.
  • Then, I unplugged and wired up the device by connecting the TXD and RXD pins together. This created what is called a loopback, so whatever is sent out here was ‘looped back’ to the terminal sending it – useful for checking if things are working. Then, I plugged it back in.
  • Because I’m running Windows 7 64bit, I did not have Hyperterminal installed, and didn’t feel like getting it (according to an online search, my choices were: buy a copy, copy it from an XP install, or downloading the last free version – v6.3 – from what looked like some dodgy download sites). So, a little more research, and I found an open source one, Realterm, which was reviewed quite favorably for working with hardware devices.
  • Downloaded it, installed it (twice, as I had to uninstall and install again, since the ActiveX libraries in the install didn’t set up properly the first time around), ran it, and then looked it over. Out of the box it’s just about ready for Arduino work, except: 1) the setting ‘half duplex’ should be on (checkbox in the ‘Display’ tab), and 2) you need to select the port (the ‘Port’ tab – don’t forget to click on the ‘Change’ button after to save it!).

From there, you can do a basic test: as you type, everything is doubled up:

II  ssaaiidd,,  aass  yyoouu  ttyyppee,, eevveerryytthhiinngg  
iiss  ddoouubblleedd  uupp

That’s half duplex – echoing things back to you, and proof the device is receiving.

At this point, you know you’re talking to those two joined pins – now it’s time to talk to the Arduino…

SOME ITEMS YOU MIGHT ENJOY
700 Point Breadboard Protoboard SYB-120 for Arduino DIY experiment
$1.99 (1 Bid)
End Date: Monday Jul-28-2014 18:05:03 PDT
Bid now | Add to watch list
7in1 ProtoSnap Pro Mini ATMEGA328P_PU& TEMT6000 & FTDI Basic FT232RL For Arduino
$9.99 (1 Bid)
End Date: Monday Jul-28-2014 17:14:34 PDT
Bid now | Add to watch list
Arduino Nano Compatible V3.0 ATmega328P 5v - Free USB cable included - US Seller
$9.35
End Date: Sunday Aug-3-2014 13:05:41 PDT
Buy It Now for only: $9.35
Buy It Now | Add to watch list


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>