View on GitHub

azure-iothub-instructions

Getting started guide for Azure IoT Hub on B&R APCs

Run a simple JavaScript(Node) sample on B&R APC device running B&R Linux

Table of Contents

Introduction

About this document

This multi-step process includes:

Prepare

Before executing any of the steps below, read through each process, step by step to ensure end to end understanding. You should have the following items ready before beginning the process:

Step 1: Sign Up To Azure IoT Hub

Follow the instructions here on how to sign up to the Azure IoT Hub service.

As part of the sign up process, you will receive the connection string.

Step 2: Register Device

In this section, you will register your device using DeviceExplorer. The DeviceExplorer is a Windows application that interfaces with Azure IoT Hub and can perform the following operations:

To run DeviceExplorer tool, follow the configuration strings as described in Step1:

Steps:

  1. Click here to download and install DeviceExplorer.

  2. Add connection information under the Configuration tab and click the Update button.

  3. Create and register the device with your IoT Hub using instructions as below.

    a. Click the Management tab.

    b. Your registered devices will be visible in the list. In case your device is not there in the list, click Refresh button. If this is your first time, then you shouldn’t retrieve anything.

    c. Click Create button to create a device ID and key.

    d. Once created successfully, device will be listed in DeviceExplorer.

    e. Right click the device and from context menu select “Copy connection string for selected device”.

    f. Save this information in Notepad. You will need this information in later steps.

Not running Windows on your PC? - Please follow the instructions here to provision your device and get its credentials.

Step 3: Build and validate the sample using Node JS client libraries

This section walks you through building, deploying and validating the IoT Client SDK on your device running a Linux operating system.

3.1 Load the Azure IoT bits and prerequisites on device

3.2 Build the samples

3.3 Run and Validate the Samples

In this section you will run the Azure IoT client SDK samples to validate communication between your device and Azure IoT Hub service. You will send messages to the Azure IoT Hub service and validate that IoT Hub has successfully receive the data. You will also monitor any messages send from the Azure IoT Hub to client.

Note: Take screen shots of all operations, like sample screen shots, performed in below sections. These will be needed in Step 4

3.3.1 Send Device Events to IOT Hub:

  1. Launch the DeviceExplorer as explained in Step 2 and navigate to Data tab. Select the device name you created from the drop-down list of device IDs, click Monitor button.

    DeviceExplorer_Monitor

  2. DeviceExplorer is now monitoring data sent from the selected device to the IoT Hub.

  3. Run the sample by issuing following command:

    node ~/azure-iot-sdk-node/device/samples/simple_sample_device.js
    
  4. Verify that data has been successfully sent and received. If any, then you may have incorrectly copied the device hub connection information.

  5. DeviceExplorer should show that IoT Hub has successfully received data sent by sample test.

    Simple_Sample_result_DeviceExplorer

3.3.2 Receive messages from IoT Hub

  1. To verify that you can send messages from the IoT Hub to your device, go to the Message To Device tab in DeviceExplorer.

  2. Select the device you created using Device ID drop down.

  3. Add some text to the Message field, then click Send button.

  4. You should be able to see the command received in the console window of the client sample.

    MessageSend_terminal

Step 4: Troubleshooting

Please contact engineering support on support@br-automation.com for help with troubleshooting.

Reference: Some information in this document is obtained from here.