You have to perform several steps in order to establish communication.
You have to pair your desired bluetooth device using bluetoothctl
sudo bluetoothctl -a
scan on
devices
pair XX:XX:XX:XX:XX:XX
trust XX:XX:XX:XX:XX:XX
quit
Where XX:XX:XX:XX:XX:XX is the MAC address of your bluetooth device.
You have to create the serial device that binds to your paired bluetooth device.
sudo rfcomm bind /dev/rfcomm0 XX:XX:XX:XX:XX:XX 1
The last number is the communication channel. It has to bee unique for all your connections.
Then you should be able to open a connection. (Assuming your bluetooth device actually supports the required SPP protocol.)
echo “test” > /dev/rfcomm0
source: https://raspberrypi.stackexchange.com/questions/78155/using-dev-rfcomm0-in-raspberry-pi/78301#78301?s=39be540452a34b55af09cb19d04ea700