Update: It’s possible to build this project with the cheaper and more readily available HC-06 3.3V Bluetooth Serial Slave module, which is a drop-in replacement for the Virtuabotix BT2S module used below. The HC-06 is available from a variety of sources, including Amazon and eBay. However, a few component substitutions are required:
- U1, the 78L05 5V voltage regulator, should be replaced with a 78L33 3.3V voltage regulator (Mouser part number 511-L78L33ACZ)
- U2, the MAX232 level-converter chip, should be replaced with a MAX3232 3.3V level converter (Mouser part number 700-MAX3232CPE)
- C3-C6, the 1.0 uF electrolytic capacitors, should be replaced with 0.1 uF polarized or non-polarized capacitors (the type isn’t critical–you can use the same part used for C2, Mouser part number 594-K104K15X7RF5TH5)
No other changes to the circuit need to be made. These substituted parts are drop-in replacements, meaning the circuit board will work unmodified.
I recently acquired a couple of new toys (an Elecraft KX3 ham radio transceiver and a Celestron NexStar 6SE astronomical telescope). Both have serial interfaces for computer control. I wanted to interface them to my Google Nexus 7 tablet, though, using bluetooth. There are a number of bluetooth-serial converters on the market, but most are either expensive or require an external power connection. I wanted something that was self-contained, battery and everything. So, I built one for myself, using the Virtuabotix BT2S Bluetooth to Serial Slave module as the basis.
For this project, I breadboarded the circuit and tested it, and then I laid out a PC board that would fit in an enclosure that I selected, so the finished product would be nicely packaged. The PC board is now available from FAR Circuits (price as of this writing is $4.50 plus shipping–ask for the Ek RS 232 Interface Board). The enclosure is a Pactec HML-9VB and includes a 9V battery compartment and a drillable front panel, available from a variety of sources (the part number for purchase from Mouser Electronics is listed below).
This interface will pair with a PC or an Android device, but not with any iPad or iPhone products–Apple has locked down those platforms so only approved devices can be connected.
The schematic for the interface is shown below.
The BT2S uses TTL-level signals for input and output, so those need to be converted to RS-232 levels using a MAX232 level converter chip. Both the BT2S and MAX232 need a 5VDC source, and that’s provided by U1, a 78L05 voltage regulator. C1 and C2 provide filtering for the voltage regulator. D1 and R1 make up a power-on LED indicator (omit both parts if you don’t want an LED to light when you turn on the circuit). D2 provides polarity protection, protecting the circuit if you accidentally hook up the power supply backwards. J1 is the connection to the BT2S module, and J2 is a stereo audio jack that is the connection to the serial line going to the device being interfaced. J3 is the 9-12V DC input to the circuit, and J4 is a connector that allows you to connect the circuit directly to a PC serial port (through a USB-to-serial converter, if needed) so that the BT2S can be programmed (set the baud rate, ID, etc).
I put together a parts list for all the necessary components except for the board (see above) and the BT2S (which you can order direct from Virtuabotix–price as of this writing is $17.95). Part numbers are for Mouser Electronics, but most of these parts can be sourced from a number of different places, or you may have some of them in your junk box. Prices are as of this writing–they will likely change over time. I saved the parts list as a Mouser Project, so you can access it directly rather than having to track everything down for yourself.
|ID||Mouser Part Number||Description||QTY|
|C1||667-ECE-A1HKS100||10uF 50V electrolytic capacitor||1|
|C2||594-K104K15X7RF5TH5||0.1uF monolithic capacitor||1|
|C3-C6||647-UMP1H010MDD||1.0uF 50V electrolytic capacitor||4|
|R1||291-4.7K-RC||4.7 KOhm resistor (1/4 W)||1|
|U1||512-LM78L05ACZ||78L05 voltage regulator||1|
|U2||595-MAX232IN||MAX232 TTL-RS232 level converter||1|
|J1, J4||649-68001-436HLF||0.1″ straight header pins||1|
|J1, J4||649-68016-436HLF||0.1″ right-angle header pins||1|
|J2||806-STX-3100-3C||3.5mm PCB-mount stereo audio jack||1|
|for J2||523-G17S0910110EU||DB9 male serial connector||1|
|for J2||523-17E-1724-2||DB9 housing||1|
|for J2||568-NYS231BG-U||stereo audio connector||1|
|for J4||523-L77SDE09S||DB9 female serial connector||1|
|for J4||538-16-02-0102||female crimp pins||10|
|for J4||855-M20-1060300||3-pin female header pin housing||1|
|616-62578-510-000||Enclosure with 9V battery compartment (includes 9V battery connector)||1|
Below are the top and bottom views of the PC Board from FAR circuits.
If you’re inexperienced with soldering, there are plenty of videos on Youtube that’ll teach you how. Take a few minutes and check them out. Here’s one from Sparkfun:
For the most part, construction is pretty straightforward–insert the parts through the top of the board and solder them on the bottom of the board. Leave the BT2S for last–we’re going to need to do a bit of work on that before we solder it to the board. Note that the capacitors and diodes have a polarity which must be observed. For the electrolytic capacitors, the longer of the two leads is the positive lead and should be inserted into the hole closest to the + sign. C2 is a nonpolarized capacitor and can be inserted in either orientation.
D1, the LED, also has a longer positive lead, and this lead should go into the hole closest to SW1. Before you solder D1 in place, consider that you won’t want to mount it flush with the surface of the board. Instead, mount it so that it’s a half inch or so above the board, so you can bend the leads and have the top of the LED push through a hole in the front panel so it’s visible.
D2, the 1N4001 diode, has a gray band on one end of its body, and that band should be lined up with the band on one end of the component outline on the board. U1, the voltage regulator, should be inserted so its flat side lines up with the flat side on the component outline on the board. U2, the MAX232 chip, should be oriented so that the dimple or notch in one end corresponds to the notch in the outline on the board.
SW1 and J2 fit right onto the board and are soldered in place. At J4, break off a row of three of the header pins and solder them in place. Later we’ll fabricate a cable that can connect to a PC serial port that we’ll plug in at J4 so we can program the BT2S module.
J3 is where the power is connected. You can connect the 9V battery connector leads here–the black wire goes into the negative hole and the red wire goes into the positive hole.
Once everything is soldered in place (minus the BT2S), connect a 9V battery and flip the switch–the LED should light. If not, check your battery, and then check all your parts placements and soldering. One more check to make is to check the voltage between the VCC and GND pads for the BT2S (you’ll need to do it from the bottom of the board). If it’s 5V, you’re good to go.
Here’s what things should look like so far:
Connecting the BT2S
The BT2S module comes complete with connector pins and a ribbon cable, and we’ll use those to connect it to the PC board. This is a little bit awkward because you have to cram the BT2S and its ribbon cable into the enclosure when you button things up, but it’s doable without a lot of trouble. You’ll need to install a set of four right-angle header pins in the holes for the BT2S on the PC board:
Then simply connect those to the cable and the cable to the BT2S. This is what things look like when you’re done:
Make sure when you plug the cable in that the pins specified on the PC board (VCC, GND, TXD, RXD) get connected to the pins of the BT2S having the same label. Once the BT2S is installed on the PC board, plug in the battery and hit the switch. You should see a small red LED begin to flash on the BT2S.
Making the BT2S Programming Cable
The BT2S is a programmable device, allowing you to specify the baud rate at which it operates, and optionally to change its bluetooth device name. The BT2S comes programmed for 9600 baud, 8 bits, one stop bit, no parity, and no flow control. These are good defaults and will work for many devices. If it’s necessary to change the baud rate at which it communicates, you’ll need to fabricate a special serial cable that can be plugged in to the PC board at one end and a PC at the other (if your PC doesn’t have a serial port, you’ll need to use a USB-to-serial converter cable in conjunction with the programming cable you make).
The necessary programming cable has a female 9-pin serial connector (DB9F) on one end, and a three-pin connector on the other end. The three-pin connector plugs into the PC board header pins you installed at J4. The labels on the board indicate which pin on the PC board connects to which pin on the female serial connector. The pictures below should give you an idea of how all this works.
The black plastic connector on the end that plugs into the PC board is made by first crimping some female header pins onto each of the wires, and then sliding those connectors into the black plastic housing. You may not be familiar with how to make that connector, so here are a couple videos that show you how.
If you find yourself doing any electronics experimenting, it’s good to learn how to make these connectors–they’ll make your connections much more reliable (and make it possible to disconnect things as well as connect them). I use an inexpensive crimping tool from Jameco (part number 99443) to crimp the pins for these connectors.
Once the cable has been prepared, you’re ready to connect everything and program it. If you’re using a USB-to-serial converter cable, plug it in to your PC and note the number of the serial port it creates (you can see that in Device Manager in Windows). Plug your programming cable into your serial port/cable and connect the other end to your PC board at J4. Here’s my interface with the programming cable connected:
Programming the BT2S
You’ll need a serial terminal program like Hyperterminal to send programming commands from your PC to your PC board. Windows 7 doesn’t include Hyperterminal, but you can use other terminal emulators. I’ll use a free one called PuTTY here as an example (you can use another if you’d like–just configure it for the correct serial port, 9600 baud, 8 bits, 1 stop bit, no parity, and no flow control). You can download putty.exe from this page (or use this link to download the exe file directly). Download it to your desktop, and just double-click it to run it. You’ll see the following window:
On this configuration screen, set the Connection Type to Serial, the Serial Line to whatever port you’re using, and the Speed to 9600. Then click the Open button. Next you’ll see the PuTTY terminal window. You’ll be sending commands to the BT2S, but rather than typing them directly into PuTTY, it works better to first type them into a text editor like Notepad, and then copy and past them into PuTTY. There’s two reasons for this. First, since the BT2S doesn’t echo your typed characters back to you, PuTTY won’t display what you type–so, it’s difficult to know if you making mistakes. Second, the BT2S expects the commands to be sent quickly (with little delay between characters), and pasting the commands into PuTTY from the clipboard causes them to be sent quickly to the BT2S, preventing any problems created by slow typing.
First, open up Notepad or some other plain text editor. Type “AT” into Notepad (without the quotes, and without hitting the Enter key at the end), and then copy that text to the clipboard (highlight it with the mouse, and the press Ctrl-C). Then right-click your mouse in the PuTTY window (right-click is the way that PuTTY knows to take what’s on the clipboard and send it to whatever it’s connected to–in this case, the BT2S). The “AT” command doesn’t do anything to the BT2S other than get it to respond with “OK”. Here’s what you should see after sending “AT”:
This verifies that the BT2S is operating correctly. If you don’t need to change the baud rate at which the BT2S communicates, and you don’t want to change the name with which it identifies itself, you’re done–close PuTTY and disconnect the serial programming cable. Otherwise, continue on.
The desired baud rate is going to be determined by the device you’re connecting to. For example, my own digital setting circles board operates at 9600 baud. My Celestron NexStar 6SE also operates at 9600 buad. My Elecraft KX3 ham radio transceiver is adjustable, but its default baud rate is 38400. To set the baud rate to something other than 9600 baud, use one of the following commands:
- for 1200 baud: AT+BAUD1
- for 2400 baud: AT+BAUD2
- for 4800 baud: AT+BAUD3
- for 9600 baud: AT+BAUD4
- for 19200 baud: AT+BAUD5
- for 38400 baud: AT+BAUD6
- for 57600 baud: AT+BAUD7
The BT2S should respond with “OK” + whatever baud rate you set it to (e.g. “OK38400”). In the screen shot below, I sent the command to set the baud rate to 9600 (which it was already set to). Keep in mind that once you set the baud rate to something other than 9600, PuTTY will no longer be able to communicate with the BT2S because it’s still trying to communicate at 9600 baud. You’ll need to close PuTTY and relaunch it, this time specifying the new baud rate it should use.
If you want to change the name that the BT2S uses when it identifies itself to devices trying to connect to it, use the command “AT+NAMExxxx” (where xxxx is the new name you want to give it. The BT2S should respond with “OKsetname”.
That’s it–your BT2S is programmed, and you should now be able to connect to your bluetooth interface from your PC or tablet (assuming, of course, they’re bluetooth-enabled). Power off the interface and unplug the programming cable.
Pairing with your Bluetooth Interface
So, let’s see if you can actually detect and pair with your newly-built bluetooth interface. If you have a bluetooth enabled PC or laptop running Windows 7, here’s how you do it. First, make sure your bluetooth radio is on. How you do that varies from one PC to the next. Sometimes on your laptop there’s a function key that will turn the bluetooth radio on and off. In other cases you might do it from one of the icons in the system tray.
Once you’ve ensured that bluetooth is on, open the system tray, find the bluetooth icon, and double-click it.
You should see the following window (ignore the KX3BT icon in my example below–that’s a device I had previously connected). Click the “Add a device” button.
The next window will probably not show any new devices when it first appears, but eventually your new device (in this example, mine’s named “NEXBT” should appear. Click to highlight it, and then click the Next button.
Next, you’ll be asked how to pair with the device. Select the option where you’ll enter a pairing code for the device, and click the Next button.
On the next screen, enter “1234” for the pairing code, and click the Next button.
Now you should be paired with your new bluetooth interface.
Click the Close button, and you should now see your bluetooth interface in the list of paired devices.
If you right-click on your device and select “Properties”, You’ll see the properties window. On the Hardware tab, you can see the serial port to which the device has been assigned.
In this case, my device was assigned to COM18.
Connecting your Serial Device
Okay, the whole point of this exercise was so you could connect one of your serial devices to your PC or tablet using bluetooth. So, we need to connect our bluetooth interface to that serial device. Most serial devices (like my digital setting circles and my Celestron NexStar 6SE telescope) have a female serial connector that is intended to be plugged into a PC. Instead, we’ll plug it into our bluetooth interface, and we’ll need to make one more cable for that purpose. Our cable has a stereo audio plug on one end and a DB9 male serial connector on the other end.
The audio plug will plug into the corresponding jack on the bluetooth interface. The male serial connector plugs into the cable or connector on your serial device. It’s wired like this:
- pin 2 of the DB9 connector (the green wire in the pictures) connects to the ring (middle part) of the audio plug
- pin 3 of the DB9 connector (the red wire in the pictures) connects to the tip (end) of the audio plug
- pin 5 of the DB9 connector (the black wire in the pictures) connects to the sleeve (base) of the audio plug
If your serial device has some other type of connector, you’ll need to research a bit to make the right cable.
Why did I use an audio connector on the bluetooth interface? The reason I did that is because I originally did this project to interface with my Elecraft KX3. Its serial port has the same audio jack as the bluetooth interface, and I can connect the two using a ready-made straight-through audio patch cable like this one from Mouser.
So, all that remains is to see if it works, and then button it up in the enclosure. How you test it will depend on what you’re using it with and what software you use to control the device you’re interfacing. If you were previously connecting your serial device directly to your PC with a cable, now you should be able to connect it using bluetooth simply by pairing the device with your PC and then running your control software, specifying the correct serial port as indicated in the bluetooth device properties like I mentioned above. If you successfully connect to your device over bluetooth using your control software, the flashing red LED on the BT2S board should stop flashing and glow a steady red. It’ll begin flashing again as soon as your software disconnects.
The enclosure I picked for this project has a front panel that’s easily drilled for the switch, audio jack, and LED. It also has a separate compartment for the 9V battery. You can put it all together just like I did, or you can customize it (or do something different entirely).
If you’re doing what I did, you’ll first want to drill the front panel so that it accepts the jack, LED, and switch. Here’s a template that you can use for this purpose. Once the front panel is drilled, use the nut on the audio jack to hold the panel on the board (it’s a tight fit–you might need to work with it a bit to get the nut on due to the thickness of the panel). Once the panel’s drilled, everything’s ready:
Here’s what it looks like all buttoned up:
So, that’s it. With any luck, you now have a bluetooth-serial converter that you can use to link your device to your PC or tablet. I’ve built two so far, one for my KX3 and the other for my Celestron telescope, and both work great. Leave a comment below if you have any questions or suggestions.