FAQs
Contents
This FAQ will explain how you can use Node-RED to send serial data from the BB-400 to the Cloud. This FAQ will assume you have a basic understanding of Node-RED so if you require further information regarding Node-RED please refer to the following FAQ.
Read Serial data from the BB-400
There is already an FAQ on how to create a flow to read serial data from the BB-400 so please refer to the How do I use the BB-400’s Serial Port In Node-Red to learn how to set up your Node-RED flow to read and write serial data within Node-RED.
Once you have set up the flow in the above tutorial we can adjust the nodes to send the data to the Cloud instead.
Send data to the Cloud
The Cloud services that we have tested using the BB-400 are IBM, FRED and AWS. This FAQ will focus mainly on sending data to FRED but please refer to the IBM and AWS FAQs if you wish to send serial data to those services instead.
So having followed the How do I use the BB-400’s Serial Port In Node-Red FAQ your Node-RED workspace should look something like this:
In order to send the serial data to the cloud, instead of using the “chart” and “gauge” nodes used in the above FAQ, we will use cloud service nodes. These nodes will be readily available if you access Node-RED on the BB-400 but for reference the nodes required for each cloud service are:
Cloud Service | Node |
FRED | node-red-contrib-fred |
AWS | Uses the MQTT node which is available by default on Node-RED |
IBM | node-red-contrib-ibm-watson-iot |
If these nodes aren’t available on your Node-RED instance you can add them by going to Manage Palette:
Sending Serial data to FRED
Attach the FRED output node to the RS232 node and edit your settings using your FRED username/password or API key. Type in an endpoint. This example uses “Serial” as the endpoint but you can choose the end point that fits your needs.
Your flow should look something like this:
Configure FRED Cloud Service to receive data
Within your Cloud Service’s instance of Node-RED you will need to set up a flow to read the serial data from the BB-400.
The way to do this in FRED is to use a ‘FRED in node’, and edit the settings to match the endpoint of the FRED output node (set to “Serial” again) on your BB-400’s instance of Node-RED. Attach a debug node to the ‘FRED in’ node. The flow on FRED should look like this:
Now if you click deploy on both your BB-400’s instance of Node-RED and on FRED’s instance of Node-RED you should see the serial data being sent from your BB-400:
and being received on FRED:
BB-400 Send Serial Data Flow
Below is the full flow for sending serial data to FRED, AWS and IBM:
The JSON for the flow can be found below:
[
{"id":"b6e221f3.d2459","type":"tab","label":"[BB-400] Send Serial Data to the Cloud","disabled":true,"info":""},
{"id":"ef1becab.c3281","type":"inject","z":"b6e221f3.d2459","name":"Repeat","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":180,"wires":[["66598259.8a6c4c"]]},
{"id":"b80511b4.ce8da","type":"debug","z":"b6e221f3.d2459","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":200,"wires":[]},
{"id":"f5971fe0.01d49","type":"serial in","z":"b6e221f3.d2459","name":"RS232","serial":"3bfdfbae.3d7b74","x":410,"y":240,"wires":[["b80511b4.ce8da","8a1a5ba2.d9aac8","3833596e.b3a9f6","d09cf555.2e36c8"]]},
{"id":"5ecf9027.5ca1e","type":"serial out","z":"b6e221f3.d2459","name":"RS232","serial":"3bfdfbae.3d7b74","x":450,"y":180,"wires":[]},
{"id":"66598259.8a6c4c","type":"random","z":"b6e221f3.d2459","name":"Random","low":"0","high":"250","inte":"true","property":"payload","x":260,"y":180,"wires":[["5ecf9027.5ca1e"]]},
{"id":"8a1a5ba2.d9aac8","type":"fred out","z":"b6e221f3.d2459","name":"Send to FRED","server":"","client":"f696225a.476b4","x":640,"y":260,"wires":[]},
{"id":"e19210a8.08071","type":"comment","z":"b6e221f3.d2459","name":"2. Then make sure to DEPLOY this flow by clicking the button located in the top right","info":"","x":290,"y":80,"wires":[]},
{"id":"c8da9158.d8016","type":"comment","z":"b6e221f3.d2459","name":"1. Enable this flow by double clicking "Send Serial Data to the Cloud" above","info":"","x":260,"y":40,"wires":[]},
{"id":"bbf53c4f.7f9b7","type":"comment","z":"b6e221f3.d2459","name":"- Sending data to the cloud","info":"","x":110,"y":120,"wires":[]},
{"id":"99920171.11863","type":"comment","z":"b6e221f3.d2459","name":"see: http://www.brainboxes.com/faq/items/how-do-i-send-serial-data-from-the-bb-400-to-the-cloud","info":"","x":730,"y":440,"wires":[]},
{"id":"3833596e.b3a9f6","type":"mqtt out","z":"b6e221f3.d2459","name":"Send To AWS","topic":"Demo1","qos":"","retain":"","broker":"e0d52363.f231d","x":640,"y":320,"wires":[]},
{"id":"d09cf555.2e36c8","type":"wiotp out","z":"b6e221f3.d2459","authType":"d","qs":"false","qsDeviceId":"","deviceKey":"","deviceType":"","deviceId":"","event":"event","format":"json","qos":"","name":"Send to IBM","x":630,"y":380,"wires":[]},
{"id":"3bfdfbae.3d7b74","type":"serial-port","z":"","serialport":"/dev/ttySC0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"5","bin":"false","out":"interbyte","addchar":"","responsetimeout":"10000"},
{"id":"f696225a.476b4","type":"fred-client","z":"","endpoint":"Serial","private":false,"username":"","wholemsg":"true"},
{"id":"e0d52363.f231d","type":"mqtt-broker","z":"","name":"Send Data","broker":"localhost","port":"1883","tls":"","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}
]
You can import this flow to your BB-400’s Node-RED instance by clicking on the hamburger icon, Import, and then Clipboard. Below is the full flow for sending serial data to FRED, AWS and IBM:
Copy and paste the code into the prompt box, click okay and the flow should appear in your workspace. Adjust the node settings accordingly.
You can now send serial data from your BB-400 to the Cloud!
This tutorial can be followed and adjusted accordingly depending on the cloud service you would like to use.
Related FAQs
- How do I configure the BB-400’s Serial Port Jumpers?
- How do I connect my BB-400 to Amazon Web Services?
- How do I connect my BB-400 to Azure?
- How do I connect my BB-400 to FRED?
- How do I connect my BB-400 to IBM Cloud?
- How do I send serial data straight to the cloud?
- How to open, send data, and close serial Port on BB-400
- Using the BB-400 Serial Port in Node-RED
- What cloud services are available on the BB-400?