How do I connect my BB-400 to Amazon Web Services?

FAQs

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 several cloud services integrated, and this FAQ will explore one of these options: Amazon Web Services (AWS). For more information regarding the other cloud services please refer to the FAQ: What cloud services are available on the BB-400?
NB: This FAQ was written using a BB-400 running Debian GNU/Linux 10 (Buster) and assumes a basic understanding of Node-Red.

What is Amazon Web Services (AWS)?

AWS is a cloud service provided by Amazon. AWS includes an IoT (Internet of Things) Core that allows you to connect your devices to AWS, and also an MQTT client connection to connect Node-Red to AWS. As Node-Red is already set up on the BB-400 by default, AWS is a great method in which to connect your device to the cloud.

Please find at the download link below the Node-Red example flows created for AWS throughout this FAQ:

Downloads
AWS Flow Example

Create your AWS account

First, we need to create an AWS account by going to https://aws.amazon.com and click on “Sign In”:

aws landing-page image

Click on “Create a new AWS account”:

AwsRegisterimg

Fill in your details:

contactinfo
billinginfo

Select a support plan:

paymentplanimg

You have set up your AWS account !

successimg

Once registered, login as Root user:

signinimg

You will be presented with the AWS Management console:

img

Register a device

Having created an AWS account, we are ready to register a device. Search for IoT Core in the search bar, then click on “IoT Core”:

img

On the side panel click on “Manage” → All devices → “Things” → “Create Things”.

img

Click on “Create a single thing” (AWS defines a device as a “thing”) and follow the steps provided. We will name our “thing” as the last 4 digits of the MAC address of our BB-400 and click next. Select the “No shadow” option for now:

img

The next page is about certificates, click on “Auto-generate a new certificate option”. You will be presented with another window asking you to attach policies:

img

Click on Create policy. A policy provides specified permissions to your device. Give your policy a name. Ensure that in the policy effect select: “Allow”, in the Policy action box type: “*”, and Policy resource type: “*”

img

Going back to the previous Tab, click on “Create things”. You will be presented with a window pop-up to download certificates and keys.

img

Download the Device certificate, Public key file, Private key file & Root CA files into a known folder as you will need this later on in Node-Red. Next, click “Done”. You have successfully created your first Thing!

Setup Node-Red to send BB-400’s IO status to AWS.

Now we’ll set up our Node-Red instances so that we can connect to AWS, to send and receive data.

First, we will use an inject node img to send data. Double-click to configure it as follows:

img

Next, we will use an HTTP Request node img to send and return a response. Configure it as follows:

img

Now we will configure the MQTT output node img to send data to AWS. Double-clicking on the node gives us options for the server name and topic.

On this menu leave the server name blank (we will add it to the next menu), “Qos” and “Retain” values should also be left as blank. Give it a topic name and then click on the pencil next to the server name for further configuration.

NB: The TCP port number is always set to 8883.

img

 

img

Give the node a name. The Server can be found by navigating to “settings” on the side panel on AWS at the bottom.

 

img

 

Copy the “Endpoint” and paste it as the server in Node-Red. Set the port number to “8883”, keep the client ID blank, and enable TLS connection. Click on the pencil to upload the certificates. Upload the device certificate, private key, and CA certificate that you downloaded earlier from AWS. Click “update” and the node is ready to connect to AWS.

img

Finally, add a “debug node”. img Give it a name and click “done”.

img

Connect each of the now configured nodes as shown below. The flow is ready to be deployed and you should be connected to AWS.

img

Sending BB-400 IO state from Node-Red to AWS

Navigate to IoT Core and click on “Test”. This can be done by navigating to the side pane → Test → MQTT test client.

img

Enter in the “Subscribe to a topic”, the topic name you gave the MQTT out node in Node-Red. Click on “Subscribe” and you should see the IO status events being sent to the MQTT client after redeploying.

In Node-Red:

img

In AWS MQTT test client:

img

Send a message from AWS to Node-Red

You can also set up a flow to receive events from AWS.

 

We will use a “MQTT input node” img instead, and set it up with the same settings as before. Give it a Topic name. If you named your previous server, you should be able to click on this in the drop-down. We will use a debug node for the output.

img

Node-Red flow:

img

Heading back to AWS MQTT client, click “Publish to a topic” → Enter the topic name you gave the MQTT in Node-Red. In the message payload, edit the message to your liking → click on “Publish”.

img

You should be able to see the message (“Hello from AWS IoT console”, in this case) in the debug message in Node-Red:

img

Sending serial data to the cloud.

The example below demonstrates using one of our ES-511 devices to send serial data to AWS. We’ll start by using an “inject node” to send a string and another to send an integer. Configure the nodes as follows:

String Inject Node:

img

Integer Inject Node:

img

Next, we’ll use a “random” node img to generate an integer between 1 and 100. Configure it as follows:

img

Configure the “TCP request” node as shown below. Ensure your ES device is set to RawTCP and has a physical loopback on the serial port. The “Server” is the IP address of your ES device.

img

Configuring a loopback test:

img

Please note for RS422/485 pins out may vary.

We’ll configure three debug nodes to monitor the sent string, sent integer, and received payload. Name them respectively.

Example of sent string debug node:

img

Now make a copy of the “MQTT Out node” used previously and integrate it into the flow as shown below:

img

After triggering the inject nodes, the expected output is as follows:

Node-Red:

img

AWS:

img

Sending IO state to the cloud

In this example, we’re generating an ASCII command from within Node-Red, passing it to an ED device, and sending the ED’s response to the cloud. Configure the nodes as follows:

Inject Node:

NB: the repeat interval can be adjusted to your preference.

img

Function Node:

img

TCP Request Node:

img

Sent ASCII Debug Node:

img

Received Hexadecimal Response debug node:

img

Join the nodes as shown below:

img

Examples of output expected after triggering the inject node:

Node-Red:

img

AWS:

img

In this FAQ we have explained how to create an AWS account, connect your device to AWS, configure certificates and a policy, and finally how to setup Node-RED to send and receive the BB-400’s IO status.

FAQs