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…

[Sintron] Arduino Uno R3 Board Starter Kit with LCD Servo Motor Sensor Module...
End Date: Tuesday Dec-29-2015 15:44:44 PST
Buy It Now for only: $48.50
Buy It Now | Add to watch list
ATmega328P CH340G Board Compatible with Arduino UNO R3 Board
End Date: Sunday Dec-27-2015 2:40:58 PST
Buy It Now for only: $3.00
Buy It Now | Add to watch list
Blue LCD1602 16x2 Characters Display Module Compatible Geeetech Arduino UNO R3
$1.55 (3 Bids)
End Date: Sunday Nov-29-2015 18:10:12 PST
Bid now | Add to watch list

Leave a Reply

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