The IntlAir Project
Indoor air can be filled with high amounts of carbon dioxide as well as volatile organic compounds (VOCs), both harmful to our health. With that in mind, Andrei built a smart air purifier made using IoT technologies that cleans the air automatically whenever excessive impurities are detected and controls a fan when CO2 levels are high.
People spend much of their day at home—they wake up, go to work, then come back and stay until the next day. We all try to beautify our home environment by filling it with (sometimes extravagant) furniture and flowers. But we pay much less attention to the air inside our homes. Studies show that the indoor air we breathe in most of the day is 3 to 4 times more polluted than the air outside our house. This refers to the higher amount of carbon dioxide (CO2) as well as volatile organic compounds (VOCs) which are harmful for our lives.
According to studies, the presence of CO2 in excessive amounts can lead to a lower level of concentration. This is because a higher level of CO2 replaces the oxygen that should be present in the air, reducing the oxygenation of the brain and leading to reduced brain function. Meanwhile, VOCs also have an impact on human health. Studies show that more than 30% of households have excessive levels of VOCs. These can lead to problems such as difficulty breathing and lengthened exposure can lead to nasal cancer.
So, what can we do to make our home environment healthier? Air purifiers can filter the VOCs out of the air easily. But there is a catch: the cost of modern air purifiers can be quite high. Moreover, we don’t want to have an air purifier that would run all the time because that would waste energy. We need our devices to be connected to the Internet and run without the need for us to press buttons.
SMART AIR PURIFIERS
Smart air purifiers are the solution! These devices automatically purify the air whenever excessive impurities are detected. But the cost of implementing solutions like this are excessive, and, on top of that, there is very little information given to the user about air quality. So, what about CO2? Well, simple ventilators and fans can redirect the impurities outside but running them all day can use up a significant amount of energy. So, what if you could automate both an air purifier and a fan to ensure that the air quality indoors is optimal at all times?
This is where my IntlAir project comes in. IntlAir is a device powered by the Microsoft Azure Sphere board, which monitors the indoor air quality by reading the TVOC and CO2 levels and turning on the air purifier and/ or the fan, respectively (Figure 1). The device also monitors barometric pressure to ensure that the atmosphere is optimum.
This way, any fan system and purifier can be modernized and brought into the age of IoT in minutes—no need to purchase new, expensive systems. IntlAir can significantly reduce the amount of energy used by these devices and provides the user with a comprehensive dashboard and application where they can visualize both the air quality in the home, and when the purifier was running. This dashboard is implemented in both desktop (Figure 2) and mobile formats. Look for more on the dashboard and how I developed it, later in the article. This gives the user full control over the data and ensures that the air in their home is always clean. Bring your home into the future with a smart, cost-effective implementation.
As mentioned earlier, it’s important to monitor the levels of these compounds in the air. Sadly, because of the cost of solutions that monitor these parameters, most homes will not be equipped with such sensors. The term TVOC refers to the Total amount of VOCs in the atmosphere. There are many VOCs such as ethanol and butanol. The TVOC level is calculated by counting the concentration of a few of these VOCs together getting the total level VOCs in the atmosphere. Both TVOCs and CO2 are calculated in either particles per billion (ppb) or particles per meter (ppm). These measurements are the same and represent the concentration (amount) of these compounds in the atmosphere in respect to 1 billion air particles.
By conducting research in the field, I managed to put together some tables with the effects of different concentrations of TVOCs and CO2 on the health of the inhabitants, these are shown in Table 1 and Table 2. After analyzing this data, I set the values at which the fan and purifier would turn on at 1,000ppm of CO2 for the fan and 40ppm of TVOCs for the purifier. This way the room can be cleaned if the concentration of impurities exceeds this limit.
THREE KEY PARTS
Three key parts of the IntlAir device are the frontend, the backend and the dashboard.
Frontend: The frontend of the project refers to the device that controls the purification system. Figure 3 shows this process. As Figure 3 shows, the device will turn on every two minutes (sleeping in between). The device will collect the TVOC and CO2 data from the click modules attached and will then process it to see if the values are abnormal. If this is the case, the relay controlling the fan and the one controlling the purifier will be toggled. The device will also pack all this data and send it to the cloud.
The system is designed to turn on the fan and/or the purifier until the air is clean. But to prevent the device from running the purifier excessively. It will turn off after 1 hour of running if the air is still not clean. The device will prevent the purifier/fan from turning on for one hour to let the air in the room circulate and if the air is still dirty afterwards, the purifier/fan will turn on again.
Because this is a home automation project, I believe that security is of utmost importance to ensure that the application is running smoothly and undisturbed by outside sources. The Azure Sphere device is as secure as it gets when it comes to IoT. From the Pluton chip ensuring that the device’s code can only be modified by users with access to the specificity needed in the app manifest, this device will ensure that the application is running smoothly and securely.
Backend: The backend of the project refers to the cloud infrastructure implemented to deal with the telemetry data sent by the device as well as the Power Bi dashboard which the end user will be able to access from anywhere (Figure 4).
An important part of this is the automatic connection and integration with the Azure Sphere. The Azure Sphere is limited to connecting to the Azure Cloud, which ensures data is sent in a safe environment. I personally use the Azure cloud for my projects, mainly because of the brilliant interface. So, it’s great to see that the Azure Sphere makes the connection easier.
A DPS (device provisioning service) connects the device to the IoT Hub. This feature allows for the connection of thousands of devices if needed without human interference making connection seamless. The messages are then placed in the IoT Hub. They are then extracted by a Stream Analytics job and forwarded into a Power Bi dashboard and mobile app (Figure 5). The data is displayed live in the dashboard.
The Dashboard and App: An aesthetically pleasing UI is essential for a modern application targeted at individuals. A dashboard that shows the user all the information they need in an orderly and beautiful fashion is just as important as the data collected by the device.
I leveraged the powerful capabilities of Power Bi to develop a stunning dashboard, which is available to the user in the cloud so they can see the data from anywhere at any time (Figure 2). I also converted it into a mobile application using Power Bi’s powerful phone layout so that users can carry their data in their pockets being able to check the air quality at work, on the bus and everywhere in between Figure 5.
The dashboard shows the user the current levels of TVOCs and CO2 in the home as well as the barometric pressure. This data is also shown on graphs over time. The user can also see within the app if the purifier and/or fan is running even if they are at work putting the data in the user’s hands.
I want to note that this project can still work even if you only have either an air purifier or a fan connected, instead of both. While developing this project, I kept notes of ways in which this project can develop further in next versions. This is a list of developments of the project:
• Adding alerts so that the user can know when the purifier/fan is turned on and off and if the air is not clean in the home.
• Storing the data in Cosmos DB to allow multiple applications to use it in the backend if needed.
• Azure Functions can be used to route messages from the IoT Hub into the Power Bi report. This will dramatically reduce the cost of development.
MARKET FOR INTLAIR
Market research was conducted for this project to gain an insight into the people that would use it as well as the competition for the product. The target market for this product can be broken down as follows:
Age: The product can help people of any age but is aimed at families because they will tend to care more about the air quality in their home because of their children.
Economic Background: The device is aimed at middle and lower-class households because of its low cost and because it is easily implementable.
Lifestyle: The product is aimed at people that care about their health indoors and want to live a healthy lifestyle.
The main competition for a device like IntlAir is a range of air purifiers known as “smart air purifiers.” These devices turn on automatically when they sense impurities in the air. Although these devices already exist, their price point starts from $118 (€100) for the cheapest models. These products also offer a very small amount of control over the purification of the air, which is not appropriate. There are multiple advantages and unique selling points that this product has over others that already exist in the market. These are:
• Cheaper than most of these devices
• Any air purifier can be turned into a smart one
• A well designed dashboard providing the user with more information than offered by similar solutions
• Azure Sphere’s security integration
Here is a typical user persona use case that illustrates IntlAir in action: Zara and James are a couple with two children. They have recently read about the importance of air quality and are wondering if they can improve the air quality in their home. They searched for smart air purifiers online, but the expense of a quality product is too high. Instead, they decide to purchase a normal purifier and use IntlAir to turn it into a smart air purifier saving money and energy. They have also connected their pre-existing fan system to the device to further save energy.
Now, let’s walk through the steps needed to construct the project and some tips on getting everything together. Let’s begin by ensuring that you have all the components you need to create this project. Figure 6 shows components (bill of materials or BOM) needed. Please make sure that you purchase the correct versions of the MikroE modules. The numbered References “[ ]” point you toward links in RESOURCES at the end of the article for the components, downloads and helpful tutorials that you’ll need to build this project.
• Azure Sphere MT3620 development board from Farnell • MikroE Air Quality Click 4 • MikroE Relay Click 1 • Power bank
Step 1: A few prerequisites: Before we can start with this project, there are a couple of steps that have to be taken to set up our development environment. You will be needing a PC and an Azure Sphere device to get started so we can set things up.
1. Download Visual Studio  (VS Code works too) and ensure you download the C++ development environment.
2. The next thing we need to do is download the Azure Sphere SDK. You can get it at .
3. Please note that you must download both the Azure Sphere SDK and the Extension for it. You will now need to download the extension from .
4. The next thing we will need to do is claim the device to our tenant. You will need to create one first using your Microsoft account. Everything you need is at , ensure to read through it all.
5. Last, we need to connect the device to your Wi-Fi network. The link  will guide you through the process.
Step 2: Getting everything connected: The next thing we need to do is get the MikroE clickboards mounted on the device. Well, you just have to attach them on the pins. Make sure that you connect the first socket to the Air Quality click and the second socket to the Relay Click. Referring to the Azure Spere graphic in Figure 7, those are the sockets label “1” and “2” respectively.
Step 3: Moving on with the Relay: Now that we have the components ready, we must attach our fan and purifier to the relay to be able to control them. Now there is a small caveat; the devices have to be able to turn on automatically when they are plugged in, the purifier I had used a switch so if I would set it to on, it would automatically start running if I plugged it in. Something like this is needed for the project to work. Please look at Table 3 to see which devices must be connected to each relay. We have to cut the power cable running from the plug to the device to reveal the wiring to get started.
Now we will need to connect the ground wires together again but keep the power ones separated. We now need to take the relay click and connect the ends of the power wire to the terminals of the device. Make sure to insulate the wires after you do this to ensure the safety of the device. Repeat the same process for the fan, ensuring that the wires are in the correct place. Once that is done, you are ready to move on.
Step 4: Working in the backend, getting the IoT Hub Ready: For this section, you will need to have a free Microsoft Azure Account. You can get your account for free at  and also get a $200 credit to get you started. Please follow the tutorials below to get your IoT Hub, Device Provisioning Service and Certificates ready. It is very important to note that although the tutorial uses the S1 tier IoT Hub, you can use the F1 tier which is free of cost and achieves the same thing in our case.
1. Use the link at  to set up your IoT Hub and DPS. Do not do the Cleaning up section at the end.
2. Finally, follow the tutorial at  to get your Azure Sphere connected to your hub
THE STREAMING JOB
We will be using a streaming job to extract the data from our IoT Hub as it is sent and relay it on to the Power Bi dataset we will be using later. Please note that this can also be done by using an Azure Function which is cheaper. The first section will walk through using Azure Functions and the second will use a Streaming Job. I personally used Stream Analytics for this project because it is easier to use. I did find two tutorials that show you how to get up and running and then how to connect the IoT Hub and then Power Bi. Note that you will have to adapt the code yourself to run using Azure Functions.
Step 5: Using Azure Functions
1. Set up the function and connect the IoT Hub by following this tutorial .
2. Connect Power Bi by adapting the code to include some from this tutorial .
Step 6: Using Stream Analytics Job
To use the Stream Analytics job, the first thing to do is open our Azure Portal and then navigate to the Create a Resource button in the menu on the left of the screen.
1. Search for Stream Analytics job and click enter. Now give it a name and select the location closest to yous. Make sure you select the resource group used in the IoT Hub. Ensure you reduce the units to 1 to reduce the cost.
2. Now wait for it to deploy and then navigate over to it (pin it to your dashboard if you wish). In the resource’s menu, find Inputs from the item list and click on it.
3. Select the IoT Hub option and from the menu, choose the IoT Hub you used. Set the resource name to “universum-intlair-iothub” to prevent having to change the script. Do not change any other parameter. Click save and wait for the connection to test out. Now select the Outputs option from the menu (below inputs).
4. Select the Power Bi option. It will prompt you to sign in. Sign in with the Microsoft account you have with a Power Bi subscription. If you do not own a Microsoft Business Account, use this tutorial  to create one based on your existing account for free to use this service. After that is done, ensure that all your fields match the ones shown in the screen shot in Figure 8 below. Make sure you name the output “universum-intlair-together”.
5. We are nearly there. Now navigate to the Query option (above Outputs) and select it. We will have to include the script that will pull the data out of the IoT Hub and push it into the Power Bi dataset. Copy the script shown below and paste it into Query field and then click Save Query. Note that if you named your input and/or output something else, you would have to edit the names in the query.
co2 as co2,
tvoc as tvoc,
pressure as pressure,
purifier as isPurifierOn,
fan as isFanOn,
time as time
6. Great! The last thing we need to do now is start running the job. To do this, go back to the resource’s home page and click the run button at the top of the page. Then select run from now and you are ready to go.
Step 7: Setting up the Variables: Now that we looked at the code, we will need to edit some variables to enable the device to connect to our IoT Hub. Before we get started, make sure the app_manifest.json file is open in Visual Studio.
1. The first thing we must do is open the Azure Sphere command prompt. This is done by pressing the Windows button and typing azsphere. Make sure you are signed in with your account and the correct tenant is selected. Type the following command to get your tenant ID:
Azsphere tenant show selected
2. Copy the tenant ID that is displayed and go to your code. Paste it in the DeviceAuthentication field.
3. Navigate to your Azure Portal and open the IoT hub the device is connected to. Copy and paste the hostname field on the main page into the AllowedConnections field in the application manifest.
4. Finally, navigate to your DPS and copy and paste the ID Scope field displayed on the main page into the CmdArgs field in the application manifest. You are now ready to go!
Step 8: Flashing the code: We must flash the application to the device. Connect the Azure Sphere device to your PC and then select the HighLevelCore from the flash options and click the run application button in the Visual Studio IDE.
Before you use the product for distribution, please follow this tutorial  to get the application running on the device in release mode.
Step 9: Mounting everything: For the sake of this prototype, I did not create a case or enclosure for the device (Figure 9). In most cases, the device can be hidden away somewhere, I decided to put it behind the air purifier. But you could put it somewhere on the wall if that’s better, probably if you do enclose it.
WORKING ON THE DASHBOARD
The last thing we need to do is get the dashboard ready to go. The first thing we need to do is open the Power Bi app (get it on the Windows store if you do not already have it, you can also use the web app). Create a new report and click on the Get Data button.
1. Navigate over to the Power Platform and then select Power Bi datasets. Simply select the dataset we have (make sure you ran the code for a while before, so we have data available). The data should now be ready to go.
2. Ok, here’s the frustrating part. We have to create a dozen measures or so for the project. I will guide you through making one and you will have to repeat the process for the rest. To get started, make sure you have the expressions folder open in the GitHub repository at:
https://github.com/Andrei-Florian/IntlAir. You will see a dozen or so expressions there, we need to create new measures based on those scripts.
3. In Power Bi, navigate to the menu bar at the top of the screen and select the New Measure button. This should create a new measure and give you a text box. Open any one of the files (you can open them in VS code or a lightweight editor) and copy and paste the content into the box.
4. Ok, so now repeat this process for all the values. Don’t worry if errors appear. Once you edit the scripts, everything should be fine at the end.
5. Now we can get to the fun stuff, this link  from Power Bi will show you how to get started with creating stunning visuals on the platform. Figure 10 shows a screenshot of the final version of the IntlAir Dashboard.
6. Click on the View option from the top nav bar and select mobile layout. Drag and drop the graphs and text onto the phone frame to create a mobile version of the dashboard.
7. Finally go back to the home page on the app and click on the Publish Report button from the options. This will publish your dashboard to the web allowing you to access it from anywhere. Just log into Power Bi and you should see it there. That’s it. We are done!
Make sure to get the Power Bi app, it is available on Google Play and the App Store.
I really enjoyed working on this project. I remember seeing the contest online that inspired this project a while ago, and I immediately started to brainstorm ideas. I soon came up with the IntlAir idea, an air purification system and got to work. Because I participated in prior contests with this device, I started developing the idea and coding the project immediately.
It took me about a month to finalize all details and thoroughly test the device. And today, here I am with a smart air purifier in my home. I did have some surprises along the way, namely I discovered what the levels of TVOCs were in the house. That really showed me the importance of IntlAir and the impact it can have. Most people do not even know if the air in their homes is clean or not, let alone purify it. I developed IntlAir to empower people with this data at a low cost and allow them to live in a clean, safe environment.
Indoor air can be filled with high amounts of carbon dioxide as well as volatile organic compounds (VOCs), both harmful to our health. With that in mind, Andrei built a smart air purifier made using IoT technology that automatically cleans the air whenever excessive impurities are detected and controls a fan when CO2 levels are high.
PUBLISHED IN CIRCUIT CELLAR MAGAZINE • DECEMBER 2020 #365 – Get a PDF of the issueSponsor this Article
Andrei Florian is a student in Dublin, Ireland. He has been working on tightening the connection between humans and technology by designing applications that will help us in our lives. This includes working on projects that combat pollution and climate change as well as monitoring our natural environment and our cities. He has also been working on personal security and big data. Andrei can be contacted at firstname.lastname@example.org