Difference between revisions of "Mbed Connector Bridge"

From ESS-WIKI
Jump to: navigation, search
Line 17: Line 17:
  
 
*Log into the Azure Portal: [https://azure.microsoft.com https://azure.microsoft.com]
 
*Log into the Azure Portal: [https://azure.microsoft.com https://azure.microsoft.com]
*Search for “IoTHub”. Select the result and click Create.
+
*Search for “IoTHub”.
 +
*Select the result and click '''Create'''.
 
*Give your IoTHub a name.
 
*Give your IoTHub a name.
*Select the Free tier.
+
*Select the '''Free '''tier.
 
**Azure will create the IoTHub instance.
 
**Azure will create the IoTHub instance.
  
Line 27: Line 28:
  
 
*Open the IoTHub instance dashboard, and select your IoTHub resource.
 
*Open the IoTHub instance dashboard, and select your IoTHub resource.
*Click Settings.
+
*Click '''Settings'''.
*Select Shared Access Policies >> iothubowner.
+
*Select '''Shared Access Policies >> iothubowner.'''
 
*Go to Connection String - Primary Key, and select Copy to Clipboard.
 
*Go to Connection String - Primary Key, and select Copy to Clipboard.
  
Line 37: Line 38:
 
*Open DeviceExplorer.
 
*Open DeviceExplorer.
 
*Paste your connection string here.
 
*Paste your connection string here.
*Click Update. In the TTL (days) field, enter 365. Click Generate SAS.
+
*Click '''Update'''.
 +
*In the '''TTL (days)''' field, enter 365.
 +
*Click '''Generate SAS'''.
 
*Copy ALL contents of your SAS Token, and save them.
 
*Copy ALL contents of your SAS Token, and save them.
  
Line 48: Line 51:
 
*Open Firefox or Chrome, and go to: [https://192.168.99.100:8234 https://192.168.99.100:8234]
 
*Open Firefox or Chrome, and go to: [https://192.168.99.100:8234 https://192.168.99.100:8234]
 
*Accept the self signed certificate. The credentials are: Username: admin Password: admin
 
*Accept the self signed certificate. The credentials are: Username: admin Password: admin
*Enter the name of your IoTHub, and click Save.
+
*Enter the name of your IoTHub, and click '''Save'''.
*Enter the Connector API Token, and click Save.
+
*Enter the Connector API Token, and click '''Save'''.
*Enter your SAS Token, and click Save.
+
*Enter your SAS Token, and click '''Save'''.
*Click Restart.
+
*Click '''Restart'''.
  
 
Your IoTHub bridge is now configured. [[File:Azure bridge.png|center|bridge]]
 
Your IoTHub bridge is now configured. [[File:Azure bridge.png|center|bridge]]
Line 74: Line 77:
  
 
*Go to your mbed Connector dashboard.
 
*Go to your mbed Connector dashboard.
*In the left hand navigation pane, click My applications > Access keys. The Access Keys window opens.
+
*In the left hand navigation pane, click '''My applications > Access keys'''. The Access Keys window opens.
*Click Create new access key.
+
*Click '''Create new access key'''.
 
*Enter a name for your access key.
 
*Enter a name for your access key.
 
*Click Add. An API token is created.
 
*Click Add. An API token is created.
Line 82: Line 85:
 
== Creating an AWS IoT instance ==
 
== Creating an AWS IoT instance ==
  
*Log into the AWS Management Console.
+
*Log into the AWS Management Console. [https://console.aws.amazon.com https://console.aws.amazon.com]
*Click AWS IoT.
+
*Click '''AWS IoT'''.
[[File:aws_iot_in_menu.png|center|aws_iot_in_menu]]
+
 
 +
[[File:Aws iot in menu.png|center|aws_iot_in_menu]]
 +
 
 
*If you do not have one already, create an Instance:
 
*If you do not have one already, create an Instance:
[[File:aws_iot_get_started.png|center|aws_iot_get_started]]
+
 
*Open the Dashboard and click Test.
+
[[File:Aws iot get started.png|center|aws_iot_get_started]]
[[File:aws_iot_dashboard.png|center|aws_iot_dashboard]]
+
 
 +
*Open the Dashboard and click '''Test'''.
 +
 
 +
[[File:Aws iot dashboard.png|center|aws_iot_dashboard]]
 +
 
 
*Determining your AWS region
 
*Determining your AWS region
 
**Determine your AWS Region from the Test Console URL:
 
**Determine your AWS Region from the Test Console URL:
Line 125: Line 134:
  
 
*Go to the AWS dashboard: [link].
 
*Go to the AWS dashboard: [link].
*From the left hand menu, click Users.
+
*From the left hand menu, click '''Users'''.
 
*Select your IAM User.
 
*Select your IAM User.
*Select Security Credentials.
+
*Select '''Security Credentials'''.
*Click Create Access Key.
+
*Click '''Create Access Key'''.
[[File:aws_iot_existing_user.png|center|aws_iot_existing_user]]
+
 
 +
[[File:Aws iot existing user.png|center|aws_iot_existing_user]]
 +
 
 
*Save both keys.
 
*Save both keys.
**Click Show to see your Secret Access Key.
+
**Click '''Show '''to see your Secret Access Key.
[[File:aws_iot_keys.png|center|aws_iot_keys]]
+
 
*Click Close.
+
[[File:Aws iot keys.png|center|aws_iot_keys]]
 +
 
 +
*Click '''Close'''.
  
 
== Verifying administrator permissions on IAM ==
 
== Verifying administrator permissions on IAM ==
Line 139: Line 152:
 
Amazon’s Identity and Access Management service (IAM) users should have administrator permissions to create thing shadows, which you will need later.
 
Amazon’s Identity and Access Management service (IAM) users should have administrator permissions to create thing shadows, which you will need later.
  
*In your AAWS Management Console, click Users
+
*In your AAWS Management Console, click '''Users'''
 
*Select your user.
 
*Select your user.
*Click permissions.
+
*Click '''permissions'''.
*Check the AdministratorAccess policy box.
+
*Check the '''AdministratorAccess '''policy box.
*Click Attach Policy.
+
*Click '''Attach Policy'''.
[[File:aws_attach_policy.png|center|aws_attach_policy]]
+
 
 +
[[File:Aws attach policy.png|center|aws_attach_policy]]
  
 
== Configuring the bridge ==
 
== Configuring the bridge ==
Line 152: Line 166:
 
**On Mac OS X or Linux: please use the IP you got at the end of the Docker import script. Go to [https:// https://]<your container IP address>:8234.
 
**On Mac OS X or Linux: please use the IP you got at the end of the Docker import script. Go to [https:// https://]<your container IP address>:8234.
 
*Accept the self signed certificate.
 
*Accept the self signed certificate.
[[File:privacy_warning.png|center|privacy_warning]]
+
 
 +
[[File:Privacy warning.png|center|privacy_warning]]
 +
 
 
*Log in. Username: admin. Password: admin.
 
*Log in. Username: admin. Password: admin.
*Enter the mbed Connector API token. Click Save.
+
*Enter the mbed Connector API token. Click '''Save'''.
*Enter your AWS region. Click Save.
+
*Enter your AWS region. Click '''Save'''.
*Enter your AWS access key. Click Save.
+
*Enter your AWS access key. Click '''Save'''.
*Enter your AWS access key ID. Click Save.
+
*Enter your AWS access key ID. Click '''Save'''.
*Click Restart at the top.
+
*Click '''Restart '''at the top.
[[File:bridge_configuration.png|center|bridge_configuration]]
+
 
 +
[[File:Bridge configuration.png|center|bridge_configuration]]
  
 
Your AWS bridge is now configured! You can restart your device and see messages coming into the AWS IoT via Amazon’s MQTT Client.
 
Your AWS bridge is now configured! You can restart your device and see messages coming into the AWS IoT via Amazon’s MQTT Client.
Line 168: Line 185:
  
 
*Go to the AWS dashboard: [link]
 
*Go to the AWS dashboard: [link]
*In the left-hand menu, click Registry > Things.
+
*In the left-hand menu, click '''Registry > Things'''.
 
*You should see your device listed as a Thing.
 
*You should see your device listed as a Thing.
[[File:aws_iot_things.png|center|aws_iot_things]]
+
 
*In the left-hand menu, click Test.
+
[[File:Aws iot things.png|center|aws_iot_things]]
 +
 
 +
*In the left-hand menu, click '''Test'''.
 
**Result: This opens the MQTT dashboard:
 
**Result: This opens the MQTT dashboard:
[[File:aws_iot_test_dashboard.png|center|aws_iot_test_dashboard]]
+
 
 +
[[File:Aws iot test dashboard.png|center|aws_iot_test_dashboard]]
 +
 
  
  
 
*Subscribe to the observation topic
 
*Subscribe to the observation topic
  
1. In the subscription topic field, enter: mbed/notify/#. 2. Click Subscribe to this topic.
+
1. In the subscription topic field, enter: mbed/notify/#.
 +
 
 +
2. Click '''Subscribe to this topic'''.
  
 
*Subscribe to the command-response topic
 
*Subscribe to the command-response topic
  
1. In the subscription topic field, enter: mbed/cmd-response/#. 2. Click Subscribe to this topic.
+
1. In the subscription topic field, enter: mbed/cmd-response/#.
 +
 
 +
2. Click '''Subscribe to this topic'''.
  
 
*Result:
 
*Result:
[[File:aws_iot_subscriptions.png|center|aws_iot_subscriptions]]
+
 
 +
[[File:Aws iot subscriptions.png|center|aws_iot_subscriptions]]

Revision as of 05:06, 4 May 2018

Azure

Introduction

This tutorial explains how to connect your mbed device to Azure IoTHub, using mbed Device Connector and ARMs prototype IoTHub Connector Bridge.

Upon completion, you will be able to see and interact with your mbed devices from within the Azure IoTHub ecosystem.
azure overview

Create your mbed Device Connector access key

  • Open the mbed Cloud Connect dashboard and log in: https://connector.mbed.com
  • In the left-hand menu, click Access Keys.
  • Click Create New Access Key, and give it a name
  • Save the key.

Create your Azure IoTHub instance

  • Log into the Azure Portal: https://azure.microsoft.com
  • Search for “IoTHub”.
  • Select the result and click Create.
  • Give your IoTHub a name.
  • Select the Free tier.
    • Azure will create the IoTHub instance.
azure iothub

Get your IoTHub Connection String

  • Open the IoTHub instance dashboard, and select your IoTHub resource.
  • Click Settings.
  • Select Shared Access Policies >> iothubowner.
  • Go to Connection String - Primary Key, and select Copy to Clipboard.
azure iothub string
azure iothub primary string

Create your SAS Token with DeviceExplorer

  • Open DeviceExplorer.
  • Paste your connection string here.
  • Click Update.
  • In the TTL (days) field, enter 365.
  • Click Generate SAS.
  • Copy ALL contents of your SAS Token, and save them.
azure sas token

Configure your IoTHub bridge

Your container IP address is: 192.168.99.100.

  • Open Firefox or Chrome, and go to: https://192.168.99.100:8234
  • Accept the self signed certificate. The credentials are: Username: admin Password: admin
  • Enter the name of your IoTHub, and click Save.
  • Enter the Connector API Token, and click Save.
  • Enter your SAS Token, and click Save.
  • Click Restart.
Your IoTHub bridge is now configured.
bridge

Check that it all works

  • Open DeviceExplorer
  • Under the Management tab you should see your device listed
  • Under Data you should see output (if you do not see output, shake your device to generate some accelerometer readings).
  • Click monitor to start monitoring.

AWS

Introduction

We’re going to use mbed Connector and ARM’s prototype AWS IoT Connector Bridge to connect an mbed device to AWS IoT. We’ll:

  • Create an instance of ARM’s prototype AWS IoT Connector Bridge and bind it to your Amazon and Connector accounts.
  • Explore the device’s data telemetry with Amazon’s web-based MQTT client.

Creating an mbed Connector API token

  • Go to your mbed Connector dashboard.
  • In the left hand navigation pane, click My applications > Access keys. The Access Keys window opens.
  • Click Create new access key.
  • Enter a name for your access key.
  • Click Add. An API token is created.
  • Save the token.

Creating an AWS IoT instance

aws_iot_in_menu
  • If you do not have one already, create an Instance:
aws_iot_get_started
  • Open the Dashboard and click Test.
aws_iot_dashboard
  • Determining your AWS region
    • Determine your AWS Region from the Test Console URL:

Your URL should look something like this: https://console.aws.amazon.com/iotv2/home?region=us-east-1#/test

  • Make a note of your “region” parameter value
    • In the above example, the AWS Region is us-east-1.

Create your AWS Access Key and ID (New IAM User)

aws_iot_user
  • When the new IAM User is created, you will be shown your keys.
    • Click Show to see your Secret Access Key.
  • Save both keys.
aws_iot_keys
  • Click Close.

Create your AWS Access Key and ID (Existing IAM User)

If you have an existing IAM User, then you can simply create a new AccessKey for that user:

  • Go to the AWS dashboard: [link].
  • From the left hand menu, click Users.
  • Select your IAM User.
  • Select Security Credentials.
  • Click Create Access Key.
aws_iot_existing_user
  • Save both keys.
    • Click Show to see your Secret Access Key.
aws_iot_keys
  • Click Close.

Verifying administrator permissions on IAM

Amazon’s Identity and Access Management service (IAM) users should have administrator permissions to create thing shadows, which you will need later.

  • In your AAWS Management Console, click Users
  • Select your user.
  • Click permissions.
  • Check the AdministratorAccess policy box.
  • Click Attach Policy.
aws_attach_policy

Configuring the bridge

  • Open Chrome or Firefox:
    • On Windows: go to https://192.168.99.100:8234.
    • On Mac OS X or Linux: please use the IP you got at the end of the Docker import script. Go to [https:// https://]<your container IP address>:8234.
  • Accept the self signed certificate.
privacy_warning
  • Log in. Username: admin. Password: admin.
  • Enter the mbed Connector API token. Click Save.
  • Enter your AWS region. Click Save.
  • Enter your AWS access key. Click Save.
  • Enter your AWS access key ID. Click Save.
  • Click Restart at the top.
bridge_configuration

Your AWS bridge is now configured! You can restart your device and see messages coming into the AWS IoT via Amazon’s MQTT Client.

Putting it all together

Connecting to the device

  • Go to the AWS dashboard: [link]
  • In the left-hand menu, click Registry > Things.
  • You should see your device listed as a Thing.
aws_iot_things
  • In the left-hand menu, click Test.
    • Result: This opens the MQTT dashboard:
aws_iot_test_dashboard


  • Subscribe to the observation topic

1. In the subscription topic field, enter: mbed/notify/#.

2. Click Subscribe to this topic.

  • Subscribe to the command-response topic

1. In the subscription topic field, enter: mbed/cmd-response/#.

2. Click Subscribe to this topic.

  • Result:
aws_iot_subscriptions