I have soldered a second serial Bluetooth module. I am now going to test them in a master/slave configuration.
The test boards
The first test board is the one already used for my slave test with a Teensy 2 as USB to serial adapter and power supply. This board will be the master one.
The second test board is powered by a USB connector and a 3.3V regulator. A serial connection is establish with my laptop through a Prolific PL2303 adapter. This board will be the slave one.
Slave module configuration
The slave module is powered up in command mode. Cu does not seem to work correctly anymore with the PL2303 so I use screen instead:
$>screen /dev/cu.serial 38400 AT+ADDR? +ADDR:11:3:252002 OK AT+UART? +UART:9600,0,0 OK AT+ROLE? +ROLE:0 OK
Role=0 is for the slave mode. I keep the default 9600 baud UART speed.
The module Bluetooth address will be useful to establish the connection from the master module.
Master module configuration
The master module is powered up in command mode. The role is changed to 1 for master. The UART baudrate is set to the same as the slave module.
$>sudo cu –s 38400 –l /dev/cu.usbmodemXXXX AT+UART? +UART:115200,0,0 OK AT+UART=9600,0,0 OK AT+UART? +UART:9600,0,0 OK AT+ROLE? +ROLE:0 OK AT+ROLE=1 +ROLE:1 OK AT+ROLE? +ROLE:1 OK
To establish an automatic connection to a slave module, the master module must know the slave address. This is configured with the AT+BIND command with CMODE=0 (Use a predefined address).
AT+CMODE? +CMOD:0 OK AT+BIND=11,3,252002 OK AT+BIND? +BIND:11:3:252002 OK
With CMODE=1, the master can connect to any device in its transmission range, so it is a much less secure configuration.
Master/Slave automatic connection
Now that the two modules are setup, I power up them in automatic mode (PIO11 = 0).
On each module, the red leds connected to PIO8 blinks quickly. After less than 2 seconds, the green led connected to PIO9 is shining on both modules indicating that they are now paired and connected, ready to transmit data.
I connect a terminal to the serial port of each module with their respective adapter to test the communication:
The first window displays the connection to the master BT module. The second window displays the connection to the slave BT module.
The connection is successful at 9600 bauds. I also successfully tested the communication at 115200 bauds.