Mbed Connector Bridge

From ESS-WIKI
Jump to: navigation, search

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

Mbed Cloud Portal
  • Go to API keys
Go to API keys
  • Create API Key in Mbed Cloud
Create API Key in Mbed Cloud
  • Copy API Key
Copy API Key

Create Azure IoTHub and mbed bridge container instance

  • Custom deployment from Advantech Marketplace and login Azure Portal
  • Enter Resource Group and select Location
  • Click Purchase
custom_deploy
  • Wait deployment finial then go to your deploy resource group
resourcegroup
  • Select bridge-iothub and get container IP address
bridge-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

  • Install the latest version of Microsoft Device Explorer. (https://github.com/Azure/azure-iot-sdk-csharp/releases)
  • 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

  • Open Firefox or Chrome, and go to: https://[container IP address]:8234
  • Accept the self signed certificate. The credentials are: Username: admin Password: admin
  • mds_api_token: Enter the mbed Cloud API Key/Token, and click Save.
  • iot_event_hub_name: Enter the name of your IoTHub, and click Save.
  • iot_event_hub_sas_token: Enter your SAS Token, and click Save.
  • mds_address: Enter the right API endpoint api.us-east-1.mbedcloud.com and click Save.
  • Click Restart.
Your IoTHub bridge is now configured.
mbed-bridge_web1

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.
mbed_bridge_iothub



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.

Create your mbed Device Connector access key

Mbed Cloud Portal
  • Go to API keys
Go to API keys
  • Create API Key in Mbed Cloud
Create API Key in Mbed Cloud
  • Copy API Key
Copy API Key

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.

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