Skill Level: Intermediate

This recipe describes how to create an simple code in Node-RED to send data from SensorTag CC2650 to IBM Watson IoT Platform.


  • Bluemix account
  • Raspberry Pi 3
  • SensorTag CC2650 Development Kit


  1. Connect to your Raspberry Pi

    The first step is to connect to your raspberry pi using an SSH terminal like putty. Then run the command node-red-start on bash terminal to start the first time node-red server, this is important to create the directory /home/pi/.node-red when we will install the libs to access SensorTag. When the server finish loading, you can test the Node-RED accessing the user interface using your browser point to the address http://<iprasberrypi>:1880



    If this works fine, you now have to stop the Node-RED server, in bash terminal just press ctrl+C and then type the command node-red-stop.


    Now we can start installing the libs.

  2. Installing Bluetooth libs and node sensortag

    The next step is access the directory .node-red that was created in your home folder /home/pi/.node-red, this is important because Node-RED is based on NodeJS, and you need to be into the correct directory to proceed libraries install. 


    Then, is importante to update you raspberry pi apt-get resources, to do this you can type the command:

    sudo apt-get update

    When they finish, we will follow the installation tutorial on this site:

    First, you install the Linux libraries to access Bluetooth:

    sudo apt-get install libbluetooth-dev libudev-dev pi-bluetooth

    Then type this command to configure Bluetooth service:

    sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

    When this finish you can install this NodeJS node that has the code to access SensorTag

    npm i node-red-node-sensortag

    This command will take some minuts to finish. 

    Before this step finish you can restart your raspberry pi, and then when this boot, start again you Node-RED server using the command: node-red-start

  3. Coding you application on Node-RED

    Now you can find the sensorTag on advanced group of tags in Node-RED. We will now build an code to get the data from SensorTag and then send to Watson IoT.


    The first node, is sensorTag, we need to double click the node to configure the MACADDRESS(UUID), from the sensor then select the data we will capture, for that we just select Temperature and Humidity.


    The next step is to connect an switch node to filter the messages from sensortag, we configure the node to just pass the objects messages that has in the topic a value temperature.



    Even if we filter the messagens, sensortag will send a lot messages, to limit the number of messages, we will use the delay node and configure to limite the number of messages for 1 per minute. 



    Before we send the message to Watson Iot, we need to format the data to mqtt server in Bluemix accept. This node function has this javascript code just to correct the format of the data. More info about this format can be found here:


    The last step is connect the node Watson Iot output to send the message to Bluemix. We create an device into Watson Iot and get the credentials to configure this node. Once you click on Deploy button the raspberry pi will conect to SensorTag and start send data to Bluemix.


    This is the code of the flow:

    [{“id”:”fc916843.2edb28″,”type”:”sensorTag”,”z”:”ee3e8f00.10579″,”name”:”tag”,”topic”:”sensorTag”,”uuid”:”a0e6f8c21684″,”temperature”:true,”humidity”:true,”pressure”:true,”magnetometer”:true,”accelerometer”:true,”gyroscope”:true,”keys”:true,”luxometer”:false,”x”:115.5,”y”:58,”wires”:[[“546008af.f1b3a8”]]},{“id”:”fdb01a2b.833a68″,”type”:”debug”,”z”:”ee3e8f00.10579″,”name”:””,”active”:true,”console”:”false”,”complete”:”true”,”x”:660,”y”:77,”wires”:[]},{“id”:”546008af.f1b3a8″,”type”:”switch”,”z”:”ee3e8f00.10579″,”name”:””,”property”:”topic”,”propertyType”:”msg”,”rules”:[{“t”:”cont”,”v”:”temperature”,”vt”:”str”}],”checkall”:”true”,”outputs”:1,”x”:221,”y”:146,”wires”:[[“aa8718c3.6315f8”]]},{“id”:”aa8718c3.6315f8″,”type”:”delay”,”z”:”ee3e8f00.10579″,”name”:””,”pauseType”:”rate”,”timeout”:”5″,”timeoutUnits”:”seconds”,”rate”:”1″,”nbRateUnits”:”1″,”rateUnits”:”minute”,”randomFirst”:”1″,”randomLast”:”5″,”randomUnits”:”seconds”,”drop”:true,”x”:354,”y”:61,”wires”:[[“d68c43b5.dce2f”]]},{“id”:”d68c43b5.dce2f”,”type”:”function”,”z”:”ee3e8f00.10579″,”name”:””,”func”:”var temp = parseFloat(msg.payload.ambient);nmsg.payload = {'d':{'temperature':temp}};nreturn msg;”,”outputs”:1,”noerr”:0,”x”:493,”y”:149,”wires”:[[“fdb01a2b.833a68″,”daddaa20.7ffdd8”]]},{“id”:”daddaa20.7ffdd8″,”type”:”wiotp out”,”z”:”ee3e8f00.10579″,”authType”:”d”,”qs”:”false”,”qsDeviceId”:””,”deviceKey”:”4d195373.2056ec”,”deviceType”:””,”deviceId”:””,”event”:”event”,”format”:”json”,”name”:””,”x”:665,”y”:197,”wires”:[]},{“id”:”4d195373.2056ec”,”type”:”wiotp-credentials”,”z”:””,”name”:””,”org”:”YOURORGANIZATIONONWATSONIOT”,”devType”:”YOURDEVICETYPEONWATSONIOT”,”devId”:”YOURDEVICEIDONWATSONIOT”}]

1 comment on"SensorTag CC2650 sending data throw Raspberry Pi 3 to IBM Watson IoT Platform using Node-RED"

  1. Hello Walter,

    I’m currently trying to replicate your above recipe, but in my case there’s no output message from debug node.
    Sensor tag node status is “connected” though. Do you know any possible pitfall?
    I’m using raspberry pi 3B, with below module versions:
    node -v
    npm -v
    nodejs -v

    Appreciate your help.
    Thank you! 🙂

Join The Discussion