Introduction
This blog documents my process for developing an Azure Sphere IoT device used to monitor the meat on my BBQ. I'm developing this project along with the 3-part Azure Sphere Development Webinar. Be sure to sign up or watch the recorded webinar sessions.
Session #1 (1/20/22): Introduction to the DevX Azure Sphere software acceleration library
Session #2: (2/3/22) Develop Azure RTOS real-time applications for Azure Sphere
Session #3: (2/17/22) Develop an IoT Cloud solution with Azure IoTCentral
Requirements
Every engineering project needs a requirements document, I've captured high level requirements here.
Implementation
This implementation can be reviewed in the Avnet DevX Examples Repo
Phase #1 (implement and test my applications device twins)
Task #1: Start a new Azure Sphere High Level Project
My first task is to start a new project.
- Fork the DevX Examples Repo
- Pull my Forked Repo
- Create a Branch for my project (GitHub documentation on working with branches)
- Copy the starter_app folder and rename it to avnet_bbq_monitor
- Rename the project by modifying the app_manifest.json and CMakeLists.txt files
By forking the DevX Example Repo, I can create a branch for all my development work. Once I've completed my application, I'll open a pull request (PR) to have my project pulled into the public repo for the community to leverage.
- Task #1 Video walkthrough (9-minutes)
Task #2: Connect my application to IoTCentral
Next I want to configure my high level application to connect to my IoTCentral application. I'm creating this project as part of the Azure Sphere Webinar 3-part series where we've already worked through Lab-5 (Connecting our device to IoTCentral). I'll use the same app_manifest.json settings for this application and verify that my application connects before moving to the next step.
- Enable the call to connect to IoTCentral
- Copy my app_manifest.json setting into the application
- Verify my application connects to IoTCentral
- Task #2 Video walkthrough (3-minutes)
Task #3: Create my Device Twins
Next let's add the device twins to the application and start the IoTCentral device template to drive and test the device twins. I'll use my requirements document for the details and my knowledge of the DevX libraries to knock this out.
For each device twin I need to . . .
- Add a forward declaration for the device twin handler
- Add a DevX binding for the device twin
- Add the device twin binding to the device twin binding array by reference
- Implement the device twin handler
- Add the device twin to my IoTCentral device template as a property (remember device twins are called properties in IoTCentral)
- Add an IoTCentral view so I can test my device twins
- Task #3 Video walkthrough (12-minutes)
Phase #2 (Add Hardware Support)
Task #1: Add support for the ThermoCLICK board
I'm going to leverage one of the Avnet AzureRTOS real-time application to my project that already supports the ThermoCLICK.
The steps to add this support . . .
- Buy the Thermo CLICK board from MikroE ($29)
- Buy a K-Type ThermoCouple Probe that I can use on the BBQ ($24)
- Download the pre-built AvnetThermoClick-Rev2-Click1-App1-V.1.1.imagepackage binary package from the Avnet AzureRTOS repo
- Open the ThermoClick application README.md from the repo
- Follow the instruction in the README.md file . . .
- Sideload the binary package onto my device
- Update my high-level application with all the required code as detailed in the README.md file
- Follow the instruction in the README.md file . . .
- Add a periodic timer to my high-level app to request temperature sensor data from the real-time app every 10 seconds
- Task #1 video walkthrough (15-minutes)
Task #2: Create a new custom hardware definition file
All high-level Azure Sphere applications leverage hardware definition files to identify and map hardware signals to the target hardware. You can read all about this scheme here. Please watch the video below to see a practical guide to creating these files.
- Create a custom hardware definition file for my BBQ Monitor
- Video walkthrough (9-min)
Task #3: Add support for the BuzzCLICK board
The Buzz click uses a PWM interface, and the DevX library supports PWM!
The Steps to add this support . . .
- Buy the Buzz CLICK board from MicroE ($9)
- Add the PWM interface using DevX
- Add logic drive the click board
- Video walkthrough (7-min)
Task #4: Add support for the RGB LED
The RGB LED uses GPIO interfaces.
The Steps to add this support . . .
- Create GPIO bindings for each element of the RGB LED
- Add the bindings to the gpio_binding[] array
- Add logic to drive the LEDs on/off
- Video walkthrough (4-min)
Task #5: Add support for the OLED display
I'll use a SSD1306 based OLED display for my solution. It's a I2C sensor
The Steps to add
- Buy the OLED display, make sure your OLED display matches the signals on the Starter Kit OLED header
- Add the DevX I2C binding
- Define your screen displays and implement them
- Video walkthrough (10-min)
.
Phase #3 (Add Cloud Support)
Things are moving right along with my BBQ Monitor. At this point all the hardware interfaces are implemented and tested. Next I need to add data up to my IoTCentral application.
Task #1: Add Telemetry Support
The steps to add telemetry support
- Define a message buffer to hold the telemetry data as it's constructed
- Define message properties to send with my telemetry
- Construct the telemetry using one of the methods described in the DevX review
- Send the telemetry with the dx_azurePublish()
- Video walkthrough (5-min)
More to come . . .
At this point my MT3620 applications meet the requirements I defined. However, I plan to add some production features in the coming weeks . . .
- Deferred update support
- Hardware watchdog support
The Reward
Video Demo (1-min)