In a previous post about bluetooth we have seen how to connect to a low cost HC-06 or Sparkfun Mate Gold module connected to an Arduino and establish a serial communication with it using minicom.
In this quick article we will see how to establish connections with two modules and a PC running Ubuntu 16.04.
Scan devices
userk@dopamine:~$ hcitool scan
Scanning ...
20:15:12:08:62:95 HC-06
00:06:66:68:20:61 RNBT-2061
From this command we get the addresses of two modules and their names.
Configure Rfcomm
Edit your configuration file and add the second device. I have just copied the settings for rfcomm0 and changed the name to rfcomm2
userk@dopamine:~$ sudo vim /etc/bluetooth/rfcomm.conf
Bind devices
Make sure that the channels are correct. Here I chose the first channel for both.
Select the device file to associate to each bluetooth module.
userk@dopamine:~$ sudo rfcomm bind 0 20:15:12:08:62:95 1
userk@dopamine:~$ sudo rfcomm bind 2 00:06:66:68:20:61 1
Minicom
Open in two different terminals Minicom as root and save two new configurations blue1 and blue2, the first one listening to port /dev/rfcomm0 and the second to /dev/rfcomm2.
Select Serial port setup.
Set the correct ports. And save the configurations as blue1 and blue2 profile.
Exit pressing Ctrl A + X. Now you can connect easily by calling the minicom profile.
userk@dopamine:~$ sudo minicom blue1
userk@dopamine:~$ sudo minicom blue2
Future connections will require the bind command we have seen above.