Skill Level: Intermediate

javascript ,bluemix, iot, node.js, node-red, mqtt,

Over the Holidays I bought some Bluetooth LED Candles called PlayBulb. They come with an app but I wanted to control them via WiFI and integrate them with WIoTP and take advantage of Node-Red, Watson API and Twitter. E.g to reflect the mood of Tweets.


  • Bluemix account
  • Watson IoT starter app
  • Weather Company and Twitter Service
  • Watson Ton Analyser Service
  • Raspberry Pi 3
  • PlayBulb Candle
  • Shopping list



  1. Connect your PlayBulb to a Pi

    The first step is to setup you PI 3i with the Bluetooth/BLE software so we can talk to the PlayBulb. 

    PI as a BLE GW for PlayBulb

    You will need to install some ble packages before we can start like libbluetooth-dev – the folowing command should to the trick. 

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

    I put a node.js package in github (here) which you can clone and than run npm install. Make sure you have npm and node.js installed on your PI. You can find instructions here. The github project / package.json contains all the information and will download all the required components to your pi. There is also a video which shows all the installations steps and finished solution on my youtube channel. 

    Once you have installed all the files you can run the pipb.js. The Syntax is >node pipb.js uuid/macaddr color mode<

    node pipb.js ??? the program will than display the uuid of all active BLE devices around you. Once you have the uuid of the candle you can use it to change the color like node pipb.js uuid blue.

    Here the steps:

    1. git clone https://github.com/markusvankempen/playbulb.git
    2. cd playbulb
    3. sudo npm install 
    4. sudo node pipb ??? // will list all ble /bluethooth devicename and  their uuid 
    5. sudo node pipb 70a54b16ace6 blue //  with your uuid of course

    here example of getting the uuid and set the candle to the color blue .


    The Canadle has a couple function like set / get name and color as well as modes like flash, Rainbow and Candle mode – see the code for more details. 



  2. Connect the PI to WIoT and publish Candle data


    Next step is to register the PI as device in Watson IoT Platform and use the credentials in our program to publish events and receive device commands. In order to register the device type i called it “raspi” and the device “candlepi” your can follow the instructions here.

    Note down the organisation and the authentication token down – assuming your sue the the same device type and id. Use the information to update the device.json file.

    "org": "g5vu8",  <<< YOUR ORG
    "domain": "internetofthings.ibmcloud.com",
    "type": "raspi",
    "id": "candlepi",
    "auth-method" : "token",
    "auth-token" : "EQh7FW&FNjhAT@H_51" << YOUR token


    once you you update the device.json file you can start the porgram pipbiot.js.

    Like: sudo node pipbiot.js uuid or macaddr

    the program will publish message to your Watson IoT Org every 5 sec. You can display the event message in Node-Red via a debugging node or see the message in the Watson IoT Dashboard

    Here an example of the PI sending events / candle information to the WIoTP.


    Thevideo is showing you how the porcess works. You can find the Node-Red flow in the git.

  3. Control the Candle via Node-Red

    Once the pibpiot.js gateway program is running and connected to your Playbulb Candle you can upload the flow (pbcandle1st.flow) to Node-red and receive status events from the pi gateway about the candle.


    The gateway program can also receive commands which you can send form Node-RED via the injection buttons. You can add node-red-ui or freeboard or use the Watson IoT workbench for visualizing the data. I like node-red-contrib-ui which you can add to your node-red instance you can find more detail about the ui setup here.

    Here and example of the Watson IoT Dashboard using the candle (ping) event data for visualisation.


  4. Change the Candle Color based on Temperature


    Since you have the Pi Candle gateway with WIoT and Node-Red running and you able to retrieve and send message to and from the Candle you can do all kinds of fun stuff. Here a couple of examples. I used the weather company service in Bluemix and added it to my IoT/Node-Red instance. Basicaly i wanted a visual representation of the temparture like blue = cold , red=warm and blink blue = very cold … you can find the Node-Red flow here

  5. Using Watson Tone Analyzer and Twitter to change the Candle Color and Mode


    In this scenario i used the Watson Tone Analyzer and Twitter to change the Candle Color. Basicly turn the PlayBulb Candle into a Twitter mood Candle based on hashtags. Like #Winter or #Snowbaording etc. You can find the Node-RED flow for the mood Candle here.


  6. Question, Comments and other use cases.

    I have published avideo of the setup and the different scenarios on my youtube channel.

    Please let me know if you have questions in the comment section.

    I will publish some more flows and scenarios for the PlayBulb Candle like Watson Speech to Text and Conversation and well as IFTT.

    Stay tuned and Enjoy.


Join The Discussion