Recently I developed a new Azure Sphere demo for our sales team in Asia and thought I would share it with the community.  The project is simple, I added a MikroE Temp&Hum 13 Click Board (with a TE HTU21D sensor) to an Avnet Azure Sphere Starter kit and developed an application to read the sensor and send the data to Azure.


This project could be applied to across various industry use-cases. For example, you can monitor telemetry and enable predictive maintenance for following scenarios:

  • Inventory management : Monitor environmental conditions in a warehouse that stores temperature/humidity sensitive materials
  • Energy Saving: Monitor public locations to make sure that the heating/cooling equipment is working as expected
  • Maintenance Operations: Monitor a remote cabin or vacation home to make sure the heating is working in the winter so you don't freeze the pipes


If any temperature or humidity threshold is exceeded the cloud solution, in this case IoTConnect, could send an alert to inform the service department that there was an issue.


Bill of Materials


  1. Avnet Azure Sphere Starter KitAvnet Azure Sphere Starter Kit
  2. MikroE Temp-Hum13 click board


Demo Build


This is a pretty easy build, just plug in the click board to either of the mikro BUS sockets.  The click board uses I2C (ISU2) and the I2C ISU2 signals are shared across both mikro BUS sockets. Just make sure you insert the click board with the sensor at the edge of the Starter Kit, like in the picture above.   You should also be able to use a HTU21DHTU21D Grove device, but I have not tested with that hardware.



As with any connected Azure Sphere application, I start with the latest Microsoft Azure IoT Example application.  This application has all the IoT Hub/IoT Central connectivity logic.  I'm pretty familiar with this example project and it's easy for me to modify to fit my needs.  And the best part is that it just works!  It contains all the hooks for connecting to an Azure IoT Hub or IoT Central application.  It sends telemetry, process device twin updates, and catches direct method calls.  Pretty much all the device to cloud (D2C) and cloud to device (C2D) functionality that you need for an IoT product.  And by the way, since I'm using Azure Sphere I don't have to develop any security features, they are all done for me and maintained by Microsoft!


Source Code: GitHubProject

  • Pull the project (This project is forked off the Microsoft Examples)
  • Open the AvnetTempHumiditySensor sample from the Samples folder
  • Update the app_manifest.json file with your preferred Azure IoT Hub connection details


My development approach . . .


  • Next I found a c example that reads the TE HTU21DHTU21D device
    • Add the HTU21DHTU21D files to my project
    • Next I modified the HTU21DHTU21D code to use the Azure Sphere API calls
    • Validate that I can read the HTU21DHTU21D device
  • Add code to send temperature and humidity as telemetry to an Azure IoT Hub
  • I added a device twin "PollTime" to control how often we read the sensor and thus control how often we send telemetry data to Azure


At this point I had a working IoT device.  I'll be sending this off to our sales team to demo, so I added a few features that would help me support the demo remotely and help the demo presenters troubleshoot issues . . .


  • Added code to send up a version string as a device twin reported property
    • This helps me make sure that a demo is running the latest and greatest application by looking at the devices device twin in the IoT Hub
    • With Azure Sphere and OTA updates this should never be an issue, but it gives me a warm fuzzy to verify that the device is running the correct software
  • Added code to automatically configure two pre-configured wifi networks to the device
    • This helps sales people setup a demo without having to install the Azure Sphere SDK, they can just change the hotspot on their phone to use one of the pre-configured wifi network names and credentials
  • Added Logic to drive the RGB LED on the Starter Kit to show the network status
    • Red: No wifi connection
    • Green: Wifi connected but not connected to Azure
    • Blue: Wifi connected and connected to Azure


If you want to follow these changes through the code base, you can see the history of my changes by switching to the TE_Demo branch in the repository, then look at the history of changes on the Azure IoT sample application.


Connecting your device to Azure

Since I started with the Azure IoT example from Microsoft, you can use the instructions from that repository to see how to connect your device to either an IoT Hub or an IoT Central application.  These instructions can be reviewed here.


IoTConnect Cloud Dashboard

If you've never heard of IoTConnect before let me tell you a little about it.  Here's the Marketing description from the IoTConnect web site:


"IoTConnect is a full-fledged platform as a Service (PaaS). This horizontal IoT platform allows for device communication and management, data storage, app creation as well as enablement and robust security protocols.

IoTConnect is the only IoT platform available in the market that comes with a powerful device management system and built-in analytics that allows you to connect and manage devices with little to no coding. Its powerful yet easy-to-use interface enables enterprises to create applications faster than laborious coding saving a lot of time and money."

IoTConnect has lots of great features including pre-built vertical application across many different industries.  As a developer, I love the interface to visualize telemetry data in near real-time.  It's great for demos and pretty easy to use.  Avnet is working on an easy way to allow developers to test drive the Avnet IoTConnect cloud platform.  We're not there yet, but I thought I would at least show you the dashboard I created for this demo.  Once we have a way to turn on developer test accounts, I'll update this Blog.


For our demo I created a user defined IoTConnect custom dashboard to show the telemetry data and some company information for Avnet, IoTConnet and TE Connectivity.


Custom IoTConnect User Defined Dashboard


Live Data Screen

One of my favorite IoTConnect features is the real-time Live Data tab.  If you want to see your telemetry update in near real-time, you need to see this interface, it's pretty slick.



Device Twin Screen

IoTConnect also includes an interface for updating and viewing device twin properties.




I hope that you learned something from this blog.  This was a pretty simple project, but it could be a full blown product, it has all the pieces.  Hardware, software, OTA updates, a Cloud Solution and most importantly it's secured by Azure Sphere.  Please let me know if you have any questions by commenting below.


Thanks for reading,