0.0.3 • Public • Published

    cc2uart -- node-cc2540

    node.js support for the TI CC2540 UART service. The CC2540 is programmable so there is no guarantee this works with all boards with the CC2540 chip.

    This module is built on noble so it should work where ever noble works.

    See also nrfuart if using the nRF8001 or nRF51822 chip.

    Tested configurations

    A USB to Bluetooth 4.0 gadget similar to this is required to add BLE support to systems without Bluetooth 4.0/BLE hardware.

    Laptop running Ubuntu Linux 14.04

    Laptop running Ubuntu 14.04 <-> BLE <-> CC2540 <-> Arduino Uno

    Ubuntu 14.04 includes bluez 4.101 which is sufficient for this module. Install the following packages before installing cc2uart.

    sudo apt-get install bluetooth bluez-utils libbluetooth-dev

    Raspberry Pi running Raspbian Linux

    The tested device is a Raspberry Pi Model B running a fresh installation of Raspian release 2015-02-16. Be sure to do the usual post-installation steps such as "sudo apt-get update", "sudo apt-get upgrade", and "sudo raspi-config".

    The next step is to install node.js. The version of node.js in the Raspian repo is too old so install a recent version.

    sudo dpkg -i node_0.10.36_armhf.deb

    Install bluez 4.99 from the Raspian repo. Testing has shown this version works with BLE and noble. This is much easier and faster than install bluez 5.x from source code.

    sudo apt-get install bluez bluez-tools libbluetooth-dev

    If bluez 4.99 does not work, remove it then install bluez 5.x as described below. Remember, do the next block of commands only if BLE is not working.

    sudo apt-get remove bluez bluez-tools libbluetooth-dev
    # Reference: 
    sudo apt-get install libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev \
    libical-dev libreadline-dev libudev-dev libusb-dev make
    mkdir bluez
    cd bluez
    tar xf bluez-5.28.tar.xz
    cd bluez-5.28
    ./configure --disable-systemd --enable-library
    # The next step takes a long time. 
    sudo make install
    sudo hciconfig hci0 up

    Install this module

    npm install cc2uart 

    Use this module

    This program sends a test pattern and displays anything that comes back.

    var cc2uart = require('cc2uart');
    cc2uart.discoverAll(function(ble_uart) {
        // enable disconnect notifications
        ble_uart.on('disconnect', function() {
        // connect and setup
        ble_uart.connectAndSetup(function() {
            var writeCount = 0;
            ble_uart.readSystemId(function(sysID) {
                console.log('System ID:', sysID);
            ble_uart.on('data', function(data) {
                console.log('received:', data.toString());
            setInterval(function() {
                var TESTPATT = 'Hello world! ' + writeCount.toString();
                ble_uart.write(TESTPATT, function() {
                    console.log('data sent:', TESTPATT);
            }, 3000);


    npm i cc2uart

    DownloadsWeekly Downloads






    Last publish


    • bbx10node