This is a sample showing an Azure IoT Edge deployment for Windows IoT Core with a .NET Core C# console app to demonstrate SPI access. Additionally, it can do this in a way that can coordinate with the other Edge samples.
This app uses an Invensense MPU 9050 9-Degrees of Freedom motion processing unit connected through an SPI interface. It includes a 6 axis accelerometer very similar to the mpu6050 and a 3 axis magnetic compass. This is a common and inexpensive part that comes in many Arduino and other Maker starter kits. The app monitors the Z-Axis orientation and sends RightSideUp or UpsideDown Device-to-Cloud Telemetry Messages.
- The deployment.json file demonstrates container creation options for exposing PWM controllers into the container.
- Azure subscription with the following resources:
- IoT Hub
- Storage
- Container Registry
- Function App with the [EventHubHandler Example] (....\EventHubHandler\Readme.md) installed if you wish to exercise the device state mirroring.
- Hardware:
- An x64 Board with Windows 10 IoT Core version 1809 (Build 17763) installed and SPI driver support.
- Invensense MPU-9050
- Required packages to install
- Windows 10 SDK, version 1809
- .NET Core 2.2
- Azure IoT Hub Device SDK
- Either Visual Studio, VSCode, or the .NET Core dotnet.exe build environment
- cd to the directory container the .csproj
- dotnet publish
- Load the solution
- Right click on the cs project and select publish.
Unfortunately, this can't be done from a developer desktop since the IoT Core container cannot run on desktop. Instead it must be done on real hardware. After you have published your app do the following steps:
- Obtain an x64 machine with IoT Core installed.
- ssh into a command prompt on the machine.
- Install Docker on the IoT Core machine
- Download x64 docker.exe
- And x64 dockerd.exe
- Copy them to the IoT Core machine and put docker.exe in the path.
- from a command prompt run 'dockerd.exe --register-service'
- sc.exe start docker
- Copy your app to the machine
- Choose properties\dockerfile.dotnet or dockerfile.standalone depending on which kind of project you've built and copy that docker file to the machine
- Do 'docker login' with creds to your container registry.
- Do 'docker build -f < path to dockerfile> -t <registry/repo:tag> .' to build the image.
- docker push <registry/repo:tag>
The "preview" creds in the deployment.json are public read-only creds to the standard edge runtime modules. But, for the sample you must update the creds in the deployment.json file to provide access to your module container repository where you've stored the module you just built. And, you must update the image url in the module section with the correct url for your module image.
There are multiple ways to do this:
The recommended way to get started is VSCode with the Azure IoT Edge extension. But, for larger scale production deployments scripting with CLI is likely preferable.