Skill Level: Intermediate

This recipe shows how to connect your Robosapien Robot to Watson IoT Platform using Raspberry Pi and to control the Humanoid Robot by sending Wake up, Dance, Pickup and Sleep commands using Node-RED.


  1. IBM Bluemix account
  2. Raspberry Pi 3 Model B
  3. Robosapien Humanoid Robot & IR Dongle
  4. Node-RED
  5. NodeJS and CylonJS


  1. Installing NodeJS and CylonJS to play Robosapien WAV files on Raspberry Pi

    You will need to first install NodeJS(See instructions here) and CylonJS(See instructions here) on your Pi. CylonJS audio module plays mp3 only. So you need to convert all the Robosapien WAV files(Click here to download wav files) to MP3 using Lame mp3 encoder.

    Here’re the Steps to play mp3 files on your Raspberry Pi:


    1. Install npm
      sudo npm install
    2. Install Node JS
      sudo apt-get install git; 

      git clone; 

      cd NodeJs-Raspberry-Pi; 

      chmod +x; 

      sudo ./; 

      cd .. && rm -R -f NodeJs-Raspberry-Pi/; 

      node -v;
    3. Install Cylon audio module
      sudo npm install cylon cylon-audio
    4. Install mpg123
      sudo apt-get install mpg123
    5. Install the lame

      sudo apt-get install lame
    6. Download the RoboSapien wavfiles and use this command to convert all wav files into mp3
      for f in *.wav; do lame -V 1 "$f" "${f%.wav}.mp3"; done
    7. Connect  earphone to audio jack of Pi and Use the following code to play MP3 in NodeJS using Cylon JS


    var Cylon = require('cylon');

    connections: {
    audio: { adaptor: 'audio' }

    devices: {
    audio: { driver: 'audio' }

    work: function(robopi) {'playing mp3 command', function(){
    console.log('Playing this Robot Command:');

    // Pass mp3 file name with a full or relative path'./sounds/RoboSapien/58_DANCE_0xD4.mp3');



  2. Connect the Raspberry Pi to WIoT and publish sample Robot message


    1. Install the node js client libraries for connecting Pi to IBM Watson IoT(See instructions here)
    2. Register your Pi in WIoT and use credentials in the code to send event messages and to receive device commands. You can follow instructions here. I've used Device Type as RberryPi and device name as RoboPidevice
    3. Update your device.json file with your Org ID, Device Type, DeviceID and Tokendevice_json
    4. Connect to the WIoT Platform by using the connect function
      var iotf = require("./iotf/iotf-client");
      var config = require("./device.json");
      var mqttClient = new iotf.IotfDevice(config);
      //setting the log level to debug.
      * Connect to IBM WIoT Platform
      console.log("IOTF start");

      mqttClient.on('connect', function() {
      var i = 0;
      console.log("connected to IBM IOTF/Bluemix");

      setInterval(function function_name() {
      mqttClient.publish('ping', 'json', '{"mode":"Dance","batLevel":"99%","RoboColor":"blue","RoboID":"Blue Robo 2.0","roboName":"iRobot"} ', 2);
      }, 30000);
    5. Make sure that your client program is connected to WIoTP successfully.Voila_Capture-2017-02-05_03-30-44_PM
    6. The above program will also publish message to your WIoT Org every 30 seconds. You can see the messages in the Watson IoT Dashboardwiot_events-Robo
  3. Controlling the Humanoid Robot using Node-Red


    1. Insert the IR dongle into the audio jack of your Pi

    2. Switch on the Robot

    3. Open the Node-Red instance on your browser

    4. Create a Flow in Node-Red to send Wakeup, Dance, Pickup, Sleep and Power off commands to WIoT as shown below



    4. Point the IR Dongle connected to Pi towards the Robot and press any one of the command such as Wakeup, Dance or Pickup in Node- Red. Robot will start accepting your command and you will see following messages in your Pi CLI for each commands sent from Node-Red





  4. Conclusion and Next steps

    In this recipe, we learned the following,

    1. How to Install Node JS and CylonJS to play Robosapien WAV files on Pi.
    2. How to Connect the Raspberry Pi to WIoT and publishing sample Robot event messages.
    3. How to send commands from Node-Red and Control the Robosapien Humanoid Robot 
      As a next step, you could try with various commands(e.g: Turn Left/Right, Go Backward/Forward, Right/Left Strike, Whistle, Burp etc..) based on the available Robosapien sound files in Node Red and enjoy playing with your humanoid Robot. 

      Go to Part 2 of this recipe for details of how to control the Humanoid Robot with voice commands using Watson STT service and start interacting with your Robot!


4 comments on"Control your Robosapien Humanoid Robot using IBM Watson IoT Platform, Raspberry Pi and Node-RED(Part 1)"

  1. Hi, Purush, Can we buy a clone one(Roboactor) to practice this lab ? Thanks

  2. any advice please ….

Join The Discussion