Even though Watson IoT Platform provides APIs to work in different languages (and Node-RED), you might want to work in a language or platform that Watson IoT Platform does not support. In this case, you need to use an MQTT client library to be able to send data to the Watson IoT Platform. (Check out the Watson IoT Platform documentation for the languages supported.)
Go to http://mqtt.org to find client libraries that you can use. I’ll use Node-RED to show how you can use your own MQTT client library to send data to Watson IoT Platform.
First Brian shows how to configure MQTT with the quickstart service (https://quickstart.internetofthings.ibmcloud.com/); then, he quickly shows how to configure it in your own deployed instance of Watson IoT Platform. You can use the quickstart service, which is an open sandbox environment, to get up and running quickly or test your configuration, but do not use it for sensitive data or production code.
Watson IoT Platform has 3 key requirements for configuring and using MQTT:
- You must specify the address of the MQTT broker. In this example, orgId.messaging.internetofthings.ibmcloud.com
- You must specify the device ID (which is used to access your data) in a specific format. In this example, d:quickstart:testType:biBitesizedMQTT. Be sure to use a unique client ID, or you might get disconnected.
- Any topic that you subscribe to must also follow a specific format. Watson IoT Platform rejects any topic that doesn’t adhere to the format. In this example, iot-2/evt/event_id/fmt/format_string. To have the quickstart visualize your data, use the json data format, such as iot-2/evt/event_id/fmt/json