I managed to connect a sensor via Bluetooth to a serial port on the Raspberry Pi 4 by doing the following:
First, I added the SP profile to the Raspberry by opening and editing the following file:
sudo nano /etc/systemd/system/dbus-org.bluez.service
I added the compatibility flag -C and a new line to add the SP profile lines:
ExecStart=/usr/lib/bluetooth/bluetoothd -C
ExecStartPost=/usr/bin/sdptool add SP
Then I paired and connected entering the following on the terminal:
bluetoothctl
pair <deviceAddress>
trust <deviceAddress>
exit
On a different terminal window, I entered:
sudo rfcomm connect hci0 <deviceAddress>
This connected the device, and then I opened a minicom window to see the data the sensor was sending by entering:
minicom -b 9600 -o -D /dev/rfcomm0
This worked fine, but now I want to connect another sensor to a different serial port (an eventually a third sensor), so that I can simultanously see the data the two sensors are sending on two different minicom windows. I managed to pair and trust the new sensor but when I execute the folling line it gives me an error:
sudo rfcomm connect hci0 <deviceAddress>
The error is: "Can't create RFCOMM TTY: Address already in use"
I guess the problem might be with the hci0 but I'm not sure, as I don't completely understand what that is. I tried to use channel 2 by adding a 2 to the prior line (I don't know if this makes sense) and it didn't work either ("Can't create RFCOMM TTY: Address already in use".)
I also tried to use another device, hci1 instead of hci0, and it says: "Can't connect RFCOMM socket: Host is down". When I run the folowing:
hcitootl dev
only hci0 appears, so I don't know if I should create another device to be able to connect another sensor or how it is done.
So, anyone knows a way to make several Bluetooth serial connections, so that I can see the data several sensors are sending at the same time on different minicom windows?
Thanks.