How to Auto-Connect 2 PmodBT2's Together

Introduction

The PmodBT2's can be configured to auto connect with one another in order to provide an instant bidirectional serial cable replacement. Below is a simple guide to show you how this is done.


Required Materials

  • x2 PmodBT2
  • Host computer with bluetooth and general purpose Terminal program (e.g. TeraTerm or Hyperterminal) or a serial terminal app on your non IOS mobile device.
  • A means to provide power to the BT2's

Terminology

  • <cr> - When you see this you will need to add a carriage return in your terminal.

Instructions

The general setup just needs the user to be able to connect and enter setup mode on the BT2's therefore this tutorial can be performed either using a Bluetooth compatible PC with a terminal program or a Bluetooth compatible smartphone (non IOS) with a terminal app. All commands used in this tutorial can be found in the RN42's reference manual.

1. Initial Setup

1.1) First make sure that both of the PmodBT2's have been reset to their factory defaults. To do this short the JP1 jumper on the BT2, apply power and remove/replace the jumper twice. On the second jumper replacement you should see both the red and green leds flash momentarily, this is how you know that you successfully reset your BT2. It is important to note that the jumper on JP1 needs to be on before the BT2 is powered on in order to take effect.
1.2) Once the BT2's are reset, remove the jumper on JP1 and power cycle.

2. BT2 Configuration

2.1) At this point you will need to decide which BT2 you would like to be the slave and master.

3. Slave Configuration

3.1) Connect to your designated slave BT2 with your preferred device and send the command “$$$” through the terminal. If you receive “CMD” back from the BT2 and the BT2's green led begins flashing more rapidly you know that you have successfully entered “Command Mode”.
3.2) Next enter “D<cr>” to display the BT2's basic settings and verify that “Mode =Slav”. If the mode is set to anything other than the slave then set the mode to slave by entering the command “SM,0<cr>”.
3.3) Next we need to disable the authentication. To do this send the command “SA,0<cr>” and verify that “Authen=0” in the basic settings.
3.4) In order for these changes to take effect the device must be rebooted. Use the “R,1<cr>” command to reboot.

4. Master Configuration

4.1) Next up is to configure your master device. Using the same process to enter command mode as you did to the slave enter command mode of the master BT2.
4.2) Send the commands “SA,0<cr>” and “Sm,3<cr>” separately. These commands will disable authentication and set the BT2 into “Auto-Connect” mode.
4.3) Next you'll need to tell the BT2 module which device to connect to. With the slave BT2 powered on send the “I,10<cr>” command to discover all PmodBT2 devices within range and their addressees will be returned. The address is a 12-digit hexadecimal number. It can also be found on the Pmod BT2's label as the MAC ID. Once the slave's device address is known send the command “SR,<address><cr>” in order to save it to memory. For example if the slave's address was 00066676ABCD you would enter “SR,00066676ABCD<cr>”.
4.4) Check to make sure that the device is in auto connect code, has no authentication, and has stored the correct slave address. Send “D<cr>” and verify “Mode =DTR”, “Authen=0” and that “REM=ADDR” where ADDR is the slave's address.
4.5) Reboot the device using the “R,1<cr>” command.

5. Test!

5.1) Connect the BT2's to a power source close enough that they are within range of each other and power them up at the same time (plugging them both into one of Digilent's boards is an easy way to do this). Within a few seconds you should see the green lights turn off on both of the BT2s. This means that you have successfully configured your PmodBT2s to auto connect with each other!