Simple Serial Console Connection

Modified on 2018/04/05 17:12 by CaptainBoing — Categorized as: Uncategorized

It is common to build projects with the serial ports of PICs and especially the console port of MicroMites (other micro-controllers are available) with a USB <-> serial adapter in order to connect it to a PC. Cheap devices like the CH340G and others make this a real possibility with just a USB cable between the two. The USB device in the project presents as a serial device on the PC and you simply connect with your favourite terminal emulator and communicate.

The need to have a USB <-> Serial adapter in every project though, is an un-necessary expense let alone the masses of COMxx ports on your laptop created by connecting to different projects.

So rather than deploying a serial device in every project, lately I have turned this approach around and moved the device to the PC side of things. I have many devices that present their console and output debugging information but for the majority of the time otherwise, do absolutely nothing with their console ports. I have a product that uses radio controlled modules - potentially hundreds of them and each needs a console connection for initial setup - I really don't want the expense and possible complication of a USB <-> Serial device in each one and connecting dozens of USB devices over and over is asking for problems on the PC; USB connections are rather temperamental about being dis/connected repeatedly. By using the simple serial outputs as the connection point, all you risk is the odd garbage character - not a confused driver and potentially a reboot. Yet another downside is that USB connectors tend to be large, difficult to machine the opening for and aren't really very robust. These points together have lead me to a simple alternative that I think reaps benefits all round.

I have made up an adapter with a (CH340G) serial device at the PC end (inside the big USB plug) and the serial pins go to a 3.5mm jack plug. This means I can use the same adapter on many different devices and the only thing required at the micro-controller end is a 3.5mm stereo jack socket with its simple hole drilled in the enclosure. This gives a cheap solution, only a single COMxx port on the service laptops and the 3.5mm Jack is arguably a much tougher connector than any USB design. Another plus-point is that with a USB Bus-Master connector, this USB cable will plug into your android or iPhone and with a suitable App, service engineers can talk to the devices with their smartphones. Customers are amazed to see me plug my phone into their kit and set it up or retrieve debug info.

Image

Below, I have used the American notation of Tip, Ring and Ground (which ties in nicely Tx, Rx, Gnd) and to clarify I have also equated these with MISO/MOSI notation to clarify the direction of each without ambiguity. This setup has no problem with 38.4KBaud, I have not tried it higher as I have never needed it but I can't imagine too many problems.

Image



Once you have eliminated the USB aspect from the project end, a whole raft of console connection options open up:

Here we see various modules:
1. Radio Serial Sender Unit - A serial to 433MHz converter to allow for remote terminal access - this one is operated from 2xAA cells in a 4xAA cell holder with integral on/off switch. It allows easy access to a hard to reach project and it's miserly on the power consumption. A small step up module steps 3.5V (2x fully charged AA cells) to 5V. this will drift downwards over time but still gives a healthy VCC for the HC-12 right down to a combined 2.6V from the cells. Working at a standardized 9600baud it gives about 20m through 6 brick walls and over a day continuous use.
2. Radio Serial USB Unit - A combined CH340G and HC-12 module to provide a USB access point for the 433MHz radio link - this is the PC (or phone) end.
3. An 'On The Go' (OTG) USB bus master cable that plugs into the USB connector on your smart phone. This then allows you to plug the USB module (2) into the master end and talk to your 433MHz console link from your phone or tablet.

This is mega-useful when communicating with a device in a hidden ceiling or awkward cupboard. Just reach in, simple connection then return to a position of comfort to do the actual work... I wish I'd had had this 30 years ago!

Image



This image shows the Radio Serial Sender Unit connected to the 3.5mm console socket of a project and a mobile phone using the Radio Serial USB Unit through an OTG USB Bus master cable shows the console (with logging information) of the project.

Image

The USB Terminal App for android used above recognizes the common and ubiquitous CH340G, FT231/2, CP210x and PL2303 devices natively. You might have to hunt around for a compatible Apple App.


Please note, the serial communication on the Radio devices is not encrypted in any way - with a little effort, e.g. another HC-12, it is entirely "snoop-able".