3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Watson IoT Platform - MQTT - Node-REDからpub/subする

Last updated at Posted at 2016-05-26

初めてWatson IoT Platformを使ってみよう、というかたのためのガイドです。
Watson IoT Platformを使ってみるでIoTアプリを準備しました。
MessageSightを動かすでMQTTブローカーとしてMessageSightを準備しました。
Node-REDをローカル環境で稼働させる

#Node-REDからpublish/subscribeしてみます

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":[]}]

  • MQTTノードを開き、ローカルのMessageSightのアドレスを指定します。
    スクリーンショット 2016-05-26 11.38.44.png

  • Node-REDからpublish/subscribeできるようになりました。
    スクリーンショット 2016-05-26 10.57.28.png

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":""}]

スクリーンショット 2016-10-07 18.10.01.png

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?