Connect the Raspberry Pi Node-RED flows to IBM Bluemix
Import a new Node-RED flow into the flow editor on the Raspberry Pi device:
- Go to GitHub: https://raw.githubusercontent.com/ibm-messaging/iot-device-samples/master/node-red/device-sample/quickstart.json.
- Copy the raw JSON from GitHub to your clipboard.
- In the flow editor, create a new flow tab.
- Import the new flow by clicking the Menu icon > Import > Clipboard.
- Double-click the red exec node (getCPUtemp) that retrieves the CPU temperature from the Raspberry Pi device. Add the following information and then click OK:
Connect the Node-RED flow on the Raspberry Pi with the Node-RED flow that you already have on Bluemix.
The communication between the Node-RED instance running on the Raspberry Pi and the one running on Bluemix is provided by IBM Watson IoT Platform/Quickstart, which is based on MQTT, a lightweight messaging protocol.
- Double-click the blue Watson IoT Output node (wiotp out) in the flow on the Raspberry Pi device. Select Quickstart and enter a unique value for the Quickstart Id. This value can be any string, but it must be unique in the entire system. Then, click OK.
- Double-click the blue IBM IoT App In node and enter the same Device Id that you used for the one on the Raspberry Pi. This is how the two Node-RED environments will communicate. Then, click Done.
- When the flow is set up as instructed in the previous steps, click Deploy. Then, click the timestamp node on the Raspberry Pi to start the flow that will send CPU data to the Node-RED instance on Bluemix every 5 seconds.
- Review the output in the debug panes.
The two outputs are dissimilar because the Node-RED flow on the Raspberry Pi does not have the trigger warning that you used for the Node-RED flow in Bluemix.
If you disconnect the connections to the green debug node on the Raspberry Pi, you won’t see any output in the first debug pane, which is highlighted in red, but you will see output in the debug pane highlighted in blue in the following image: