(Use of A7 and M4 cores, all on-board sensors, ADC, OLED display, IoT Central dashboards, rules & actions for notifications and more...)

 

 

Note! Github repo update (8/08/2019)

Make sure you are using the latest version app_manifest.json files for the M4 and A7 applications! (These files have been updated in the Github repo)

 

Tutorial Introduction

 

This "advanced tutorial" is partitioned into two sections, enabling it to be worked on in two sessions:

  • 1st section focus is on configuring, building and running the M4 and A7 embedded applications (and viewing local output from these applications)
  • 2nd section walks the user through the capabilities and expansion options of the Azure IoT Central cloud application that the A7 embedded application is connected to

 

It consolidates what was covered in Part 1 and Part 3 of an earlier "Out-of-Box demo" three-part blog series (by Brian Willess) but adds shortcuts and a number of new capabilities to the overall application (see detail below).

This tutorial is intended to be used standalone (no dependency on previous material) but it is recommended that at minimum Part 1 of the earlier blog series be reviewed before starting.

 

 

Part 1

Intro to Avnet’s MT3620 Starter Kit with Non-Connected Application that Samples On-board Sensors and Reports Locally
(Periodic sampling of on-board sensors and reporting these measurements to Visual Studio IDE's output window)
http://avnet.me/mt3620-kit-OOB-ref-design-blog

Part 2

Azure IoT Hub, the Device Twin and Azure Time Series Insights
(Hands-on exercise creating an IoT Hub, manipulating the Device Twin and viewing sensor data using Azure Time Series Insights)
http://avnet.me/mt3620-kit-OOB-ref-design-blog-p2

Part 3

Azure IoT Central for Sensor Display and Remote Control of Device Outputs
(Introduction to using the different tabs in IoT Central, to create sensor visualizations and a device output control dashboard)
http://avnet.me/mt3620-kit-OOB-ref-design-blog-p3

 

 

    

Tutorial Purpose

  • Implement embedded applications on the A7 and one of the M4 cores to monitor on-board sensors, output user-friendly OLED display messages and communicate with cloud-based Azure IoT Central resources
  • Detail the steps for building the embedded application code for the A7 and M4 cores, plus accelerated implementation of a more comprehensive Azure IoT Central based visualization and control interface for the Starter Kit
  • Provide insights on the support of additional MT3620 device and Starter Kit features (use of an M4 real-time core, ADC inputs, optional OLED display and how to derive accurate elevation readings from measured pressure)

 

Tutorial Overview

Three separate applications work together to implement a system solution for sensor data collection, remote output control, local display, plus a rapidly implemented cloud-based reporting and control interface: 

  1. An Azure Sphere Arm Cortex-M4 (real-time) application
  2. An Azure Sphere Arm Cortex-A7 (high-level) application
  3. An Azure IoT Central Cloud-based application interface to the Starter Kit

 

The Avnet Azure Sphere Starter Kit “Out-of-Box” reference design embedded application code is re-used for the A7 application, but augmented with additional features:

  • OLED graphic display messages (8 screens of 5 lines each)
  • Additional telemetry information is sent to the IoT Central application (and custom text-box values from the IoT Central control interface, are received and processed on the board)
  • Ambient Light and barometric pressure measurements are processed and reported (pressure converted to elevation, and further guidance provided on how to increase the elevation accuracy)

 

A bare-metal companion application is executed on one of the Arm Cortex-M4 based RT cores to:

  • Periodically sample (once per second) the ADC inputs (Ambient Light Sensor and Click1, Click2 ADC pins) and
  • Post the ADC0 light sensor measurement for use by the high-level Arm Cortex A7 application

 

The combined A7 and M4 based application is cloned from the provided github repo, which contains both a HighLevelApp (targets the A7 core) plus an RTApp (targets an M4 core)
These two applications are built and programmed into the MT3620 device from two separate instances of the Visual Studio IDE.

 

============  Part 1: The M4 and A7 Embedded Applications  ============

 

Hardware Setup

 

Hardware Items Required

  • Avnet Azure Sphere MT3620 Starter Kit
    Product LinkProduct Link

 

 

 

Note: This advanced tutorial application will still function without the optional OLED Display ($6.99) and Relay Click board ($18.00), but to experience this in full, it is recommended that these optional add-on boards be purchased

The MikroE Click Relay board (p/n: MIKROE-1370) is available for purchase from Avnet / Newark / Farnell as well as catalog component distributors)

 

Fit an OLED Display to your Azure Sphere Starter Kit

  • Solder first the OLED pin labled SDA, check the display is aligned and level (adjust as needed then continue)
  • Solder the other remaining three pins

    

 

Software Setup

 

Prepare Azure Sphere SDK and the Starter Kit (may be skipped if previously done)


Instructions for getting started with Azure Sphere are well documented in the Microsoft Azure Sphere Documentation pages here.
 
Use those instructions to get your device updated, claimed to your tenant, and connected to your Wi-Fi access point.


The key steps are summarized below...

  1. Connect your Starter Kit to your development computer (and ensure this computer is connected to the internet!)
  2. From the Windows start menu launch the Azure Sphere Developer Command Prompt
  3. Check you have Azure Sphere SDK version 19.05 or above by entering the following command: azsphere show-version
    If a version earlier than 19.05 is reported, you need to download and install the latest SDK
  4. From the CLI command prompt, check the computer can communicate with the board by entering azsphere device show-attached
  5. If any issues are noted, you may need to login to your Azure Sphere Tenant again, by entering azsphere device login
  6. You should also make sure your device is in prep-debug mode by entering  azsphere device prep-debug
  7. Now using the regular CLI window, delete any previously loaded applications by means of the following command:
    azsphere device sideload delete
  8. Check that the Starter Kit is connected to Wi-Fi (and the internet) using the following command:
    azsphere device wifi show-status
  9. If the Starter Kit is not yet connected to a Wi-Fi access point, configure this as follows:
    azsphere device wifi add -s <SSID> -k <network key>

 

Install the debug driver for the real-time core

  1. If you skipped-over the previous section, connect the USB cable now from Starter Kit to your development computer (ensure also that this computer is connected to the internet!)
  2. Launch in administrator mode a new instance of the Azure Sphere Developer Command Prompt
    ie. Right-click the Azure Sphere Developer Command Prompt shortcut icon, then select More à Run as Administrator
  3. Check that your Starter Kit has successfully connected to Wi-Fi (see steps 8 and 9 above)
  4. At the [administrator mode] Azure Sphere command prompt, issue the following command:
    azsphere device prep-debug --EnableRTCoreDebugging
    (This command enables real-time capable core debugging. It must be run from administrator mode because it installs USB drivers for the debugger)
  5. After completion of this command, close the [administrator mode] CLI window as administrator privilege is no longer required.
    (Note: As best practice, you should always use the lowest privilege that can accomplish a task)

 

Pull the project folder from GitHub

The tutorial's project files are on GitHub. To clone this, the GitHub Extension needs to have been added to your Visual Studio IDE application
(If not already done, add this by going to the Visual Studio menu, click on “Tools / Extensions and Updates” then "Online" to select GitHub Extension for Visual Studio, then click Download button)

Clone the project to your local drive as follows:

  1. From the Visual Studio pull down menus, select “File / Open / Open from Source Control” to open a window titled “Team Explorer – Connect
  2. Under the GitHub heading, click the “Clone” link. An "Open from GitHub" form will open...
  3. Enter the following URL into the form  https://github.com/CloudConnectKits/Azure_Sphere_SK_ADC_RTApp  then click the Clone button

 

Provision the Azure IoT Central custom application

 

Part 2 of of this tutorial fully covers the Azure IoT Central Application. It is necessary however to provision your Starter Kit device in IoT Central at this stage, as connection authentication credentials are needed from the IoT Central application, prior to building the A7 embedded application

 

Use of the Starter Kit's Azure IoT Central Application Template

A pre-engineered application template will be used to efficiently create the necessary IoT Central cloud application.

  1. Use the following link to go directly into the IoT Central "Create an Application" screen, pre-populated with the required template
    https://apps.azureiotcentral.com/create?appTemplate=8ef6d061-425b-4d39-9048-244bbeb9a103
  2. The default "Trial" payment plan should be used (free for 7 days) 
  3. Enter an application name (make it descriptive but short, as this will form part of the unique URL for your dashboard)
  4. Enter your first name and last name
  5. Enter your Email and Phone Number (these are required fields)
  6. Select the Country/Region where you are located
  7. Once this form is completed, click the "Create" button

Note: If prompted to login, use your Azure credentials.  If you don’t have Azure credentials, you can sign up for a free account here.

 

Provision your Device in the IoT Central Application

  1. Allow a half minute or so for the new IoT Central application to be provisioned in Azure
  2. Click on Devices then click the "+" icon and select Real
  3. This will open the “Create New Device” form.
    - Device ID: Leave this set to the default.
    - Device Name: This field is pre-populated with the Device Template Name + Device ID. Change this to something more friendly.
  4. Click on the Properties tab, then edit two fields:
    - the Device Location (a Bing Maps compatible street address. Test this address in Bing Maps before entering here)
    - the Email Address (that you would like notifications to be sent to)
  5. Make sure to click Save after entering the location and email addresses
  6. Open Windows NotePad to facilitate the creation/editing of the unique connection string that will be used by the A7 embedded application to connect to IoT Central
  7. Click on the Dashboard tab. Tiles for the different measurements will display but without data. The map tile will display the geo location of your Starter Kit
  8. At top-right of this screen, click on Connect
  9. The “Device Connection” dialog box will open, with the details that we need plug-into the dps-keygen utility.
    We need Scope ID, Device ID, and Primary Key. Use the copy button at right-side of each of these fields to copy these values into the NotePad editor

Install dps-keygen utility and create the "connection string"

A one-time execution of a command-line tool called dps-keygen is required from Windows Powershell to generate the "connection string"

This connection string will be used by the A7 embedded application, to authenticate with the real device you've just added to your IoT Central application

  1. From Windows Powershell execute the following command
    npm i -g dps-keygen
  2. The result of this should be similar to what is shown below...
  3. If any difficulties are encountered with the dps-keygen installation, check the node.js version on your computer by entering node -v
    If the version of node.js is prior to v8 (or missing), then node.js and npm need to be installed/updated, after which this dps-keygen installation step must be repeated.
    The installation procedure for node.js and npm is well documented on the web in various places, eg.
    https://www.guru99.com/download-install-node-js.html
    https://blog.teamtreehouse.com/install-node-js-npm-windows
  4. The three values previously copied to Windows Notepad (from your IoT Central application's provisioned device), now need to be assembled into a specific format and supplied to dps-gen to create the connection string
  5. Plug-in these three values as follows (edit the command string in NotePad and then copy and paste to the PowerShell command-line and execute...):
    dps-keygen -si:<scope ID> -di:<device ID> -dk:<device primary shared key>
  6. Using parameters from my own IoT Central application, this command and it's results were as follows:

 

Visual Studio M4 Embedded Application

 

Build and run the M4 application

  1. Return now to the Visual Studio IDE. The cloned repository contains two projects located under a folder named Azure_Sphere_SK_ADC_RTApp
  2. From the main menu: Select File / Open / Folder, then select Azure_Sphere_SK_ADC_RTApp
  3. From the File menu: Select Open / CMake... then navigate into the IntercoreCommsADC_RTApp_MT3620_BMetal folder, then select CMakeLists.txt and click Open
  4. Open the app_manifest.json file. Under the "Capabilities" section, two items will be listed:
    1. AllowedApplicationConnections : lists the Component ID of the A7 application
    2. Adc : lists ADC0 (the first ADC channel only)
  5. From Visual Studio's CMake menu (if present), select Build / All
  6. If this menu is not present, in the IDE's Solution Explorer, right-click the CMakeLists.txt file, then select Build / All
    This step automatically performs the manual packaging steps. The output location of the Azure Sphere application appears in the Output window.
  7. On the toolbar, select the Select Startup Item drop-down menu (located where the Run button normally is), then select GDB Debugger (RTCore).
  8. Press F5 to start the M4 application with debugging... A number of openocd status messages will be displayed and the yellow USB activity LED will commence flashing rapidly, but there is no further confirmation that the application is running

     

 

Monitor the output of the M4 application [optional]

Note: This section describes a useful diagnostic output capability, but is not a requirement for completing the combined M4 and A7 application!

  1. With the M4 application now running, it is possible to monitor the raw ADC measurements periodically output by the application, via the M4-dedicated "IO0" UART on the MT3620
  2. To achieve this, three items are needed:
    1. Header pins soldered into the pin 1 and 3 positions of the unpopulated J11 site
    2. USB-to-Serial adaptor cable, needs to be fitted as follows:
      • RxD wire of USB-Serial Adapter connects to J11 pin 1 (IO0_TXD)
      • GND wire of USB-Serial Adapter connects to J11 pin 3 (GND)
    3. Windows serial terminal application (eg. Tera Term) needs to be launched, configured for the relevant COM port (set to 115200:8:N:1)
  3. Shade or shine a light onto the on-board ambient light sensor, to see the reported ADC values change...

      

(The M4 application may simply be left running while you proceed with edits and building of the A7 application in the other instance of Visual Studio that you will now open)

 

Visual Studio A7 Embedded Application

 

Edit the Azure Sphere Arm Cortex-A7 (high level) application

  1. Start another instance of Visual Studio for the A7 application: From this IDE's main menu, select File / Open / Folder, then again select Azure_Sphere_SK_ADC_RTApp
  2. This time select File / Open / Project/Solution, then navigate into the AvnetAzureSphereSK_OLED folder
  3. Double click on the AvnetStarterKitOLED.sln solution file to open the A7 project.
  4. This application was originally designed to support three different build configurations:
    • No cloud connectivity: The simplest configuration, the application runs and you can only monitor sensor data in the Visual Studio debug window.
    • IoT Hub connectivity: This configuration requires an Azure IoT Hub (with associated IoT Hub connection string) and it provisioned a Time Series Insights (TSI) application to visualize the sensor data and control device GPIOs from the cloud.
    • IoT Central connectivity: Leverages Microsoft’s IoT Central SaaS product to provide an IoT Central based easy to implement interface, to visualize sensor telemetry and control connected devices.
  5. For this exercise, the IoT Central configuration is required: Open the build_options.h file in this IDE's editor and check:
    • Line #5: must be enabled (ie. remove comment characters if present at line start of  #define IOT_CENTRAL_APPLICATION ).
    • Line #8: must be commented-out (ie. // #define IOT_HUB_APPLICATION )
  6. Items in two other files also need to be edited in the A7 project:
    • The connection string in connection_strings.h
    • The hostname string in app_manifest.json
  7. Open connection_strings.h in the A7 IDE's editor and note the expected format (shown in the comments) of the #define MY_CONNECTION_STRING statement:
    // #define MY_CONNECTION_STRING "HostName=iotc-xxxx....azure-devices.net;DeviceId=xxxx....;SharedAccessKey=xxxxx..."
  8. Using the connection string captured earlier in your temporary text file, edit this line to match the format shown in this #define comment
    Note! Make sure to finalize this #define in the temporary text file, with quotation characters enclosing the string, before pasting this into Visual Studio's editor!
    if you paste the string without quotes into Visual Studio's editor, spaces will get added within the string, which will invalidate the authentication
    When finished, save the edited connection_strings.h file in the Visual Studio IDE editor (ctrl+S)
  9. Open app_manifest.json file in the A7 IDE's editor, then copy into the “AllowedConnections” field, just the HostName string, extracted from the connection string in your temporary text file, then save the edited file (ctrl+S)

 

Build and deploy the Arm Cortex-A7 (high level) application

  1. From the Build menu select Build Solution
  2. Press F5 to start the A7 application with debugging.
  3. Check for Real Time Core: OK status on the OLED display (this confirms operation of the M4 application is and the inter-processor communication)
  4. Press Button-B on the Starter Kit to advance to the "network" screen which details the Wi-Fi network connection.
  5. Check the Wi-Fi access point SSID is reported, and that the measured RSSI (received signal strength) is acceptable

 

Monitor the output of the Arm Cortex-A7 (high-level) application

The A7 high-level application output is displayed in the Output window of this 2nd instance of Visual Studio.

Remote debugging from host 192.168.35.1

Version String: Avnet-Starter-Kit-reference-V1.0

Avnet Starter Kit Simple Reference Application starting.

OLED found!

LSM6DSO Found!

LPS22HH Found!

LSM6DSO: Calibrating angular rate . . .

LSM6DSO: Please make sure the device is stationary.

LSM6DSO: Calibrating angular rate complete!

Opening Starter Kit Button A as input.

Opening Starter Kit Button B as input.

Sending: Read-ADC-0

SSID: 2WIRE872

Frequency: 2457MHz

After a couple of seconds, a sequence repeats every 2 seconds, displayed in the output window that:

  • Reads one of the ADC channels,
  • Reports new measurements from the on-board sensors
  • Sends telemetry measurements to the Azure IoT Hub Client (and receives acknowledgement from that IoT Hub)

 

Sending: Read-ADC-2

Received 4 bytes.

 

LSM6DSO: Acceleration [mg]  : -14.6400, 12.0780, 1014.5520

LSM6DSO: Angular rate [dps] : 0.07, 0.00, 0.00

LSM6DSO: Temperature1 [degC]: 29.48

LPS22HH: Pressure     [hPa] : 985.02

LPS22HH: Temperature2 [degC]: 27.85

ALSPT19: Ambient Light[Lux] : 446.26

 

[Info] Sending telemetry: {"gX":"-14.6400", "gY":"12.0780", "gZ":"1014.5520", "pressure": "985.02", "aX": "0.07", "aY": "0.00", "aZ": "0.00", "light_intensity": "446.26", "altitude": "237.76", "temp": "29.48", "rssi": "-53"}

[Azure IoT Hub client] INFO: IoTHubClient accepted the message for delivery

[Azure IoT Hub client] INFO: Message received by IoT Hub. Result is: 0

Notes regarding the A7 application

  • Re-orientate the Starter Kit, then visually confirm the resulting changes for the reported accelerometer and gyro values
  • Cast a shadow on the ambient light sensor then verify that the ADC reports lower values
  • Check the Output window for the periodic Azure IoT Hub confirmations of the received telemetry messages  
  • Manually exercise what is displayed on the local OLED display by stepping through the eight available screens using Button-B
  • The A7 application is posting new values to the Azure IoT Central dashboard every 2 seconds. After the trial period, excessive data ingestion will incur charges, so make it your practice to stop the application when it is not in use

 

Viewing the OLED Display Screens

 

I2C INIT is the first screen that will be shown on the OLED display after start of the application.
This provides status of the I2C bus and STMicro MEMs sensors, as well as status of the Arm M4 Real Time Core application 

I2C Initialization (Displays:  I2C Bus status, LSM6DSO sensor status, LPS22HH  sensor status, Arm M4 Real Time Core application status)

I2C Initialization shows:

  • I2C Bus status
  • LSM6DSO sensor status
  • LPS22HH  sensor status
  • Arm M4 Real Time Core application status

 

>> Press Button-B on the Starter Kit to advance to the "network" screen which details the Wi-Fi network connection.

Note the reported RSSI value. This should be between -30 dBm (excellent!) and -70 dBm (the minimum for reliable operation)

The IoT Central dashboard display will only commence updating once a valid Wi-Fi network connection is established

Network: Displays: Wi-Fi Access Point SSID Name, Wi-Fi Frequency and Channel, Wi-Fi Received Signal Strength (dBm)

Network shows:

  • Wi-Fi Access Point SSID Name
  • Wi-Fi Frequency and Channel
  • Wi-Fi Received Signal Strength (dBm)

 

>> Press Button-B to advance to the "Cloud Twin" screen

Displays four custom messages updated from content of the four text boxes on the remote  IoT Central “Settings” screen

Cloud Twin shows:

  • Four custom messages whose content is defined remotely in the four OLED Line #1-4 text boxes of the IoT Central “Settings” screen

 

 

OLED Display Messages:

  • These are user-defined messages accessible from the IoT Central “Settings” tab, where four text boxes are provided for entering custom messages into the “cloud twin”
  • The cloud twin then updates these fields on the Starter Kit's OLED display screen
  • In the device twin and the A7 code, the field Names of these text strings are: OledDisplayMsg1 through OledDisplayMsg4 (each can have up to 21 characters)

 

>> Press Button-B to advance to the "Accelerometer" screen

Shows XYZ axis accelerometer measurements (in mg)

Accel. displays:

  • XYZ axis acceleration measurements (in mg)

 

>> Press Button-B to advance to the "Gyro" screen

Shows XYZ axis Gyro angular measurements (in dps)

Gyro. shows:

  • XYZ axis angular measurements (in dps)

 

>> Press Button-B to advance to the "Environmental" screen

Environmental shows LSM6DSO Temperature (C)  LPS22HH  Temperature (C) Barometric Pressure (hPa) Elevation (m)

Environ. shows:

  • LSM6DSO Temperature (C)
  • LPS22HH  Temperature (C)
  • Barometric Pressure (hPa)
  • Elevation (m)

 

>> Press Button-B to advance to the "Other" screen

Light Sensor and spare fields:  Ambient Light Level (Lux)

Light Sensor and spare fields

  • Ambient Light Level (Lux)
  • TBD 1 - 2 : Spare fields available for custom functions 

 

>> Press Button-B to advance to the Welcome/Logo screen

Logo / welcome screen

 

 

Part 1 Conclusion Summary

 

This section stepped you through the procedure to:

  • Provision and connect an Azure IoT Central application for your Starter Kit
  • Build and run an M4 embedded application that manages and reports ADC measurement of analog output from the ambient light sensor
  • Configure, build and run an A7 embedded application that:
    - reads measurements from I2C-connected on-board sensors
    - reports sensor measurements locally, as well as sending them in telemetry messages to the Azure IoT Central application
    - responds to local push-button input and writes status messages to an I2C-connected graphic OLED display
    - controls seven LED and two Relay output GPIOs, based on remote User Interface settings in the Azure IoT Central cloud application

 

The next section will walk you through details of different aspects of the Azure IoT Central cloud application


[ This concludes Part 1 of the Azure Sphere Starter Kit Advanced Tutorial ]

 

 

 

============  Part 2: The Azure IoT Central Cloud Application  ============

 

 

Exercising the Azure IoT Central Application

 

View the Azure IoT Central Dashboard

 

  1. Click on the Dashboard tab to view a pre-engineered "developer" dashboard visualization, showing a subset of the incoming Starter Kit measurement data
  2. This dashboard view may be user-customized, but this must be done in the Device Template view, ie.
    • select Device Templates from the sidebar, then select your AvnetStarterKit template. Make and save your desired edits, then
    • select Devices from the sidebar, followed by again selecting your real (not simulated) Starter Kit, to return to the device view...)

 

Exercise the Azure IoT Central Settings Interface

 

  1. Click on the Settings tab to view the pre-engineered Starter Kit control user-interface. Here you can control the state of:
    • five Starter Kit LEDs
    • two output relays (requires optional MikroE Click Relay board to be fitted in Click socket #1)
    • four lines of custom text messages that display on Starter Kit's OLED screen (requires optional OLED display to be fitted)
  2. Experiment with switching different LED and relay outputs ON and OFF.
    Note! The Update button (in top-left area of screen) must be pressed after changing setting, to send the updates to the Starter Kit
  3. Experiment also with entering different text strings into the four OLED message text boxes (up to 21 characters per line)
  4. Press Button-B on the Starter Kit to get to the Cloud Twin OLED screen where these custom text messages can be viewed.

 

View the Azure IoT Central Measurements (all incoming Telemetry)

 

  1. All sources of incoming telemetry data can be viewed by clicking on the Measurements tab
  2. Here you can experiment with viewing different subsets of telemetry data, by turning-on the corresponding traces (see sidebar controlled view settings below)
  3. If for example you want to reduce the range displayed by the ambient light sensor trace (default is 0 to 4095) instead to 0 to 768, this must be edited in the Device Template view

 

Configure Azure IoT Central Rules (Email Alerts)

 

  1. Next we will edit and enable a rule in the Device Template view, to send an Email Alert to your phone whenever Button-A is pressed
  2. Select Device Templates from the sidebar, then select your AvnetStarterKit template.
  3. Click on the Rules tab, then click on the Button_A_Rule
  4. Click on Enable Rule for all devices of this template
  5. Under Actions, click on the + button, then select Email
  6. Under Display name, enter a descriptive name for your rule (eg. Send an email alert to my phone!)
  7. Under To, enter your email address
  8. Under Notes, enter a description of what caused the rule to trigger (eg. Starter Kit button-A has been pressed!)
  9. Click on the Save button!
  10. Using the sidebar navigation, return now to the Device view
  11. Go to the Rules tab and inspect the rule settings, then test operation of the rule by pressing Button-A on the Starter Kit, then checking your incoming email
  12. In the same way, you can enable and use the Light_Sensor_Rule in the Device Template.
  13. The rule in this case is triggered by the light level falling below an ADC threshold value of 50.
  14. This is easily exercised on the Starter Kit: Simply cup your hand over the light sensor area of the board
  15. The shadowed light sensor will then result in ADC values below 50 and trigger this rule

 

Configure Azure IoT Central Rules (Webhook Actions)

 

  1. It's recommended that you experiment also with another of the available Rule Actions, the Webhook Action
  2. This action can be setup to respond to a separate new rule, or simply added as an additional response to an existing rule
  3. The Webhook mechanism enables the server-side application (IoT Central in this case) to automatically notify external systems when a rule is triggered in IoT Central.
  4. When the rule is triggered, this action will send an HTML POST to the callback URL that you have specified in the Webhook Action
  5. Operation of a webhook action can easily be tested, by creating a unique test URL at http://requestbin.net and then using this as the callback URL


  6. Now configure (in your Device Template) a rule triggered by Button-A, that causes an HTML POST to the test URL that you've just createdSave this rule in the Device Template and then return to the Device view

  7. Trigger the Rule by pressing Button-A on your Starter KitCheck for the HTML POST by opening another browser window.
  8. Address this to the main http://requestbin.net URL, then click your unique link now listed under History on right side of that page


  9. This will take you to the requestbin inspection view, where the history of all triggered Webhook HTML POSTs from your Starter Kit are listed...

 

 

Additional Notes:

 

Telemetry Message

1)     The A7 application sends the following parameters in the telemetry payload for display on the Azure IoT Central dashboard:

  • acceleration_mg[0], acceleration_mg[1], acceleration_mg[2],
  • angular_rate_dps[0], angular_rate_dps[1], angular_rate_dps[2],
  • pressure_hPa, light_sensor, altitude, lsm6dsoTemperature_degC

 

Elevation (Absolute Altitude)

This is derived from Barometric Pressure, using the following formula:

  • Where P0is the current “Sea Level” barometric pressure
  • A default P0value of 1013.25 hPa is used in this calculation resulting in a small error.
    For increased accuracy, the current P0 value for the Starter Kit's specific location should instead be sourced from an online weather service (eg. weather.com)
  • The procedure for achieving more accurate elevation results will be detailed in a future blog

 

 

Part 2 Conclusion Summary

 

This section walked you through different aspects of exercising the Azure IoT Central cloud application:

  • Viewing and editing the customized dashboard
  • Viewing all incoming telemetry measurements and events
  • Using the Settings dashboard to remotely control the Starter Kit LEDs, Click board relays and OLED display messages from the Sett
  • Configuring a rule for an email alert in response to a push-button event
  • Configuring a rule for an email alert in response to a light sensor threshold event
  • Configuring a rule for Webhook action in response to a push-button event


[ This concludes Part 2 of the Azure Sphere Starter Kit Advanced Tutorial ]

 

 

Next Steps

 

Certified Avnet Azure Sphere MT3620 modules!