Cloud computing is the process by which information can be sent over the internet using a variety of different "pay-as-you-go" services. The BB-400 has a number of cloud services integrated, and this FAQ will explore one of these options: FRED. For more information regarding the other cloud services please refer to the FAQ What Cloud services are available on the BB-400?

What is FRED? 

Front End for Node-RED or FRED is a cloud service that manages [Node-RED](link to Node-RED FAQ) instances. It has been independently developed by Sense Tecnic, an IoT solutions provider.

It is possible to connect the BB-400's Node-RED instance to FRED and as Node-RED is already set up on the BB-400 by default, FRED is a great method in which to connect your device to the cloud.

Create Sense Tecnic and FRED account

Sign up for a Sense Tecnic account: https://users.sensetecnic.com/app/services

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-function-account-registration.png

Complete the user registration, select a plan, and create an account.

You will receive an email in order to verify your account, after this you can login to Sense Tecnic.

 

After verification you will arrive at this screen and clicking on FRED will load up the FRED Node-RED instance.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-initial-screen.png

Clicking on "Start Instance" will begin FRED.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-initial-node-red-screen.png

You will be presented with a default flow and a few examples.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-node-red-default-flow.png

FRED short features

In this example we are using FRED short, the free account on offer. FRED short includes a number of different features that will be explained briefly here.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-features.png

  1. The timer shows how long you have been running the FRED instance for. There is a 24 hour running time provided and after the 24 hours have been exceeded your flows will stop and you will have to log back in to FRED to restart your flows.
  2. An API key is provided for secure connections.
  3. A maximum of 50 nodes are available to use.
  4. FRED manages the nodes available to users and only allows installation of nodes that have been tested. There are a range of different nodes available, and they can be found by clicking on "Add and Remove nodes".

FRED nodes

FRED comes with 2 FRED nodes: input http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-input-node.png and output http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-output-node.png.

The BB-400's Node-RED instance comes with the FRED nodes installed by default, they can be found on the left-hand side under "input" and "output".

Now you can begin configuring your Node-RED flow to start sending data from the BB-400 to FRED. Below are a couple of example flows to send data from your BB-400 to FRED and to also receive data from FRED to your device's Node-RED instance.

Example: Flow to send IO status from BB-400 to FRED using REST

In this example we will set up a Node-RED flow to send the BB-400's IO status to FRED using FRED nodes.

Firstly, within the BB-400's Node-RED instance, drag a inject node http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-inject-node.png onto the workspace, double click on the node, and configure it to send data at regular intervals (we have chosen 1 second intervals), as follows:

 

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-inject-node-send-data.png

Next, underneath the 'function' nodes, drag a http request node onto the workspace.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-http-request-node.png

Change the Method to GET and the URL to the IP address of your BB-400 followed by ':9000/io'. 9000 is the port number for REST and /io is the path to obtain the IO status. Change Return to "a parsed JSON object" and finally name your http request node. Connect this node to the inject node.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-http-request-node-config.png

Next, we need to use a json node http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-json-node.png (can be found under function nodes) to convert the IO status to a json message. Connect this node to the http request node.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-json-node-config.png

Then add a FRED output node http://www.brainboxes.com/files/pages/support/faqs/How-do-i-connect-the-bb-400-to-fred-output-node.png and when you double click on the node the configuration looks like:

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-out-config.png

You can think of the endpoint as being an ID used to connect the FRED node on your BB-400's Node-RED instance, i.e. the client, to the specified FRED endpoint. When we create the FRED workflow in the next section, you will see that whatever you use as the endpoint on the client's Node-RED, needs to be the same on FRED's Node-RED so that both instances can communicate with one another.

Click on the pencil next to endpoint to add your username and in order to set up a secure connection, you can use the FRED API key (located on the left-hand side of FRED Node-RED) as an endpoint. Connect this node to the json node.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-out-config-api.png

Finally we need to add a debug node, http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-debug-node.png and connect it to the json node, so we can read the output from the flow.

 

The image below shows the flow for the BB-400's Node-RED:

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-send-io-status-bb-400-complete-flow.png

Setup FRED's Node-RED

Now we will set up FRED's Node-RED instance so that we can receive the IO status that is being sent from the BB-400's Node-RED.

This requires just 2 nodes, first we need to add a FRED input node

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-in-config.png

and use the same endpoint that we gave the FRED output node on the BB-400's Node-RED.

Finally we will add a debug node so we can read the output, and connect the 2 nodes together. The image below shows FRED's Node-RED flow to receive the IO status from the BB-400:

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-send-io-status-fred-complete-flow.png

Now we can click on deploy on both Node-RED instances to start the flows. You can see that the IO status is being sent from the BB-400's Node-RED

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-deploy-io-status-bb-400-flow.png

and is being received by FRED's Node-RED.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-deploy-io-status-fred-flow.png

If you adjust the IO status, for example within BB-400's webadmin page,

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-webadmin.png

you can see the change in the IO status being sent from the BB-400 to FRED.

Example: Flow to send message from FRED to BB-400's Node-RED

In this example we will send a message from FRED and we will receive the message within BB-400's Node-RED.

FRED Node-RED

Start in your FRED Node-RED workspace, and drag a inject node http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-inject-node.png onto the workspace. Edit the node so that the message is repeated at regular intervals.

 

Next add a function node http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-function-node.png and edit it so that we can send the message "hello" as follows:

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/Node-REDapp-watson-function-node-edit.png

Now we need to send the message using a FRED output node. We will name the endpoint "hello".

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-send-hello.png

Finally we will add a debug node to see the output of the flow.

BB-400 Node-RED

In the BB-400's Node-RED, drag a FRED input node and give it the same endpoint name. Add a debug node, connect the 2 nodes and click on deploy.

You will see the message "hello" being sent from FRED

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-send-data-to-bb-400-device-complete-flow.png

and received on BB-400's Node-RED.

http://www.brainboxes.com/files/pages/support/faqs/bb-400-faqs/How-do-i-connect-the-bb-400-to-fred-send-data-to-bb-400-fred-complete-flow.png

Export Flow

Below is the flow to send the IO status to FRED via REST. You can import the flow into your Node-RED instance, making sure you update your username.

[
    {"id":"bc75b9e3.257b68","type":"tab","label":"FRED: Send IO status REST","disabled":true,"info":""},
    {"id":"a5ede5bf.0114b8","type":"inject","z":"bc75b9e3.257b68","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":116,"y":86,"wires":[["aa64657b.d26c88"]]},
    {"id":"aa64657b.d26c88","type":"http request","z":"bc75b9e3.257b68","name":"GET IO status","method":"GET","ret":"obj","paytoqs":false,"url":"localhost:9000/io","tls":"","proxy":"","authType":"basic","x":296,"y":85,"wires":[["91ecefef.a656f"]]},
    {"id":"b3499883.6386a8","type":"debug","z":"bc75b9e3.257b68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":641,"y":54,"wires":[]},
    {"id":"91ecefef.a656f","type":"json","z":"bc75b9e3.257b68","name":"","property":"payload","action":"","pretty":false,"x":459,"y":84,"wires":[["b3499883.6386a8","e3293f40.1c5a7"]]},
    {"id":"e3293f40.1c5a7","type":"fred out","z":"bc75b9e3.257b68","name":"FRED out","server":"","client":"afa6f3d5.71de9","x":644,"y":130,"wires":[]},
    {"id":"afa6f3d5.71de9","type":"fred-client","z":0,"endpoint":"SendData","private":true,"username":"ADD","wholemsg":"true"}
]

 

 

In this FAQ we have learnt how to setup a FRED account, installed FRED nodes on the BB-400's instance of Node-RED, sent the IO status from the BB-400 to FRED, and finally we have sent a message from FRED to the BB-400.