element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Azure Sphere Starter Kit
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Azure Sphere Starter Kit
  • More
  • Cancel
Azure Sphere Starter Kit
Blog Azure Sphere Temperature and Humidity IoT Project with the TE HTU21D Sensor
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Azure Sphere Starter Kit to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: bwilless
  • Date Created: 11 Sep 2020 7:34 PM Date Created
  • Views 1667 views
  • Likes 5 likes
  • Comments 3 comments
Related
Recommended

Azure Sphere Temperature and Humidity IoT Project with the TE HTU21D Sensor

bwilless
bwilless
11 Sep 2020

Introduction

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.

image

 

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.

 

Software

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 . . .

 

  • I started with the Azure IoT example
    • Connect it to my IoT Hub and validate it's working correctly
  • Port in the I2C_LSM6DS3_High_LevelApp I2C functionality
    • Search for the I2C file descriptor  "i2cFd" to quickly identify all the code that needs to move over
    • I followed the instructions to use the on-board Azure Sphere Starter Kit LSM6DSO sensor since I don't have a LSM6DS3 device
    • Validate that the code port works in the new project
  • 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

image

 

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.

 

image

 

Device Twin Screen

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

 

image

 

Conclusion

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,

 

Brian

  • Sign in to reply

Top Comments

  • BigG
    BigG over 5 years ago +1
    Providing your development approach in bullet point really helped frame what it takes to get it working. That's very handy to know and will be a good reference to come back to.
  • DAB
    DAB over 5 years ago +1
    Nice post. A simple test can always tell you a lot about a device. DAB
  • skruglewicz
    skruglewicz over 5 years ago

    I'll check it out thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 5 years ago

    Nice post.

     

    A simple test can always tell you a lot about a device.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • BigG
    BigG over 5 years ago

    Providing your development approach in bullet point really helped frame what it takes to get it working. That's very handy to know and will be a good reference to come back to.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube