Bluetooth serial port communication for Node.js

Bluetooth serial port communication for Node.js

This node module lets you communicate over Bluetooth serial port with devices using Node.js. The goal is have an easy to use API. This module is great for communicating with Bluetooth enabled Arduino devices.

If you have any problems make sure to checkout the FAQ.

  • Fixes a critical runtime error on all platforms.
  • Improves travis build.
  • Needs Bluetooth development packages to build

apt-get install build-essential libbluetooth-dev

  • Needs XCode and XCode command line tools installed.
  • Needs Visual Studio (Visual C++) and its command line tools installed.
  • Needs Python 2.x installed and accessible from the command line path.

npm install bluetooth-serial-port

docker build -t bluetooth-serial-port .


var btSerial = new (require('bluetooth-serial-port')).BluetoothSerialPort();
btSerial.on('found', function(addressname) {
    btSerial.findSerialPortChannel(address, function(channel) {
        btSerial.connect(address, channel, function() {
            btSerial.write(new Buffer('my data', 'utf-8'), function(errbytesWritten) {
                if (err) console.log(err);
            btSerial.on('data', function(buffer) {
        }, function () {
            console.log('cannot connect');
        // close the connection when you're ready 
    }, function() {
        console.log('found nothing');

Emitted when data is read from the serial port connection.

  • buffer - the data that was read into a Buffer object.

Emitted when a connection was closed either by the user (i.e. calling close or remotely).

Emitted when reading from the serial port connection results in an error. The connection is closed.

Emitted when a bluetooth device was found.

  • address - the address of the device
  • name - the name of the device (or the address if the name is unavailable)

Emitted when the device inquiry execution did finish.

Starts searching for bluetooth devices. When a device is found a 'found' event will be emitted.

Checks if a device has a serial port service running and if it is found it passes the channel id to use for the RFCOMM connection.

  • callback(channel) - called when finished looking for a serial port on the device.
  • errorCallback - called the search finished but no serial port channel was found on the device.

Connects to a remote bluetooth device.

  • bluetoothAddress - the address of the remote Bluetooth device.
  • channel - the channel to connect to.
  • [successCallback] - called when a connection has been established.
  • [errorCallback(err)] - called when the connection attempt results in an error. The parameter is an Error object.

Closes the connection.

Check whether the connection is open or not.

Writes a Buffer to the serial port connection.

  • buffer - the Buffer to be written.
  • callback(err, bytesWritten) - is called when the write action has been completed. When the err parameter is set an error has occured, in that case err is an Error object. When err is not set the write action was successful and bytesWritten contains the amount of bytes that is written to the connection.


Lists the devices that are currently paired with the host.

  • callback(pairedDevices) - is called when the paired devices object has been populated. See the pull request for more information on the pairedDevices object.

This module is available under a FreeBSD license, see the LICENSE file for details.