Connecting Bluetooth Serial

line.ctrl
4 min readNov 5, 2017

--

This is a post about the tiny Arduino-based text terminal emulator project. Please see the Hackaday project page for more background.

I wrapped up a chapter of display-related work and switched gears to trying to work out terminal connectivity to the host device.

The USB cable connection serves fine as a serial link for code uploads and basic debugging, but for the intended wearable form factor it just does not seem right to hook up a bulky cable. So I figured I’d rather sort out the wireless connectivity tech now than have to re-work my assumptions later.

Wireless, baby!

I decided to go with a simple Bluetooth serial connection. Linux-enabled host devices like Raspberry Pi support it reliably, and even for debugging it becomes convenient to have both USB FTDI and Bluetooth as upload options.

Retail Blues

Searching Adafruit and SparkFun turned up some good options for Bluetooth connectivity, but instead of waiting for online delivery I biked down to Creatron, my local robotics hobby store.

The friendly staff there suggested to use the HC-05 chip breakout (as would anyone with Arduino Bluetooth experience, in retrospect). But I did not do my homework and ended up picking something else at first: an HM-10 module. At that moment, using a low energy chip sounded more fitting for the wearable form factor, so I asked about BLE support and hence ended up with the HM-10.

Little did I know that that device does not appear as a normal serial pipe on the host (specifically because the protocol is BLE). When I tried to pair with it from my PC workstation, I saw a mysterious “HMSoft” device, not a COM5 that I expected.

Only then I looked deeper in the docs and found out that with the HM-10 module the host application is supposed to send and receive short burst data packets by accessing a special vendor-specific Bluetooth profile instead of standard serial port communication. By avoiding upkeep of a continuous data pipe the remote end consumes less energy.

For my use case this of course was not appropriate, since I need a real serial device to run a full terminal shell session. Oops.

HC-05 Serial Link

I came back to the store and got the HC-05 breakout module as the staff member had suggested originally. This chip is also cheaper, to boot (and nope, no refund on the HM-10).

I had to resolve some annoying device driver issues on Windows first, but the HC-05 was indeed a success: paired with my PC as a proper serial COM device and sent/received data with a real console session.

Terminal with HC-05 with an RX pin voltage divider

As always, there are interesting caveats.

My Arduino runs at 5V while the HC-05 chip itself is 3.3V. The breakout board is OK to plug into the 5V bus power directly because it has a built-in voltage regulator; however, the Bluetooth data pin levels are not shifted and still produce/accept 3.3V maximum. The output (TX) pin of the breakout can work without level-shifting, because 3.3V still gets picked up by Arduino as a “high” TTL signal, but the data input (RX) pin of the breakout needs a level shift.

Some HC-05 tutorials out there just feed 5V into the RX pin, and apparently the chip does survive despite that, but that just did not seem responsible. I set up a simple voltage divider for the RX pin and it seems to work fine.

Another issue was that the Bluetooth TX and RX interfered with sketch code uploads, since both FTDI and Bluetooth are wired directly to the Arduino hardware UART serial pins. This type of problem gave me trouble earlier this year when I was using the onboard Arduino UART to test a serial transmission link widget. Disconnecting the Bluetooth TX pin during the upload and then reconnecting it again helps work around this.

And, finally, the Windows device driver was not happy with the constant connection and disconnection and power-cycling of the HC-05 chip that I had to do as part of working on the terminal.

Here’s a bonus picture of the terminal emulator gadget running off a portable battery and connecting directly to my phone (wow, that breadboard is running out of space!):

Android BlueTerm connected to the tiny terminal emulator

Little stumbles like the ones I experienced while picking the right Bluetooth module are a good reminder to do research first. But they are also unavoidable: the experience and intuition for electronics and general “hardware culture” are not something that can be gotten just from reading online manuals. It is something that is earned one wrong purchase and wasted bike trip at a time.

Check out more details and pictures on the Hackaday project page!

--

--

line.ctrl

Nick Matantsev: independent web developer by day, building electronics/graphics/art projects in my spare time