4

I am trying build a IoT small application, using IBM Bluemix platform. I found a video of Ryan J Baxter's on connecting a Sensor Tag to the IoT Cloud Foundation with a Beagle-bone. Now I'm trying the same procedure with a Raspberry Pi device instead of a Beagle-Bone, facing some issues with the sensor-tag.js file we are not able to get the cfg parameter values like cfg type, cfg org, cfg id from config.properties file.

I got the mac address which I gave when I'm registering the device I gave my Raspberry Pi mac address as it is connected to my Ethernet eth0.

    if(cfg.id != deviceId) {
        console.warn('The device MAC address does not match the ID in the configuration file.');
    }
    //------------- This is where I'm facing  a problem --------

    var clientId = ['d', cfg.org, cfg.type, cfg.id].join(':');

    var client = mqtt.connect("mqtts://" + cfg.org + 
      '.messaging.internetofthings.ibmcloud.com:8883', 
      {
        "clientId" : clientId,
        "keepalive" : 30,
        "username" : "use-token-auth",
        "password" : cfg['auth-token']
      });
    client.on('connect', function() {
      console.log('MQTT client connected to IBM IoT Cloud.');
    });
    client.on('error', function(err) {
      console.log('client error' + err);
      process.exit(1);
    });
    client.on('close', function() {
      console.log('client closed');
      process.exit(1);
    });
    monitorSensorTag(client);
  });
});

function monitorSensorTag(client) {
  console.log('Make sure the Sensor Tag is on!');
Ram
  • 3,092
  • 10
  • 40
  • 56
praveen gogula
  • 599
  • 3
  • 6
  • 22

1 Answers1

2

If you are using raspberry pi, take a look at the recipe for raspberry pi https://developer.ibm.com/iotfoundation/recipes/raspberry-pi/

There is also source code for raspberry pi on GitHub which may be helpful: https://github.com/ibm-messaging/iot-raspberrypi/

Using the recipe, you store the device info in a device.cfg file and it is used by the IoT service when you connect. /etc/iotsample-raspberrypi/device.cfg

EDITED TO ADD: Looking at the logs, I see you registered the Raspberry Pi Device with a different ID than what you are using. Please register the device with the correct ID that I emailed to you.

ValerieLampkin
  • 2,620
  • 13
  • 27
  • yes. it is already done before but I want my sensor tag to be connected to the IoT Cloud using Raspberry Pi. If I have to do this I have to connect my raspberry pi in a register mode is it?? – praveen gogula Jul 14 '15 at 13:59
  • Did you register the raspberry pi to the IoT Foundation? It expects the mac address to be in lowercase with no colons. – ValerieLampkin Jul 14 '15 at 20:09
  • If you let me know your org, I will check the IoT logs to see if I can find your connection errors. – ValerieLampkin Jul 14 '15 at 20:16
  • I registered my raspberry pi to the IoT Foundation mac address is perfect. But it is not connected to the IoT Cloud and not publishing any data. – praveen gogula Jul 15 '15 at 11:55
  • I see this error 2015-07-15T12:21:16 Token auth failed (Device does not exist): ClientID='d:rpwtjr:Raspberrypi: Your org shows registered devices both "pi" and "Raspberrypi" with the same ID. Did you only recently add the Raspberrypi name? – ValerieLampkin Jul 15 '15 at 12:47
  • Exactly you are right, I already registered the device in the name of "pi" or "RaspberryPi" with a trail Bluemix account. I think the Trail version is completed, now I'm trying the same procedure with same Raspberry pi with another bluemix trail account. can i do this or not???? – praveen gogula Jul 16 '15 at 10:58
  • You should be able to do it with a new trial account, but you'll have to register the Pi under the new account because when you create a new IOT service under new account it will have a different org. – ValerieLampkin Jul 16 '15 at 19:39