Design a Azure IoT Indoor Air Quality monitoring platform from scratch

Published Jul 17 2021 08:04 AM 2,905 Views
Senior Member

This article is the first part of a series which explores an end-to-end pipeline to deploy an Air Quality Monitoring application using off-the-market sensors, Azure IoT Ecosystem and Python. We will begin by looking into what is the problem, some terminology, prerequisites, reference architecture, and an implementation. 

 

Indoor Air Quality - why does it matter and how to measure it with IoT?

 

Most people think of air pollution as an outdoor problem, but indoor air quality has a major impact on health and well-being since the average American spends about 90 percent of their time indoors. Proper ventilation is one of the most important considerations for maintaining good indoor air quality. Poor indoor air quality is known to be harmful to vulnerable groups such as the elderly, children or those suffering chronic respiratory and/or cardiovascular diseases. Here is a quick visual on some sources of indoor air pollution.

 

KaushikRoy_0-1626298945190.png

 

Post Covid-19, we are in a world where awareness of our indoor environments is key for survival. Here in Canada we are quite aware of the situation, which is why we have a set of guidlines from the Government of Canada, and a recent white paper from Public Health Ontario. The American Medical Association has put up this excellent document for reference. So now that we know what the problem is, how do we go about solving it? To solve something we must be able to measure it and currently we have some popular metrics to measure air quality, viz. IAQ and VOC.

 

So what are IAQ and VOC exactly?

Indoor air quality (IAQ) is the air quality within and around buildings and structures. IAQ is known to affect the health, comfort, and well-being of building occupants. IAQ can be affected by gases (including carbon monoxide, radon, volatile organic compounds), particulates, microbial contaminants (mold, bacteria), or any mass or energy stressor that can induce adverse health conditions. IAQ is part of indoor environmental quality (IEQ), which includes IAQ as well as other physical and psychological aspects of life indoors (e.g., lighting, visual quality, acoustics, and thermal comfort). In the last few years IAQ has received increasing attention from environmental governance authorities and IAQ-related standards are getting stricter. Here is a IAQ blog infographic if you'd like to read.

 

Volatile organic compounds (VOC) are organic chemicals that have a high vapour pressure at room temperature. High vapor pressure correlates with a low boiling point, which relates to the number of the sample's molecules in the surrounding air, a trait known as volatility. VOC's are responsible for the odor of scents and perfumes as well as pollutants. VOCs play an important role in communication between animals and plants, e.g. attractants for pollinators, protection from predation, and even inter-plant interactions. Some VOCs are dangerous to human health or cause harm to the environment. Anthropogenic VOCs are regulated by law, especially indoors, where concentrations are the highest. Most VOCs are not acutely toxic, but may have long-term chronic health effects. Refer to this and this for vivid details.

 

The point is, in a post pandemic world, having a centralized air quality monitoring system is an absolute necessity. The need for collecting this data and using the insights from it is crucial to living better. And this is where Azure IoT comes in. In this series we are going to explore how to create the moving parts of this platform with 'minimum effort'. In this first part, we are goiing to concentrate our efforts on the overall architecture, hardware/software requirements, and IoT edge module creation. 

 

Prerequisites

 

To accomplish our goal we will ideally need to meet a few basic criteria. Here is a short list.

  1. Air Quality Sensor (link)
  2. IoT Edge device (link)
  3. Active Azure subscription (link)
  4. Development machine
  5. Working knowledge of Python, Sql, Docker, Json, IoT Edge runtime, VSCode
  6. Perseverance

Lets go into a bit of details about the aforementioned points since there are many possibilities. 

 

Air Quality Sensor

This is the sensor that emits the actual IAQ/VOC+ data. Now, there are a lot of options in this category, and technically they should be producing the same results. However, the best sensors in the market are Micro-Electro-Mechanical Systems (MEMS). MEMS technology uses semiconductor fabrication processes to produce miniaturized mechanical and electro-mechanical elements that range in size from less than one micrometer to several millimeters. MEMS devices can vary from relatively simple structures with no moving elements, to complex electromechanical systems with multiple moving elements. My choice was uThing::VOC™ Air-Quality USB sensor dongle. This is mainly to ensure high quality output and ease of interfacing, which is USB out of the box, and does not require any installation. Have a look at the list of features available on this dongle. The main component is a Bosch proprietary algorithm and the BME680 sensor that does all the hard work. Its basically plug-and-play.  The data is emitted in Json format and is available at an interval of 3 milliseconds on the serial port of your device. In my case it was /dev/ttyACM0, but could be different in yours.

KaushikRoy_0-1626350059920.png

 

 

 

IoT Edge device

This is the edge system. where the sensor is plugged in. Typical choices are windows or linux. If you are doing windows, be aware some of these steps may be different and you have to figure those out. However, in my case I am using ubuntu 20.04 installed on an Intel NUC. The reason I chose the NUC is because many IoT modules require an x86_64 machine, which is not available in ARM devices (Jetson, Rasp Pi, etc.) Technically this should work on ANY edge device with a usb port, but for example windows has an issue mounting serial ports onto containers. I suggest better stick with linux unless its a client requirement.

 

KaushikRoy_0-1626351757966.jpeg

 

Active Azure subscription

Surely, you will need this one, but as we know Azure has this immense suit of products, and while ideally we want to have everything, it may not be practically feasible. For practical purposes you might have to ask for access to particular services, meaning you have to know ahead exactly which ones you want to use. Of course the list of required services will vary between use cases, so we will begin with just the bare minimum. We will need the following:

  • Azure IoT Hub (link)
  • Azure Container Registry (link)
  • Azure blob storage (link)
  • Azure Streaming Analytics (link)(future article)
  • Power BI / React App (link)(future article)
  • Azure Linux VM (link)(optional)

A few points before we move to the next prerequisite. For IoT hub you can use free tier for experiments, but I will recommend to use the standard tier instead. For ACR get the usual tier and generate username password. For storageaccount its the standard tier. The ASA and BI products will be used in the reference architecture, but is not discussed in this article. The final service Azure VM is an interesting one. Potentially all the codebase can be run using VM, but this is only good for simulations. However, note that it is an equally good idea to experiment with VMs first as they have great integration and ease the learning curve.

 

Development machine

The development machine can be literally anything from which you have ssh access to the edge device. From an OS perspective it can be windows, linux, raspbian, mac etc. Just remember two things - use a good IDE (a.k.a VSCode) and make sure docker can be run on it, optionally with priviliges. In my case I am using a Startech KVM, so I can shift between my windows machine and the actual edge device for development purposes, but it is not neccessary.

 

Working knowledge of Python, Sql, Docker, Json, IoT Edge runtime, VSCode

This is where it gets tricky. Having a mix of these knowledge is somewhat essential to creating and scaling this platform. However, I understand you may not be having proficiency in all of these. On that note, I can tell from experience that being from a data engineering background has been extremely beneficial for me. In any case, you will need some python skills, some sql, and Json. Even knowing how to use the VSCode IoT extension is non-trivial. One notable mention is that good docker knowledge is extrememly important, as the edge module is in fact simply a docker container thats deployed through the deployment manifest (IoT Edge runtime).

 

Perseverance

In an ideal world, you read a tutorial, implement, it works and you make merry. The real world unfortunately will bring challenges that you have not seen anywhere. Trust me on this, many times you will make good progress simply by not quitting what you are doing. Thats it. That is the secret ingredient. Its like applying gradient descent to your own brain model of a concept. Anytime any of this doesn't work, simply have belief in Azure and yourself. You will always find a way. Okay enough of that. Lets get to business.

 

Reference Architecture

Here is a reference architecture that we can use to implement this platform. This is how I have done it. Please feel free to do your own.

 

aqarch.png

 

 

Most of this is quite simple. Just go through the documentation for Azure and you should be fine. Following this we go to what everyone is waiting for - the implementation.

 

Implementation

In this section we will see how we can use these tools to our benefit. For the Azure resources I may not go through the entire creation or installation process as there are quite a few articles on the internet for doing those. I shall only mention the main things to look out for. Here is an outline of the steps involved in the implementation.

 

  1. Create a resource group in Azure (link)
  2. Create a IoT hub in Azure (link)
  3. Create a IoT Edge device in Azure (link)
  4. Install Ubuntu 18/20 on the edge device
  5. Plugin the usb sensor into the edge device and check blue light
  6. Install docker on the edge device 
  7. Install VSCode on development machine 
  8. Create conda/pip environment for development
  9. Check read the serial usb device to receive json every few milliseconds
  10. Install IoT Edge runtime on the edge device (link)
  11. Provision the device to Azure IoT using connection string (link)
  12. Check IoT edge Runtime is running good on the edge device and portal 
  13. Create an IoT Edge solution in VSCode (link)
  14. Add a python module to the deployment (link)
  15. Mount the serial port to the module in the deployment
  16. Add codebase to read data from mounted serial port
  17. Augument sensor data with business data
  18. Send output result as events to IoT hub
  19. Build and push the IoT Edge solution (link)
  20. Create deployment from template (link)
  21. Deploy the solution to the device 
  22. Monitor endpoint for consuming output data as events 

Okay I know that is a long list. But, you must have noticed some are very basic steps. I mentioned them so everyone has a starting reference point regarding the sequence of steps to be taken. You have high chance of success if you do it like this. Lets go into some details now. Its a mix of things so I will just put them as flowing text.

 

90% of what's mentioned in the list above can be done following a combination of the documents in the official Azure IoT Edge documentation. I highly advise you to scour through these documents with eagle eyes multiple times. The main reason for this is that unlike other technologies where you can literally 'stackoverflow' your way through things, you will not have that luxury here. I have been following every commit in their git repo for years and can tell you the tools/documentation changes almost every single day. That means your wits and this document are pretty much all you have in your arsenal. The good news is Microsoft makes very good documentation and even though its impossible to cover everything, they make an attempt to do it from multiple perspectives and use cases. Special mention to the following articles.

 

 

Once you are familiar with the 'build, ship, deploy' mechanism using the copius SimulatedTemperatureSensor module examples from Azure Marketplace, you are ready to handle the real thing. The only real challenge you will have is at steps 9, 15, 16, 17, and 18. Lets see how we can make things easy there. For 9 I can simply do a cat command on the serial port.

 

cat /dev/ttyACM0

 

 

This gives me output every 3 ms. 

 

{"temperature": 23.34, "pressure": 1005.86, "humidity": 40.25, "gasResistance": 292401, "IAQ": 33.9, "iaqAccuracy": 1, "eqCO2": 515.62, "eqBreathVOC": 0.53}

 

 

This is exactly the data that the module will receive when the serial port is successfully mounted onto the module. 

 

"AirQualityModule": {
            "version": "1.0",
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "settings": {
              "image": "${MODULES.AirQualityModule}",
              "createOptions": {
                "Env": [
                  "IOTHUB_DEVICE_CONNECTION_STRING=$IOTHUB_IOTEDGE_CONNECTION_STRING"
                ],
                "HostConfig": {
                  "Dns": [
                    "1.1.1.1"
                  ],
                  "Devices": [
                    {
                      "PathOnHost": "/dev/ttyACM0",
                      "PathInContainer": "/dev/ttyACM0",
                      "CgroupPermissions": "rwm"
                    }
                  ]
                }
              }
            }
          }

 

 

Notice the Devices block in the above extract from the deployment manifest. Using these keys/values we are able to mount the serial port onto the custom module aptly named AirQualityModule. So we got 15 covered.

Adding codebase to the module is quite simple too. When the module is generated by VSCode it automatically gives you the docker file (Dockerfile.amd64) and a sample main code. We will just create a copy of that file in the same repo and call it say air_quality.py. Inside this new file we will hotwire the code to read the device output. However, before doing any modification in the code we must edit requirements.txt. Mine looks like this:

 

azure-iot-device
psutil
pyserial

 

 

azure-iot-device is for the edge sdk libraries, and pyserial is for reading serial port. The imports look like this:

 

import time, sys, json
# from influxdb import InfluxDBClient
import serial
import psutil
from datetime import datetime
from azure.iot.device import IoTHubModuleClient, Message

 

 

Quite self-explainatory. Notice the influx db import is commented, meaning you can send these reading there too through the module. To cover 16 we will need the final three peices of code. Here they are:

 

message = ""
#uart = serial.Serial('/dev/tty.usbmodem14101', 115200, timeout=11) # (MacOS)
uart = serial.Serial('/dev/ttyACM0', 115200, timeout=11) # Linux
uart.write(b'J\n')
message = uart.readline()
uart.flushInput()
if debug is True:
  print('message...')
  print(message)
data_dict = json.loads(message.decode())

 

 

There that's it! With three peices of code you have taken the data emitted by the sensor, to your desired json format using python. 16 is covered. For 17 we will just update the dictionary with business data. In my case as follows. I am attaching a sensor name and  coordinates to find me :happyface:.

 

data_dict.update({'sensorId':'roomAQSensor'})
data_dict.update({'longitude':-79.025270})
data_dict.update({'latitude':43.857989})
data_dict.update({'cpuTemperature':psutil.sensors_temperatures().get('acpitz')[0][1]})
data_dict.update({'timeCreated':datetime.now().strftime("%Y-%m-%d %H:%M:%S")})

 

 

For 18 it is as simple as 

 

print('data dict...')
print(data_dict)
msg=Message(json.dumps(data_dict))
msg.content_encoding = "utf-8"
msg.content_type = "applicationhttps://techcommunity.microsoft.com/json"
module_client.send_message_to_output(msg, "airquality")

 

 

Before doing step 19, two things must happen. First, u need to replace the default main.py in the dockerfile and with air_quality.py. Second, you must use proper entries in .env file to generate deployment & deploy successfully. We can quickly check the docker image exists before actual deployment.

 

docker images
iotregistry.azurecr.io/airqualitymodule   0.0.1-amd64  030b11fce8af  4 days ago  129MB

 

 

Now you are good to deploy. Use this tutorial to help deploy successfully. At the end of step 22 this is what it looks like upon consuming the endpoint through VSCode.

 

[IoTHubMonitor] Created partition receiver [0] for consumerGroup [$Default]
[IoTHubMonitor] Created partition receiver [1] for consumerGroup [$Default]
[IoTHubMonitor] [2:33:28 PM] Message received from [azureiotedge/AirQualityModule]:
{
  "temperature": 28.87,
  "pressure": 1001.15,
  "humidity": 38.36,
  "gasResistance": 249952,
  "IAQ": 117.3,
  "iaqAccuracy": 1,
  "eqCO2": 661.26,
  "eqBreathVOC": 0.92,
  "sensorId": "roomAQSensor",
  "longitude": -79.02527,
  "latitude": 43.857989,
  "cpuTemperature": 27.8,
  "timeCreated": "2021-07-15 18:33:28"
}
[IoTHubMonitor] [2:33:31 PM] Message received from [azureiotedge/AirQualityModule]:
{
  "temperature": 28.88,
  "pressure": 1001.19,
  "humidity": 38.35,
  "gasResistance": 250141,
  "IAQ": 115.8,
  "iaqAccuracy": 1,
  "eqCO2": 658.74,
  "eqBreathVOC": 0.91,
  "sensorId": "roomAQSensor",
  "longitude": -79.02527,
  "latitude": 43.857989,
  "cpuTemperature": 27.8,
  "timeCreated": "2021-07-15 18:33:31"
}
[IoTHubMonitor] Stopping built-in event endpoint monitoring...
[IoTHubMonitor] Built-in event endpoint monitoring stopped.

 

 

Congratulations! You have successfully deployed the most vital step in creating a scalable air quality monitoring platform from scratch using Azure IoT.

 

Future Work

Keep an eye out for a follow up of this article where I shall be discussing how to continue the end-to-end pipeline and actually visualize it on Power BI.

2 Comments
Occasional Visitor

DO u have any git link for python file ?

Senior Member

Hi Ayush,

 

Thanks for your comment. I have attached the module as a zip file at the end of this article. Let me know if you face any issues.

 

THanks,

Roy

%3CLINGO-SUB%20id%3D%22lingo-sub-2748788%22%20slang%3D%22en-US%22%3ERe%3A%20Design%20a%20Azure%20IoT%20Indoor%20Air%20Quality%20monitoring%20platform%20from%20scratch%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2748788%22%20slang%3D%22en-US%22%3E%3CP%3EDO%20u%20have%20any%20git%20link%20for%20python%20file%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2549733%22%20slang%3D%22en-US%22%3EDesign%20a%20Azure%20IoT%20Indoor%20Air%20Quality%20monitoring%20platform%20from%20scratch%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2549733%22%20slang%3D%22en-US%22%3E%3CP%20class%3D%22lia-align-justify%22%3EThis%20article%20is%20the%20first%20part%20of%20a%20series%20which%20explores%20an%20end-to-end%20pipeline%20to%20deploy%20an%20Air%20Quality%20Monitoring%20application%20using%20off-the-market%20sensors%2C%20Azure%20IoT%20Ecosystem%20and%20Python.%20We%20will%20begin%20by%20looking%20into%20what%20is%20the%20problem%2C%20some%20terminology%2C%20prerequisites%2C%20reference%20architecture%2C%20and%20an%20implementation.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--410477073%22%20id%3D%22toc-hId--409583151%22%3EIndoor%20Air%20Quality%20-%20why%20does%20it%20matter%20and%20how%20to%20measure%20it%20with%20IoT%3F%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EMost%20people%20think%20of%20air%20pollution%20as%20an%20outdoor%20problem%2C%20but%20indoor%20air%20quality%20has%20a%20major%20impact%20on%20health%20and%20well-being%20since%20the%20average%20American%20spends%20about%20%3CSTRONG%3E90%20percent%3C%2FSTRONG%3E%20of%20their%20time%20indoors.%20Proper%20ventilation%20is%20one%20of%20the%20most%20important%20considerations%20for%20maintaining%20good%20indoor%20air%20quality.%20Poor%20indoor%20air%20quality%20is%20known%20to%20be%20harmful%20to%20vulnerable%20groups%20such%20as%20the%20elderly%2C%20children%20or%20those%20suffering%20chronic%20respiratory%20and%2For%20cardiovascular%20diseases.%20Here%20is%20a%20quick%20visual%20on%20some%20%3CSTRONG%3Esources%20of%20indoor%20air%20pollution%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22KaushikRoy_0-1626298945190.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F295928i2A83A4497344A826%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_0-1626298945190.png%22%20alt%3D%22KaushikRoy_0-1626298945190.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%20data-unlink%3D%22true%22%3EPost%20Covid-19%2C%20we%20are%20in%20a%20world%20where%20awareness%20of%20our%20indoor%20environments%20is%20key%20for%20survival.%20Here%20in%20Canada%20we%20are%20quite%20aware%20of%20the%20situation%2C%20which%20is%20why%20we%20have%20a%20%3CA%20title%3D%22set%20of%20guidlines%22%20href%3D%22https%3A%2F%2Fwww.canada.ca%2Fen%2Fpublic-health%2Fservices%2Fdiseases%2F2019-novel-coronavirus-infection%2Fguidance-documents%2Fguide-indoor-ventilation-covid-19-pandemic.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Eset%20of%20guidlines%3C%2FA%3E%26nbsp%3Bfrom%20the%20Government%20of%20Canada%2C%20and%20a%20%3CA%20title%3D%22recent%20white%20paper%22%20href%3D%22https%3A%2F%2Fwww.publichealthontario.ca%2F-%2Fmedia%2Fdocuments%2Fncov%2Fipac%2F2020%2F09%2Fcovid-19-hvac-systems-in-buildings.pdf%3Fla%3Den%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Erecent%20white%20paper%3C%2FA%3E%20from%20Public%20Health%20Ontario.%20The%20%3CSTRONG%3EAmerican%20Medical%20Association%3C%2FSTRONG%3E%20has%20put%20up%20this%20excellent%20%3CA%20title%3D%22document%22%20href%3D%22https%3A%2F%2Fwww.epa.gov%2Fsites%2Fproduction%2Ffiles%2F2015-01%2Fdocuments%2Findoor_air_pollution.pdf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Edocument%3C%2FA%3E%20for%20reference.%20So%20now%20that%20we%20know%20what%20the%20problem%20is%2C%20how%20do%20we%20go%20about%20solving%20it%3F%20To%20solve%20something%20we%20must%20be%20able%20to%20measure%20it%20and%20currently%20we%20have%20some%20popular%20metrics%20to%20measure%20air%20quality%2C%20viz.%20IAQ%20and%20VOC.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%20data-unlink%3D%22true%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH5%20class%3D%22lia-align-justify%22%20data-unlink%3D%22true%22%20id%3D%22toc-hId-981148979%22%20id%3D%22toc-hId-982042901%22%3E%3CEM%3ESo%20what%20are%20IAQ%20and%20VOC%20exactly%3F%3C%2FEM%3E%3C%2FH5%3E%0A%3CP%20class%3D%22lia-align-justify%22%20data-unlink%3D%22true%22%3E%3CSTRONG%3EIndoor%20air%20quality%20(IAQ)%3C%2FSTRONG%3E%20is%20the%20air%20quality%20within%20and%20around%20buildings%20and%20structures.%20IAQ%20is%20known%20to%20affect%20the%20health%2C%20comfort%2C%20and%20well-being%20of%20building%20occupants.%26nbsp%3BIAQ%20can%20be%20affected%20by%20gases%20(including%20%3CSTRONG%3Ecarbon%20monoxide%3C%2FSTRONG%3E%2C%20%3CSTRONG%3Eradon%3C%2FSTRONG%3E%2C%20volatile%20organic%20compounds)%2C%20particulates%2C%20microbial%20contaminants%20(%3CSTRONG%3Emold%3C%2FSTRONG%3E%2C%20%3CSTRONG%3Ebacteria%3C%2FSTRONG%3E)%2C%20or%20any%20mass%20or%20energy%20stressor%20that%20can%20induce%20adverse%20health%20conditions.%26nbsp%3BIAQ%20is%20part%20of%20indoor%20environmental%20quality%20(IEQ)%2C%20which%20includes%20IAQ%20as%20well%20as%20other%20physical%20and%20psychological%20aspects%20of%20life%20indoors%20(e.g.%2C%20lighting%2C%20visual%20quality%2C%20acoustics%2C%20and%20thermal%20comfort).%20In%20the%20last%20few%20years%20IAQ%26nbsp%3Bhas%20received%20increasing%20attention%20from%20environmental%20governance%20authorities%20and%20IAQ-related%20standards%20are%20getting%20stricter.%20Here%20is%20a%26nbsp%3B%3CA%20title%3D%22IAQ%20blog%20infographic%22%20href%3D%22http%3A%2F%2Fwww.ac-heatingconnect.com%2Fwp-content%2Fuploads%2FIAQ-blog-infographic.pdf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EIAQ%20blog%20infographic%3C%2FA%3E%26nbsp%3Bif%20you'd%20like%20to%20read.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%20data-unlink%3D%22true%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%20data-unlink%3D%22true%22%3E%3CSTRONG%3EVolatile%20organic%20compounds%20(VOC)%3C%2FSTRONG%3E%26nbsp%3Bare%20organic%20chemicals%20that%20have%20a%20high%20vapour%20pressure%20at%20room%20temperature.%20High%20vapor%20pressure%20correlates%20with%20a%20low%20boiling%20point%2C%20which%20relates%20to%20the%20number%20of%20the%20sample's%20molecules%20in%20the%20surrounding%20air%2C%20a%20trait%20known%20as%20%3CSTRONG%3Evolatility%3C%2FSTRONG%3E.%26nbsp%3BVOC's%20are%20responsible%20for%20the%20odor%20of%20scents%20and%20perfumes%20as%20well%20as%20pollutants.%20VOCs%20play%20an%20important%20role%20in%20communication%20between%20animals%20and%20plants%2C%20e.g.%20attractants%20for%20pollinators%2C%20protection%20from%20predation%2C%20and%20even%20inter-plant%20interactions.%20Some%20VOCs%20are%20dangerous%20to%20human%20health%20or%20cause%20harm%20to%20the%20environment.%20Anthropogenic%20VOCs%20are%20regulated%20by%20law%2C%20especially%20indoors%2C%20where%20concentrations%20are%20the%20highest.%20Most%20VOCs%20are%20not%20acutely%20toxic%2C%20but%20may%20have%20long-term%20chronic%20health%20effects.%20Refer%20to%20%3CA%20title%3D%22this%22%20href%3D%22https%3A%2F%2Fwww.canada.ca%2Fen%2Fhealth-canada%2Fservices%2Fair-quality%2Findoor-air-contaminants%2Fvolatile-organic-compounds.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ethis%3C%2FA%3E%20and%20%3CA%20title%3D%22this%22%20href%3D%22https%3A%2F%2Fwww.canada.ca%2Fen%2Fhealth-canada%2Fservices%2Fpublications%2Fhealthy-living%2Findoor-air-reference-levels.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ethis%3C%2FA%3E%20for%20vivid%20details.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%20data-unlink%3D%22true%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%20data-unlink%3D%22true%22%3EThe%20point%20is%2C%20in%20a%20post%20pandemic%20world%2C%20having%20a%20%3CSTRONG%3Ecentralized%20air%20quality%20monitoring%20system%20is%20an%20absolute%20necessity%3C%2FSTRONG%3E.%20The%20need%20for%20collecting%20this%20data%20and%20using%20the%20insights%20from%20it%20is%20crucial%20to%20living%20better.%20And%20this%20is%20where%20%3CSTRONG%3EAzure%20IoT%3C%2FSTRONG%3E%20comes%20in.%20In%20this%20series%20we%20are%20going%20to%20explore%20how%20to%20create%20the%20moving%20parts%20of%20this%20platform%20with%20'%3CSTRONG%3Eminimum%20effort%3C%2FSTRONG%3E'.%20In%20this%20first%20part%2C%20we%20are%20goiing%20to%20concentrate%20our%20efforts%20on%20the%20overall%20architecture%2C%20hardware%2Fsoftware%20requirements%2C%20and%20IoT%20edge%20%3CSTRONG%3Emodule%3C%2FSTRONG%3E%20creation.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-269581297%22%20id%3D%22toc-hId-270475219%22%3EPrerequisites%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20accomplish%20our%20goal%20we%20will%20ideally%20need%20to%20meet%20a%20few%20basic%20criteria.%20Here%20is%20a%20short%20list.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EAir%20Quality%20Sensor%20(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fohmtech.io%2Fproducts%2Futhingvoc%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3EIoT%20Edge%20device%26nbsp%3B(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fark.intel.com%2Fcontent%2Fwww%2Fus%2Fen%2Fark.html%23%40Intel%25C2%25AENUC%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3EActive%20Azure%20subscription%20(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fabout-iot-edge%3Fview%3Diotedge-2020-11https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Finternet-of-things%2Fbringing-new-life-to-the-altair-8800-on-the-azure-sphere%2Fba-p%2F2554337%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3EDevelopment%20machine%3C%2FLI%3E%0A%3CLI%3EWorking%20knowledge%20of%20Python%2C%20Sql%2C%20Docker%2C%20Json%2C%20IoT%20Edge%20runtime%2C%20VSCode%3C%2FLI%3E%0A%3CLI%3EPerseverance%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ELets%20go%20into%20a%20bit%20of%20details%20about%20the%20aforementioned%20points%20since%20there%20are%20many%20possibilities.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--836808588%22%20id%3D%22toc-hId--835914666%22%3EAir%20Quality%20Sensor%3C%2FH4%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThis%20is%20the%20sensor%20that%20emits%20the%20actual%20IAQ%2FVOC%2B%20data.%20Now%2C%20there%20are%20a%20lot%20of%20options%20in%20this%20category%2C%20and%20technically%20they%20should%20be%20producing%20the%20same%20results.%20However%2C%20the%20best%20sensors%20in%20the%20market%20are%20%3CSTRONG%3EMicro-Electro-Mechanical%20Systems%20(MEMS)%3C%2FSTRONG%3E.%20MEMS%20technology%20uses%20semiconductor%20fabrication%20processes%20to%20produce%20miniaturized%20mechanical%20and%20electro-mechanical%20elements%20that%20range%20in%20size%20from%20less%20than%20one%20micrometer%20to%20several%20millimeters.%20MEMS%20devices%20can%20vary%20from%20relatively%20simple%20structures%20with%20no%20moving%20elements%2C%20to%20complex%20electromechanical%20systems%20with%20multiple%20moving%20elements.%20My%20choice%20was%26nbsp%3B%3CA%20title%3D%22uThing%3A%3AVOC%E2%84%A2%20Air-Quality%20USB%20sensor%20dongle%22%20href%3D%22https%3A%2F%2Fohmtech.io%2Fproducts%2Futhingvoc%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EuThing%3A%3AVOC%E2%84%A2%20Air-Quality%20USB%20sensor%20dongle%3C%2FA%3E.%20This%20is%20mainly%20to%20ensure%20high%20quality%20output%20and%20ease%20of%20interfacing%2C%20which%20is%20USB%20out%20of%20the%20box%2C%20and%20does%20not%20require%20any%20installation.%20Have%20a%20look%20at%20the%20list%20of%20features%20available%20on%20this%20dongle.%20The%20main%20component%20is%20a%20Bosch%20proprietary%20algorithm%20and%20the%20BME680%20sensor%20that%20does%20all%20the%20hard%20work.%20Its%20basically%20plug-and-play.%26nbsp%3B%20The%20data%20is%20emitted%20in%20Json%20format%20and%20is%20available%20at%20an%20interval%20of%203%20milliseconds%20on%20the%20serial%20port%20of%20your%20device.%20In%20my%20case%20it%20was%20%3CSTRONG%3E%2Fdev%2FttyACM0%3C%2FSTRONG%3E%2C%20but%20could%20be%20different%20in%20yours.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22KaushikRoy_0-1626350059920.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296101iA8B7DFC689506A76%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_0-1626350059920.png%22%20alt%3D%22KaushikRoy_0-1626350059920.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-1650704245%22%20id%3D%22toc-hId-1651598167%22%3EIoT%20Edge%20device%3C%2FH4%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThis%20is%20the%20edge%20system.%20where%20the%20sensor%20is%20plugged%20in.%20Typical%20choices%20are%20windows%20or%20linux.%20If%20you%20are%20doing%20windows%2C%20be%20aware%20some%20of%20these%20steps%20may%20be%20different%20and%20you%20have%20to%20figure%20those%20out.%20However%2C%20in%20my%20case%20I%20am%20using%20ubuntu%2020.04%20installed%20on%20an%20%3CA%20title%3D%22Intel%20NUC%22%20href%3D%22https%3A%2F%2Fwww.intel.com%2Fcontent%2Fwww%2Fus%2Fen%2Fproducts%2Fdetails%2Fnuc.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EIntel%20NUC%3C%2FA%3E.%20The%20reason%20I%20chose%20the%20NUC%20is%20because%20many%20IoT%20modules%20require%20an%20%3CSTRONG%3Ex86_64%3C%2FSTRONG%3E%20machine%2C%20which%20is%20not%20available%20in%20ARM%20devices%20(Jetson%2C%20Rasp%20Pi%2C%20etc.)%20Technically%20this%20should%20work%20on%20%3CSTRONG%3EANY%3C%2FSTRONG%3E%20edge%20device%20with%20a%20usb%20port%2C%20but%20for%20example%20windows%20has%20an%20issue%20%3CSTRONG%3Emounting%20serial%20ports%3C%2FSTRONG%3E%20onto%20%3CSTRONG%3Econtainers%3C%2FSTRONG%3E.%20I%20suggest%20better%20stick%20with%20linux%20unless%20its%20a%20client%20requirement.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-center%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22KaushikRoy_0-1626351757966.jpeg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296105i1ABE5962324BC82D%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22KaushikRoy_0-1626351757966.jpeg%22%20alt%3D%22KaushikRoy_0-1626351757966.jpeg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--156750218%22%20id%3D%22toc-hId--155856296%22%3EActive%20Azure%20subscription%3C%2FH4%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ESurely%2C%20you%20will%20need%20this%20one%2C%20but%20as%20we%20know%20Azure%20has%20this%20immense%20suit%20of%20products%2C%20and%20while%20ideally%20we%20want%20to%20have%20everything%2C%20it%20may%20not%20be%20practically%20feasible.%20For%20practical%20purposes%20you%20might%20have%20to%20ask%20for%20access%20to%20particular%20services%2C%20meaning%20you%20have%20to%20know%20ahead%20exactly%20which%20ones%20you%20want%20to%20use.%20Of%20course%20the%20list%20of%20required%20services%20will%20vary%20between%20use%20cases%2C%20so%20we%20will%20begin%20with%20just%20the%20bare%20minimum.%20We%20will%20need%20the%20following%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20class%3D%22lia-align-justify%22%3EAzure%20IoT%20Hub%20(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fiot-hub%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%20class%3D%22lia-align-justify%22%3EAzure%20Container%20Registry%20(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fcontainer-registry%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%20class%3D%22lia-align-justify%22%3EAzure%20blob%20storage%20(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fstorage%2Fblobs%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%20class%3D%22lia-align-justify%22%3EAzure%20Streaming%20Analytics%20(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fstream-analytics%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)(future%20article)%3C%2FLI%3E%0A%3CLI%20class%3D%22lia-align-justify%22%3EPower%20BI%20%2F%20React%20App%20(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fpower-bi-embedded%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)(future%20article)%3C%2FLI%3E%0A%3CLI%20class%3D%22lia-align-justify%22%3EAzure%20Linux%20VM%20(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fvirtual-machines%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)(optional)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EA%20few%20points%20before%20we%20move%20to%20the%20next%20prerequisite.%20For%20%3CSTRONG%3EIoT%20hub%3C%2FSTRONG%3E%20you%20can%20use%20free%20tier%20for%20experiments%2C%20but%20I%20will%20recommend%20to%20use%20the%20%3CSTRONG%3Estandard%20tier%3C%2FSTRONG%3E%20instead.%20For%20%3CSTRONG%3EACR%3C%2FSTRONG%3E%20get%20the%20usual%20tier%20and%20generate%20%3CSTRONG%3Eusername%20password%3C%2FSTRONG%3E.%20For%20%3CSTRONG%3Estorageaccount%3C%2FSTRONG%3E%20its%20the%20%3CSTRONG%3Estandard%20tier%3C%2FSTRONG%3E.%20The%20ASA%20and%20BI%20products%20will%20be%20used%20in%20the%20reference%20architecture%2C%20but%20is%20not%20discussed%20in%20this%20article.%20The%20final%20service%20Azure%20VM%20is%20an%20interesting%20one.%20Potentially%20all%20the%20codebase%20can%20be%20run%20using%20%3CSTRONG%3EVM%3C%2FSTRONG%3E%2C%20but%20this%20is%20only%20good%20for%20%3CSTRONG%3Esimulations%3C%2FSTRONG%3E.%20However%2C%20note%20that%20it%20is%20an%20equally%20good%20idea%20to%20experiment%20with%20VMs%20first%20as%20they%20have%20great%20integration%20and%20ease%20the%20learning%20curve.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--1964204681%22%20id%3D%22toc-hId--1963310759%22%3EDevelopment%20machine%3C%2FH4%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThe%20development%20machine%20can%20be%20literally%20anything%20from%20which%20you%20have%20%3CSTRONG%3Essh%20access%20to%20the%20edge%20device%3C%2FSTRONG%3E.%20From%20an%20OS%20perspective%20it%20can%20be%20windows%2C%20linux%2C%20raspbian%2C%20mac%20etc.%20Just%20remember%20two%20things%20-%20use%20a%20good%20%3CSTRONG%3EIDE%3C%2FSTRONG%3E%20(a.k.a%20VSCode)%20and%20make%20sure%20%3CSTRONG%3Edocker%3C%2FSTRONG%3E%20can%20be%20run%20on%20it%2C%20optionally%20with%20priviliges.%20In%20my%20case%20I%20am%20using%20a%20%3CA%20title%3D%22Startech%20KVM%22%20href%3D%22https%3A%2F%2Fwww.startech.com%2Fen-ca%2Fserver-management%2Fsv431hdu3a2%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EStartech%20KVM%3C%2FA%3E%2C%20so%20I%20can%20shift%20between%20my%20windows%20machine%20and%20the%20actual%20edge%20device%20for%20development%20purposes%2C%20but%20it%20is%20not%20neccessary.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-523308152%22%20id%3D%22toc-hId-524202074%22%3EWorking%20knowledge%20of%20Python%2C%20Sql%2C%20Docker%2C%20Json%2C%20IoT%20Edge%20runtime%2C%20VSCode%3C%2FH4%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThis%20is%20where%20it%20gets%20tricky.%20Having%20a%20mix%20of%20these%20knowledge%20is%20somewhat%20essential%20to%20creating%20and%20scaling%20this%20platform.%20However%2C%20I%20understand%20you%20may%20not%20be%20having%20proficiency%20in%20all%20of%20these.%20On%20that%20note%2C%20I%20can%20tell%20from%20experience%20that%20being%20from%20a%20%3CSTRONG%3Edata%20engineering%3C%2FSTRONG%3E%20background%20has%20been%20extremely%20beneficial%20for%20me.%20In%20any%20case%2C%20you%20will%20need%20some%20%3CSTRONG%3Epython%3C%2FSTRONG%3E%20skills%2C%20some%20%3CSTRONG%3Esql%3C%2FSTRONG%3E%2C%20and%20%3CSTRONG%3EJson%3C%2FSTRONG%3E.%20Even%20knowing%20how%20to%20use%20the%20%3CSTRONG%3EVSCode%20IoT%20extension%3C%2FSTRONG%3E%20is%20non-trivial.%20One%20notable%20mention%20is%20that%20good%20%3CSTRONG%3Edocker%3C%2FSTRONG%3E%20knowledge%20is%20extrememly%20important%2C%20as%20the%20%3CSTRONG%3Eedge%20module%3C%2FSTRONG%3E%20is%20in%20fact%20simply%20a%20docker%20container%20thats%20deployed%20through%20the%20deployment%20manifest%20(%3CSTRONG%3EIoT%20Edge%20runtime%3C%2FSTRONG%3E).%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--1284146311%22%20id%3D%22toc-hId--1283252389%22%3EPerseverance%3C%2FH4%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIn%20an%20ideal%20world%2C%20you%20read%20a%20tutorial%2C%20implement%2C%20it%20works%20and%20you%20make%20merry.%20The%20real%20world%20unfortunately%20will%20bring%20challenges%20that%20you%20have%20not%20seen%20anywhere.%20Trust%20me%20on%20this%2C%20many%20times%20you%20will%20make%20good%20progress%20simply%20by%20%3CSTRONG%3Enot%20quitting%3C%2FSTRONG%3E%20what%20you%20are%20doing.%20Thats%20it.%20That%20is%20the%20secret%20ingredient.%20Its%20like%20applying%20gradient%20descent%20to%20your%20own%20brain%20model%20of%20a%20concept.%20Anytime%20any%20of%20this%20doesn't%20work%2C%20simply%20have%20%3CSTRONG%3Ebelief%20in%20Azure%20and%20yourself%3C%2FSTRONG%3E.%20You%20will%20always%20find%20a%20way.%20Okay%20enough%20of%20that.%20Lets%20get%20to%20business.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1294649415%22%20id%3D%22toc-hId--1293755493%22%3EReference%20Architecture%3C%2FH3%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EHere%20is%20a%20reference%20architecture%20that%20we%20can%20use%20to%20implement%20this%20platform.%20This%20is%20how%20I%20have%20done%20it.%20Please%20feel%20free%20to%20do%20your%20own.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22aqarch.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296179i196016DEE97DABD6%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22aqarch.png%22%20alt%3D%22aqarch.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EMost%20of%20this%20is%20quite%20simple.%20Just%20go%20through%20the%20documentation%20for%20Azure%20and%20you%20should%20be%20fine.%20Following%20this%20we%20go%20to%20what%20everyone%20is%20waiting%20for%20-%20the%20implementation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-497699939%22%20id%3D%22toc-hId-498593861%22%3EImplementation%3C%2FH3%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIn%20this%20section%20we%20will%20see%20how%20we%20can%20use%20these%20tools%20to%20our%20benefit.%20For%20the%20Azure%20resources%20I%20may%20not%20go%20through%20the%20entire%20creation%20or%20installation%20process%20as%20there%20are%20quite%20a%20few%20articles%20on%20the%20internet%20for%20doing%20those.%20I%20shall%20only%20mention%20the%20main%20things%20to%20look%20out%20for.%20Here%20is%20an%20outline%20of%20the%20steps%20involved%20in%20the%20implementation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20a%20resource%20group%20in%20Azure%3C%2FSTRONG%3E%20(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-resource-manager%2Fmanagement%2Fmanage-resource-groups-portal%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20a%20IoT%20hub%20in%20Azure%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-hub%2Fiot-hub-create-through-portal%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20a%20IoT%20Edge%20device%20in%20Azure%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fhow-to-register-device%3Fview%3Diotedge-2020-11%26amp%3Btabs%3Dazure-portal%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EInstall%20Ubuntu%2018%2F20%20on%20the%20edge%20device%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EPlugin%20the%20usb%20sensor%20into%20the%20edge%20device%20and%20check%20blue%20light%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EInstall%20docker%20on%20the%20edge%20device%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EInstall%20VSCode%20on%20development%20machine%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20conda%2Fpip%20environment%20for%20development%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECheck%20read%20the%20serial%20usb%20device%20to%20receive%20json%20every%20few%20milliseconds%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EInstall%20IoT%20Edge%20runtime%20on%20the%20edge%20device%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fhow-to-install-iot-edge%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EProvision%20the%20device%20to%20Azure%20IoT%20using%20connection%20string%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fhow-to-register-device%3Fview%3Diotedge-2020-11%26amp%3Btabs%3Dazure-portal%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECheck%20IoT%20edge%20Runtime%20is%20running%20good%20on%20the%20edge%20device%20and%20portal%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20an%20IoT%20Edge%20solution%20in%20VSCode%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fhow-to-vs-code-develop-module%3Fview%3Diotedge-2020-11%26amp%3B%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EAdd%20a%20python%20module%20to%20the%20deployment%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Ftutorial-python-module%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EMount%20the%20serial%20port%20to%20the%20module%20in%20the%20deployment%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EAdd%20codebase%20to%20read%20data%20from%20mounted%20serial%20port%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EAugument%20sensor%20data%20with%20business%20data%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ESend%20output%20result%20as%20events%20to%20IoT%20hub%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EBuild%20and%20push%20the%20IoT%20Edge%20solution%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fhow-to-deploy-modules-vscode%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20deployment%20from%20template%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22link%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fmodule-composition%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EDeploy%20the%20solution%20to%20the%20device%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EMonitor%20endpoint%20for%20consuming%20output%20data%20as%20events%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EOkay%20I%20know%20that%20is%20a%20long%20list.%20But%2C%20you%20must%20have%20noticed%20some%20are%20very%20basic%20steps.%20I%20mentioned%20them%20so%20everyone%20has%20a%20starting%20reference%20point%20regarding%20the%20%3CSTRONG%3Esequence%20of%20steps%3C%2FSTRONG%3E%20to%20be%20taken.%20You%20have%20high%20chance%20of%20success%20if%20you%20do%20it%20like%20this.%20Lets%20go%20into%20some%20details%20now.%20Its%20a%20mix%20of%20things%20so%20I%20will%20just%20put%20them%20as%20flowing%20text.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%3CSTRONG%3E90%25%3C%2FSTRONG%3E%20of%20what's%20mentioned%20in%20the%20list%20above%20can%20be%20done%20following%20a%20combination%20of%20the%20documents%20in%20the%20official%20%3CA%20title%3D%22Azure%20IoT%20Edge%20documentation%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2F%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20IoT%20Edge%20documentation%3C%2FA%3E.%20I%20highly%20advise%20you%20to%20scour%20through%20these%20documents%20with%20eagle%20eyes%20multiple%20times.%20The%20main%20reason%20for%20this%20is%20that%20unlike%20other%20technologies%20where%20you%20can%20literally%20'stackoverflow'%20your%20way%20through%20things%2C%20you%20will%20not%20have%20that%20luxury%20here.%20I%20have%20been%20following%20every%20commit%20in%20their%20git%20repo%20for%20years%20and%20can%20tell%20you%20the%20tools%2Fdocumentation%20changes%20almost%20every%20single%20day.%20That%20means%20your%20wits%20and%20this%20document%20are%20pretty%20much%20all%20you%20have%20in%20your%20arsenal.%20The%20good%20news%20is%20Microsoft%20makes%20very%20good%20documentation%20and%20even%20though%20its%20impossible%20to%20cover%20everything%2C%20they%20make%20an%20attempt%20to%20do%20it%20from%20multiple%20perspectives%20and%20use%20cases.%20Special%20mention%20to%20the%20following%20articles.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20title%3D%22Develop%20IoT%20module%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fhow-to-vs-code-develop-module%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDevelop%20IoT%20module%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20title%3D%22Deploy%20your%20first%20IoT%20Edge%20module%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fquickstart-linux%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDeploy%20your%20first%20IoT%20Edge%20module%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20title%3D%22Register%20an%20IoT%20Edge%20device%20in%20IoT%20Hub%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fhow-to-register-device%3Fview%3Diotedge-2020-11%26amp%3Btabs%3Dazure-portal%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ERegister%20an%20IoT%20Edge%20device%20in%20IoT%20Hub%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20title%3D%22Install%20or%20uninstall%20Azure%20IoT%20Edge%20for%20Linux%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fhow-to-install-iot-edge%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EInstall%20or%20uninstall%20Azure%20IoT%20Edge%20for%20Linux%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20title%3D%22Understand%20Azure%20IoT%20Edge%20modules%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fiot-edge-modules%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EUnderstand%20Azure%20IoT%20Edge%20modules%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20title%3D%22Develop%20your%20own%20IoT%20Edge%20modules%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fmodule-development%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDevelop%20your%20own%20IoT%20Edge%20modules%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CA%20title%3D%22How%20to%20deploy%20modules%20and%20establish%20routes%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fmodule-composition%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHow%20to%20deploy%20modules%20and%20establish%20routes%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EOnce%20you%20are%20familiar%20with%20the%20%3CSTRONG%3E'build%3C%2FSTRONG%3E%2C%20%3CSTRONG%3Eship%3C%2FSTRONG%3E%2C%20%3CSTRONG%3Edeploy'%3C%2FSTRONG%3E%20mechanism%20using%20the%20copius%20%3CA%20title%3D%22SimulatedTemperatureSensor%22%20href%3D%22https%3A%2F%2Fazuremarketplace.microsoft.com%2Fmarketplace%2Fapps%2Fazure-iot.simulated-temperature-sensor%3Ftab%3Doverview%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESimulatedTemperatureSensor%3C%2FA%3E%20module%20examples%20from%20Azure%20Marketplace%2C%20you%20are%20ready%20to%20handle%20the%20real%20thing.%20The%20only%20real%20challenge%20you%20will%20have%20is%20at%20steps%209%2C%2015%2C%2016%2C%2017%2C%20and%2018.%20Lets%20see%20how%20we%20can%20make%20things%20easy%20there.%20For%209%20I%20can%20simply%20do%20a%20%3CSTRONG%3Ecat%20command%20on%20the%20serial%20port%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Ecat%20%2Fdev%2FttyACM0%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThis%20gives%20me%20%3CSTRONG%3Eoutput%3C%2FSTRONG%3E%20every%203%20ms.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%22temperature%22%3A%2023.34%2C%20%22pressure%22%3A%201005.86%2C%20%22humidity%22%3A%2040.25%2C%20%22gasResistance%22%3A%20292401%2C%20%22IAQ%22%3A%2033.9%2C%20%22iaqAccuracy%22%3A%201%2C%20%22eqCO2%22%3A%20515.62%2C%20%22eqBreathVOC%22%3A%200.53%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThis%20is%20exactly%20the%20data%20that%20the%20module%20will%20receive%20when%20the%20serial%20port%20is%20successfully%20mounted%20onto%20the%20module.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%22AirQualityModule%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22version%22%3A%20%221.0%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22docker%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22status%22%3A%20%22running%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22restartPolicy%22%3A%20%22always%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22settings%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22image%22%3A%20%22%24%7BMODULES.AirQualityModule%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22createOptions%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Env%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22IOTHUB_DEVICE_CONNECTION_STRING%3D%24IOTHUB_IOTEDGE_CONNECTION_STRING%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22HostConfig%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Dns%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%221.1.1.1%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Devices%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22PathOnHost%22%3A%20%22%2Fdev%2FttyACM0%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22PathInContainer%22%3A%20%22%2Fdev%2FttyACM0%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22CgroupPermissions%22%3A%20%22rwm%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ENotice%20the%20%3CSTRONG%3EDevices%3C%2FSTRONG%3E%20block%20in%20the%20above%20extract%20from%20the%20deployment%20manifest.%20Using%20these%20keys%2Fvalues%20we%20are%20able%20to%20%3CSTRONG%3Emount%3C%2FSTRONG%3E%20the%20serial%20port%20onto%20the%20custom%20module%20aptly%20named%20%3CSTRONG%3EAirQualityModule%3C%2FSTRONG%3E.%20So%20we%20got%2015%20covered.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EAdding%20codebase%20to%20the%20module%20is%20quite%20simple%20too.%20When%20the%20module%20is%20generated%20by%20VSCode%20it%20automatically%20gives%20you%20the%20docker%20file%20(Dockerfile.amd64)%20and%20a%20sample%20main%20code.%20We%20will%20just%20create%20a%20copy%20of%20that%20file%20in%20the%20same%20repo%20and%20call%20it%20say%20air_quality.py.%20Inside%20this%20new%20file%20we%20will%20hotwire%20the%20code%20to%20read%20the%20device%20output.%20However%2C%20before%20doing%20any%20modification%20in%20the%20code%20we%20must%20edit%20%3CSTRONG%3Erequirements.txt%3C%2FSTRONG%3E.%20Mine%20looks%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Eazure-iot-device%0Apsutil%0Apyserial%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eazure-iot-device%3C%2FSTRONG%3E%20is%20for%20the%20edge%20sdk%20libraries%2C%20and%20%3CSTRONG%3Epyserial%3C%2FSTRONG%3E%20is%20for%20reading%20serial%20port.%20The%20imports%20look%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Eimport%20time%2C%20sys%2C%20json%0A%23%20from%20influxdb%20import%20InfluxDBClient%0Aimport%20serial%0Aimport%20psutil%0Afrom%20datetime%20import%20datetime%0Afrom%20azure.iot.device%20import%20IoTHubModuleClient%2C%20Message%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EQuite%20self-explainatory.%20Notice%20the%20influx%20db%20import%20is%20commented%2C%20meaning%20you%20can%20send%20these%20reading%20there%20too%20through%20the%20module.%20To%20cover%2016%20we%20will%20need%20the%20final%20three%20peices%20of%20code.%20Here%20they%20are%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Emessage%20%3D%20%22%22%0A%23uart%20%3D%20serial.Serial('%2Fdev%2Ftty.usbmodem14101'%2C%20115200%2C%20timeout%3D11)%20%23%20(MacOS)%0Auart%20%3D%20serial.Serial('%2Fdev%2FttyACM0'%2C%20115200%2C%20timeout%3D11)%20%23%20Linux%0Auart.write(b'J%5Cn')%3C%2FCODE%3E%3C%2FPRE%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Emessage%20%3D%20uart.readline()%0Auart.flushInput()%0Aif%20debug%20is%20True%3A%0A%20%20print('message...')%0A%20%20print(message)%3C%2FCODE%3E%3C%2FPRE%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Edata_dict%20%3D%20json.loads(message.decode())%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThere%20that's%20it!%20With%20three%20peices%20of%20code%20you%20have%20taken%20the%20%3CSTRONG%3Edata%20emitted%20by%20the%20sensor%2C%20to%20your%20desired%20json%20format%20using%20python%3C%2FSTRONG%3E.%2016%20is%20covered.%20For%2017%20we%20will%20just%20%3CSTRONG%3Eupdate%20the%20dictionary%20with%20business%20data%3C%2FSTRONG%3E.%20In%20my%20case%20as%20follows.%20I%20am%20attaching%20a%20sensor%20name%20and%26nbsp%3B%20coordinates%20to%20find%20me%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fhtml%2F%40D0941B27F467CBA2580A8C085A80A0CF%2Fimages%2Femoticons%2Fhappyface_40x40.gif%22%20alt%3D%22%3Ahappyface%3A%22%20title%3D%22%3Ahappyface%3A%22%20%2F%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Edata_dict.update(%7B'sensorId'%3A'roomAQSensor'%7D)%0Adata_dict.update(%7B'longitude'%3A-79.025270%7D)%0Adata_dict.update(%7B'latitude'%3A43.857989%7D)%0Adata_dict.update(%7B'cpuTemperature'%3Apsutil.sensors_temperatures().get('acpitz')%5B0%5D%5B1%5D%7D)%0Adata_dict.update(%7B'timeCreated'%3Adatetime.now().strftime(%22%25Y-%25m-%25d%20%25H%3A%25M%3A%25S%22)%7D)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%2018%20it%20is%20as%20simple%20as%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Eprint('data%20dict...')%0Aprint(data_dict)%0Amsg%3DMessage(json.dumps(data_dict))%0Amsg.content_encoding%20%3D%20%22utf-8%22%0Amsg.content_type%20%3D%20%22application%2Fjson%22%0Amodule_client.send_message_to_output(msg%2C%20%22airquality%22)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EBefore%20doing%20step%2019%2C%20two%20things%20must%20happen.%20First%2C%20u%20need%20to%20%3CSTRONG%3Ereplace%20the%20default%20main.py%20in%20the%20dockerfile%20and%20with%20air_quality.py%3C%2FSTRONG%3E.%20Second%2C%20you%20must%20use%20proper%20entries%20in%20%3CSTRONG%3E.env%3C%2FSTRONG%3E%20file%20to%20generate%20deployment%20%26amp%3B%20deploy%20successfully.%20We%20can%20quickly%20check%20the%20docker%20image%20exists%20before%20actual%20deployment.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Edocker%20images%0Aiotregistry.azurecr.io%2Fairqualitymodule%20%20%200.0.1-amd64%20%20030b11fce8af%20%204%20days%20ago%20%20129MB%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20you%20are%20good%20to%20deploy.%20Use%20%3CA%20title%3D%22this%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Ftutorial-develop-for-linux%3Fview%3Diotedge-2020-11%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ethis%3C%2FA%3E%20tutorial%20to%20help%20deploy%20successfully.%20At%20the%20end%20of%20step%2022%20this%20is%20what%20it%20looks%20like%20upon%20%3CSTRONG%3Econsuming%20the%20endpoint%20through%20VSCode%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%5BIoTHubMonitor%5D%20Created%20partition%20receiver%20%5B0%5D%20for%20consumerGroup%20%5B%24Default%5D%0A%5BIoTHubMonitor%5D%20Created%20partition%20receiver%20%5B1%5D%20for%20consumerGroup%20%5B%24Default%5D%0A%5BIoTHubMonitor%5D%20%5B2%3A33%3A28%20PM%5D%20Message%20received%20from%20%5Bazureiotedge%2FAirQualityModule%5D%3A%0A%7B%0A%20%20%22temperature%22%3A%2028.87%2C%0A%20%20%22pressure%22%3A%201001.15%2C%0A%20%20%22humidity%22%3A%2038.36%2C%0A%20%20%22gasResistance%22%3A%20249952%2C%0A%20%20%22IAQ%22%3A%20117.3%2C%0A%20%20%22iaqAccuracy%22%3A%201%2C%0A%20%20%22eqCO2%22%3A%20661.26%2C%0A%20%20%22eqBreathVOC%22%3A%200.92%2C%0A%20%20%22sensorId%22%3A%20%22roomAQSensor%22%2C%0A%20%20%22longitude%22%3A%20-79.02527%2C%0A%20%20%22latitude%22%3A%2043.857989%2C%0A%20%20%22cpuTemperature%22%3A%2027.8%2C%0A%20%20%22timeCreated%22%3A%20%222021-07-15%2018%3A33%3A28%22%0A%7D%0A%5BIoTHubMonitor%5D%20%5B2%3A33%3A31%20PM%5D%20Message%20received%20from%20%5Bazureiotedge%2FAirQualityModule%5D%3A%0A%7B%0A%20%20%22temperature%22%3A%2028.88%2C%0A%20%20%22pressure%22%3A%201001.19%2C%0A%20%20%22humidity%22%3A%2038.35%2C%0A%20%20%22gasResistance%22%3A%20250141%2C%0A%20%20%22IAQ%22%3A%20115.8%2C%0A%20%20%22iaqAccuracy%22%3A%201%2C%0A%20%20%22eqCO2%22%3A%20658.74%2C%0A%20%20%22eqBreathVOC%22%3A%200.91%2C%0A%20%20%22sensorId%22%3A%20%22roomAQSensor%22%2C%0A%20%20%22longitude%22%3A%20-79.02527%2C%0A%20%20%22latitude%22%3A%2043.857989%2C%0A%20%20%22cpuTemperature%22%3A%2027.8%2C%0A%20%20%22timeCreated%22%3A%20%222021-07-15%2018%3A33%3A31%22%0A%7D%0A%5BIoTHubMonitor%5D%20Stopping%20built-in%20event%20endpoint%20monitoring...%0A%5BIoTHubMonitor%5D%20Built-in%20event%20endpoint%20monitoring%20stopped.%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECongratulations!%20You%20have%20successfully%20deployed%20the%20most%20vital%20step%20in%20creating%20a%20scalable%20air%20quality%20monitoring%20platform%20from%20scratch%20using%20Azure%20IoT.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1309754524%22%20id%3D%22toc-hId--1308860602%22%3EFuture%20Work%3C%2FH3%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EKeep%20an%20eye%20out%20for%20a%20follow%20up%20of%20this%20article%20where%20I%20shall%20be%20discussing%20how%20to%20continue%20the%20end-to-end%20pipeline%20and%20actually%20visualize%20it%20on%20Power%20BI.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2549733%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22titleaq.png%22%20style%3D%22width%3A%20297px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F295926i77E631324CF18F99%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22titleaq.png%22%20alt%3D%22titleaq.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EUnderstand%20what%E2%80%99s%20in%20the%20air%20you%20breathe.%20Keep%20your%20family%20safe%20from%20indoor%20contaminants%26nbsp%3B%23IAQ%20%23VOC%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2549733%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20IoT%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20IoT%20Edge%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIoT%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Sep 14 2021 10:11 AM
www.000webhost.com