初めてWatson IoT Platformを使ってみよう、というかたのためのガイドです。
Watson IoT Platformを使ってみるでIoTアプリを準備しました。
MessageSightを動かすでMQTTブローカーとしてMessageSightを準備しました。
Node-REDをローカル環境で稼働させる
#Node-REDからpublish/subscribeしてみます
- Node-REDのフローをコピーする方法を参照して以下のフローをコピペします。
Node-REDからpub/subする
[{"id":"fac58d0f.dee3e8","type":"mqtt-broker","z":"d5a876a5.e9ace8","broker":"172.16.100.100","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"b1ec1387.cd7e8","type":"inject","z":"d5a876a5.e9ace8","name":"","topic":"","payload":"こんにちは","payloadType":"str","repeat":"","crontab":"","once":false,"x":120,"y":80,"wires":[["f65fa076.4979b8"]]},{"id":"11098816.20d498","type":"debug","z":"d5a876a5.e9ace8","name":"","active":true,"console":"false","complete":"false","x":670,"y":80,"wires":[]},{"id":"3ca78e60.54be5a","type":"mqtt in","z":"d5a876a5.e9ace8","name":"","topic":"/topic/test","broker":"fac58d0f.dee3e8","x":500,"y":80,"wires":[["11098816.20d498"]]},{"id":"f65fa076.4979b8","type":"mqtt out","z":"d5a876a5.e9ace8","name":"","topic":"/topic/test","qos":"","retain":"","broker":"fac58d0f.dee3e8","x":310,"y":80,"wires":[]}]
Quickstartへpublishする
- 下記のフローでQuickstartへpublishします
Quickstartへpub
[{"id":"25299f9e.3b6c58","type":"ibmiot in","z":"36890dfe.1ec31a","authentication":"quickstart","apiKey":"","inputType":"evt","deviceId":"001122334455","applicationId":"","deviceType":"+","eventType":"+","commandType":"","format":"json","name":"IBM IoT","service":"quickstart","allDevices":"","allApplications":"","allDeviceTypes":true,"allEvents":true,"allCommands":"","allFormats":"","x":250,"y":280,"wires":[["ee533a9b.228c48"]]},{"id":"ee533a9b.228c48","type":"debug","z":"36890dfe.1ec31a","name":"","active":true,"console":"false","complete":"false","x":410,"y":280,"wires":[]},{"id":"9a1895de.b51ed8","type":"mqtt out","z":"36890dfe.1ec31a","name":"","topic":"iot-2/evt/status/fmt/json","qos":"","retain":"","broker":"9ce74b4e.cb3c5","x":450,"y":220,"wires":[]},{"id":"f00fc92.52b2438","type":"inject","z":"36890dfe.1ec31a","name":"","topic":"","payload":"{ \"temp\" : \"25\", \"humidity\" : \"50\"}","payloadType":"str","repeat":"","crontab":"","once":false,"x":250,"y":220,"wires":[["9a1895de.b51ed8"]]},{"id":"9ce74b4e.cb3c5","type":"mqtt-broker","z":"36890dfe.1ec31a","broker":"quickstart.messaging.internetofthings.ibmcloud.com","port":"1883","tls":null,"clientid":"d:quickstart:myThing:001122334455","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""}]