This blog has been updated to reference a new GitHub repo and the most recent SDK changes.
This blog has been updated for recent SDK changes. The sample project and these instructions have been updated to utilize the CMAKE build process and the repository has been updated to support connecting to the Azure IoT Hub/IoT Central using a Device Provisioning Service (DPS).
The GitHub projects have been updated to support the VS Code development environment.
- What’s in the box?
Avnet Starter Kit Overview
- On-board sensors
- User Push Buttons
- LED Indicators
- Expansion interfaces
- Avnet Azure Sphere Starter Kits (Rev1 and Rev2)
- Product Links
- Getting Started
- Next steps
- Additional Azure Sphere Resources
Developing products with Microsoft Azure Sphere has just become a lot easier with a new Azure Sphere MT3620 Starter Kit hardware and application software examples from Avnet. This highly adaptable starter kit has a range of expansion interfaces and a production-ready MT3620 based module, that enables custom hardware requirements to be rapidly prototyped and applications developed for a certified module that scales for volume production.
The Starter Kit is available for order here.
We've put together four different blogs to showcase the Avnet Azure Sphere Starter Kit and how it can be used for your next IoT project . . .
- Blog #1: Simple non-connected demo (this blog)
- Reads on-board sensors every 5 seconds
- Reports sensor readings to the Visual Studio debug console
- Blog #2: Hands-on connected demo using a generic IoT Hub, DPS and Time Series Insights
- Must complete blog 1 demo before moving on to blog 2
- Configures IoT Hub and Time Series Insights Azure resources
- Manipulate the device twins
- Visualize data using Time Series Insights
- Blog #3: Hands-on, connected demo using IoT Central
- Must complete blog 1 before moving on to part 3
- Walks the user though configuring a IoT Central Application to create a custom visualization and device control application
- Advanced Blog: Hands-on, connected demo using IoT Central
- Must complete blog 1 before moving on to the Advanced Blog
- Adds OLED functionality to the Starter Kit
- Walks through using a real-time Bare-Metal M4 application to read the on-board light sensor
- Uses a IoT Central Template to quickly stand up a new IoT Central Application
This blog walks you through the following topics:
- Key features of the Avnet Azure Sphere Starter Kit
- How to set up tools, accounts, and your Azure Sphere device for development
- Detailed instructions for downloading, building, and side-loading a sample application that exercises the on-board sensors
What’s in the box?
- Starter Kit carrier board, fitted with a certified, production-ready Azure Sphere MT3620 module
- USB cable (Type-A to Micro-B)
- Quick Start Card with links to key documentation, application example code and other downloads
Avnet Starter Kit Overview
The Avnet Azure Sphere MT3629 Starter Kit is a platform for rapid prototyping highly secure, end-to-end IoT solutions utilizing Microsoft’s Azure Sphere MCU (MT3620). There are some great features on this board.
- 3-Axis accelerometer, gyro and temperature (LSM6DSO)
- Pressure/Barometric (LPS22HH)
- Ambient light sensor (ALSPT19)
User Push Buttons
There are two user buttons on the Starter Kit. You can use these for any purpose you like.
Software-defined User RGB LED, two single color LEDs are available, plus two pre-assigned LED status indicators
When we designed the Starter Kit we set out to design a flexible platform that allowed designers/developers to add additional hardware features as easily as possible. To meet this requirement we included some standard expansion interfaces.
MikroE Click Board expansion sockets
We included two Click board interfaces. MikroE currently has > 1,000 different Click boards. These modules use standard hardware interfaces and work with UART, SPI, I2C, or GPIO interfaces. There are click boards with input devices, output devices, actuators, and just about any sensor you can think of. MikroE turns out new Click boards at an incredible pace. Look for additional products on a weekly basis.
Grove expansion connector
In addition to the click board interfaces, we also included a single Grove expansion connector. Grove devices support either GPIO or I2C hardware interfaces.
We included two additional interfaces on the board that are unpopulated. Headers can be soldered to these locations.
OLED I2C interface
We included a standard I2C header interface for some of the inexpensive OLED displays on the market. To use this interface you need to solder a 4-pin through-hole header strip to the board. Here’s an example OLED display with the correct pin out: link.
We included access to UART signals under the mikroBUS #2 socket. You can solder a right-angle Pmod 2x6 socket connector to this site and have access to the signals from the edge of the board. Note that the Click sockets also have UART signals, but they lack the CTS and RTS UART signals.
Avnet Azure Sphere Starter Kits (Rev1 and Rev2)
In late 2020 Avnet released an updated Azure Sphere Starter Kit. You can see all the details for the updated kit here. The graphics below show both revisions for reference.
Rev1 callout and block diagram
Rev2 callout and block diagram
Press Release: http://avnet.me/mt3620-PR
Starter Kit Users Guide: http://avnet.me/mt3620-kit-UG
Product Brief: http://avnet.me/mt3620-kit-PB
Product Page: http://avnet.me/mt3620-kit
Intro Video: http://avnet.me/mt3620-kit-intro-video-ces2019
Marketing Presentation: http://avnet.me/mt3620-kit-slides
Starting with SDK release 19.11, the solution now includes support for developing Azure Sphere solutions in Linux and Windows (Visual Studio Code OR Visual Studio). Each of these three environments requires different SDKs. This blog only covers the details for developing Azure Sphere solutions using the Visual Studio Development environment.
The instructions for getting started with Azure Sphere are well documented by Microsoft on the Azure Sphere Documentation page here. My recommendation is to use the Microsoft documentation to get your device updated, claimed to your tenant, and connected to your Wi-Fi access point. Once you have all that completed, come back to this documentation to continue.
The diagram below shows the items you should complete on the web site before returning to this document.
Visual Studio 2019 Enterprise, Professional, or Community version 16.40 or later are all supported for Azure Sphere development.
Link for Visual Studio 2019
- 2019 Community edition Install Link: here
Visual Studio Azure Sphere Extension
Beginning with the 20.04 release Microsoft moved the Visual Studio Azure Sphere SDK extensions out of the Azure Sphere SDK installer and into a Visual Studio Extension that must be installed separately.
- Download the extension from here
- Locate the file and double click on it to install the extension
Note: We have seen this installer get downloaded as a *.zip file on some systems. If this happens to you simply replace the .zip extension with .vsix, then double click on the file to run the installer.
First things first . . .
By default Azure Sphere is a locked down system. You can’t load any applications to the device with a physical connection, if you could, bad actors who had physical access to the device could load whatever application they wanted to onto the device. That would be bad! So when Sphere devices are deployed into the wild, they are put into enable-cloud-test mode that adds the device into a device group so that the Azure Sphere Security Service (AS3) (in the cloud) knows what OS flavor (Retail or RetailEval) and user application(s) to send to the device over-the-air (OTA). Once in enable-cloud-test mode the ONLY way to change software on the device is OTA via AS3. You can read more about OTA software deployments here.
Devices ship in a locked state, so we need to “unlock” it. This is accomplished from the “Start à Azure Sphere à Azure Sphere Developer Command Prompt” command line interface (CLI) application. Go ahead and launch that application.
The first thing we need to do is to log into our Tenant. You should have setup a Tenant when you performed the install steps from the Microsoft documentation. We should have also claimed our device to our Tenant. If you did not complete these steps, please complete these tasks then come back. Since we want to change the accessibility of our device, AS3 will first authenticate us to the tenant, then when we execute the command to change the device from enable-cloud-test to enable-development mode, AS3 will confirm that our device belongs (or has been claimed) to our tenant. If not, then we won’t be able to change the status of the device. So if someone was to steal a deployed device, they could not do anything with the device outside its main purpose in life.
- Confirm that your device is connected to your PC using the supplied USB cable
- Azure Sphere CLI V1 and V2
- From the CLI enter the command > azsphere login
- A popup window will open asking for credentials. Use the Tenant credentials that you created in the install steps.
- Next, put the device into enable-development mode by entering the command
- Azure Sphere CLI V1 and V2
- > azsphere device enable-development
- Azure Sphere CLI V1 and V2
- You should see output similar to the graphic below . . .
If you get timeout errors, like the one below.
- Confirm that your device is plugged in
- Confirm that the USB drivers are installed correctly
- Disconnect from your company VPN (if connected)
- Azure Sphere uses a TAP driver that enables ethernet over Serial USB. Some VPN configurations disable a feature called "split tunneling." If split tunneling is disabled and your connected to your company VPN, then packets will not correctly route to your Azure Sphere device
- Navigate to the Microsoft troubleshooting page for additional help
Simple reference design
We’ve created an example project that demonstrates how to use some of the features on your new Azure Sphere Starter kit. The software implements the following features.
- Determine the BSSID address, Wi-Fi AP SSID and Wi-Fi Frequency
- Read X, Y, Z accelerometer data from the onboard LSM6DSO device using the I2C Interface
- Read X, Y, Z angular rate data from the onboard LSM6DSO device using the I2C Interface
- Read the temperature from the onboard LSM6DSO device using the I2C Interface
- Read the barometric pressure from the onboard LPS22HH device using the I2C Interface
- Read the temperature from the onboard LPS22HH device using the I2C Interface
- Read the state of the A and B buttons
- Send BSSID address, Wi-Fi AP SSID, Wi-Fi Frequency data, and application version to an IoT Hub or IoT Central Application
- Send X, Y, Z accelerometer data to an IoT Hub or IoT Central Application
- Send barometric pressure data to an IoT Hub or IoT Central Application
- Send button state data to an IoT Hub or IoT Central Application
- Control user RGB LEDs from the cloud using device twin properties
- Control optional Relay Click relays from the cloud using device twin properties
Pull project from GitHub
- Launch Visual Studio 2019 Click on the “Clone or check out code” link.
Enter the URL to the GitHub project into the form: https://github.com/Avnet/azure-sphere-samples
- Click on the “Clone” link
- You can also clone from the command line
- > git clone https://github.com/Avnet/azure-sphere-samples
Close the project and open the AvnetAzureSphereHacksterTTC/HighLevelApplication project
- When we cloned the repo using Visual Studio, it opened all the projects in the repo, we don't need them all open, it will just make working with the project more difficult
- Close Visual Studio 2019
- Open a new Visual Studio 2019 instance
- Select the "Open a local folder" option
- Browse to the location where you cloned the repo and click on the "Select Folder" button
Configure the project for your Starter Kit Revision
There are a few minor differences between the Avnet Starter Kit Rev1 and Rev2 boards; see this blog for all the details. Before we run the project, we need to update the project to select the hardware platform that you have.
- Open the CMakeLists.txt file
- Go down to line ~34
- If you have a Rev1 board, make sure line 34 is enabled and line 35 is commented out.
- If you have a Rev2 board, make sure line 35 is enabled and line 34 is commented out.
This graphic shows the file configured for a Rev1 board.
Run the Example Project
The project opens and you'll see a list of all the files in the project listed in the "Solution Explorer" window. Open the build_options.h header file by clicking on the filename.
This project has two different build configuration options for connectivity
- No cloud connectivity. This is the simplest configuration. The application runs and you can monitor sensor data from the Visual Studio debug window.
- IoT Hub connectivity. This configuration requires IoT Hub and Device Provisioning Service (DPS) resources in Azure . Once we have the Hub and DPS configured and the application connecting to the IoT Hub, we'll explore device twins and learn how we can use device twins to make application changes from the cloud. Last, we’ll walk through how to provision a Time Series Insights (TSI) application to visualize the sensor data.
No cloud connectivity
The build configurations are defined in the build_options.h file. Open that file and confirm that IOT_CENTRAL_APPLICATION is commented out. Look around line 6 for the #define pre-processor directive. This will build the no cloud connectivity configuration.
One of the really cool features of the Azure Sphere development environment is that to build, link, load, and run your embedded application all you have to do is click one button.
- First select the target to build from the pull down menu. Select the "GDB Debugger (HL Core)" option
- Build, link, sideload, and run the project by clicking on the “GDB Debugger (HL Core)” button at the top of the application.
You’ll see the build and link process, then a popup window stating that Visual Studio is starting the debugger on the target. If all goes well, you should see output similar to the text below. If there is a problem, the build output will tell you what’s wrong and hopefully provide a hint on how to correct the issue.
- The output window should open, if not open it with the shortcut keys Ctrl + Alt + o
- Select "Device Output" from the pull down control
That concludes the non-connected demonstration. This demo introduced you to the Azure Sphere Starter Kit and walked you though cloning an application that reads the the on-board sensors. The next tutorial will walk you through connecting your board to Azure, where you can control things on the board from the cloud, and graph/visualize telemetry data from the device.
Now that you're familiar with how to open and run an Azure Sphere application, move on to the next blog where we'll configure Azure resources and connect our device to the cloud.
Additional Azure Sphere Resources