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
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Sending Data to Azure with MaaXBoard
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: james.flynn
  • Date Created: 15 Apr 2020 4:45 PM Date Created
  • Views 1190 views
  • Likes 1 like
  • Comments 0 comments
  • azure
  • avnet
  • iot
  • nxp
  • maaxboard
Related
Recommended

Sending Data to Azure with MaaXBoard

james.flynn
james.flynn
15 Apr 2020

image

Want to send telemetry data from a MikroE Click-Board to an Azure IoT Hub using a  MaaXBoard? The MaaXBoard runs Debian Linux, so you can easily leverage Python to quickly implement interaction between attached hardware and Azure.  This blog discusses  reading a Temp & Humidity Mikroe Click-Board and sending the data to an Azure IoT Hub. Once the data has been delivered to an Azure IoT Hub, you can use the resources available on Azure to process data.  This example is based on a Microsoft Quick Start Sample that has been modified to read a MikorE Click-Board for the telemetry data to send.

  • Equipment Setup
  • Click-Board Python Script
  • Monitoring Azure IoT Hub Events
  • Conclusion

 

Equipment Setup

To set up the environment, install Azure CLI on your development machine. This process is described in  https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest and provides instruction for Windows, Mac, and Linux.  The Azure CLI can be used for many things, but in this blog, it is used to monitor IoT Hub events that occur as data is sent from the MaaXBoard to the IoT Hub. 

 

Setting up the MaaXBoard involves several steps, all of which are detailed in an excellent article on Hackster.io, see Getting Started with MaaXBoard - Headless Setup.  In addition to the steps described in the Hackster.io article, you need to add the following repositories:

  • Microsoft Azure IoT Python Samples at https://github.com/Azure-Samples/azure-iot-samples-python.  The Quickstart sample that is used is located within the 'azure-iot-samples-python/iot-hub/Quickstarts/simulated-device-2/' sub-directory.
  • Review the documentation for the Send Telemetry Quickstart located at https://docs.microsoft.com/en-us/azure/iot-hub/quickstart-send-telemetry-python

 

Once you have cloned the Python Quickstart and read the Quickstart documentation, you can send “simulated” Temperature and Humidity to an IoT Hub to verify operation.

 

We will send Temperature & Humidity data read from an attached Click-Board, so we need to install a Click ShieldClick Shield on the MaaxBoard 40-pin header and a Temp&Hum Click BoardTemp&Hum Click Board for the sensor reading.    The large heat-sink on the MX8M prevents the Click Shield from mounting properly,  so you can either order a header extension (https://www.adafruit.com/product/4079?gclid=EAIaIQobChMI2PDPg8yz5gIVh_5kCh1J-AJPEAQYASABEgJx7_D_BwE) or remove the heat-sink (this isn’t a problem for this Python example but processor intensive tasks will require the heat-sink).  To remove the heat-sink, simply remove the screws holding it on top of the MX8X and remove.

Click-Board Python Script

With the Click Shield and Click-Board installed, clone the github repository https://github.com/Avnet/clickboard_python. The hts221.py

script is setup to use I2C device 1 and you can verify this is the correct device by running i2cdetect -y 1 as shown below:

image

 

image

This command shows the device ID's connected to I2C device #1, in this case it shows the Barometer Click (5d) and the Temp&Hum Click (5f).  If the devices were connected to a different I2C Device, you could change the 1 to a 2 and obtain similar output.  The hts221.py script defines our I2C device at line 14 using the I2C device #1 and when hts221.py is ran, it produces the following:

image

After verifying the hts221.py script runs correctly, we can modify SimulatedDevice.py to utilize our hardware instead of the simulated data:

 

  1. Add "import hts221' at line 7
  2. Update the CONNECTION_STRING to reflect the IoT Hub connection string you have in your IoT device (if you haven't already done this)
  3. Modify the function iothub_client_telemetry_sampe_run() (in hts221.py) by adding/modifying lines 73-84 as shown below:

image

  • The first function 'init()' simply reads the device ID and if the correct ID is read, reports the device as 'Initialized'.
  • The activate() function configures control register 1, powers the hts221 up, then loads the calibration data.
  • The functions, readTemperature() and readHumidity(), are self explanatory and their results are used to build the telemetry message to send the IoT Hub.

note: use the -O flag to avoid having the stand-alone output being printed

When you run SimulatedDevice.py, it now reports the HTS221 as initialized, displays the Temperature and Humidity, then sends the telemetry message to your IoT Hub:

image

Monitoring Azure IoT Hub Events

With the telemetry messages now sent to the IoT Hub, use the Azure CLI to monitory the reported events using the command

az iot hub monitor-events --login "<<Connection String>>”

 

for example:

image

Conclusion

Congratulations, you are now sending Telemetry data that is read from the Temp&Hum Click Board to the Azure IoT Hub!  With the plethora of MikroE Click-Boards that are available, there are numerous opportunities for telemetry collection.  In fact, the Barometer Click can be used if you want to modify SimulatedDevice.py to send Barometric Pressure instead of, or in addition to, Humidity.

As always, please let me know if you find this helpful and have any suggestions for other blogs.

  • Sign in to reply
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