Monitoring indoor CO2 levels is essential for infection risk management in enclosed environments, especially in the context of the COVID-19 pandemic and other infectious diseases. High CO2 levels are indicative of poor ventilation and overcrowded spaces, which contribute to the spread of respiratory infections. CO2 monitoring helps assess the effectiveness of ventilation systems. Adequate ventilation is crucial for diluting and removing airborne contaminants, including viruses, bacteria, and other pathogens. Monitoring CO2 levels can indicate if the ventilation is sufficient to maintain a healthy indoor environment.
Asymptomatic carriers of infectious diseases can unknowingly spread the virus. CO2 monitoring can help identify spaces where people might be at higher risk due to overcrowding or inadequate ventilation, allowing for targeted interventions to reduce the potential for transmission. Many health organizations, including the CDC and WHO, have recommended maintaining good indoor air quality and ventilation as part of infection control measures. Monitoring CO2 levels can help organizations and building owners ensure compliance with these guidelines.
The Device:We opted for a compact and a travel-friendly design for the device. The device comprises a solar panel, a battery, an STM32-based microcontroller, a CO2 sensor, a Blues cellular Notecard, and a Blues Notecarrier A. The Notecarrier is equipped with a built-in solar charger to recharge the battery. The device utilizes cellular networks to transmit data, including the coordinates, to the cloud.
Reasons for Choosing CellularCellular networks and Wi-Fi serve as distinct methods for internet connectivity, each offering their own advantages and disadvantages contingent on specific circumstances. We have opted for cellular networks instead of Wi-Fi for the following reasons:
1. Data Encryption: Security concerns often arise when utilizing shared Wi-Fi networks because data encryption may not be guaranteed, depending on the network. Cellular networks, on the other hand, consistently employ data encryption, ensuring the privacy of data. While this might not be a significant issue for preliminary projects, it becomes imperative in a real laboratory setting when precise control of the device is necessary.
2. Unlimited Wireless Range: Wi-Fi's reach is constrained by the range of the router, whereas cellular internet connectivity lacks a defined range limit. Devices can connect from any location with a cellular signal. We aimed to ensure the setup's portability, in the event of future device relocation.
3. No Router Dependency: Cellular connectivity obviates the necessity for a nearby router since data flows directly from the device to the cellular network, much like a mobile phone. Given that the lab relies on a Wi-Fi network provided by a co-working facility, over which we have no control, opting for a cellular network affords us greater autonomy.
4. Resilient Connectivity: Wi-Fi is notorious for its inconsistency in various deployments, often exhibiting dead spots, requiring router resets, and susceptible to signal disruptions. In contrast, cellular data offers increased resilience and reliability, particularly for applications demanding constant, uninterrupted connectivity.
Hardware:As this is a portable device, it is important the network connectivity is reliable, offers low power consumption and is easy to use. Based on these factors the following hardware was selected and used in the device.
Blues LTE-M Global Notecard:
The Notecard functions as a device-to-cloud data transfer tool, simplifying the process of creating secure and dependable connected solutions through cellular technology. It is an embeddable System on Module (SoM) that can be seamlessly integrated with any microcontroller, whether for new projects or retrofitting, allowing you to use your own design or one of many specially designed Notecarriers.
You can easily send data to the cloud with just two lines of code within minutes, without the need for complex device registration or provisioning. Additionally, it features a robust JSON-based API, enabling you to program the Notecard via USB or control it from your preferred microcontroller or single-board computer using an open-source firmware library. You can establish a connection from your chosen host to the Notecard using either Serial or I2C communication methods.
SCD30 CO2 Sensor:
The SCD30 is a carbon dioxide (CO2) sensor developed by Sensirion. It is designed to accurately measure the concentration of CO2 in the ambient air. It uses NDIR technology to measure CO2 levels. NDIR sensors are known for their accuracy and stability in CO2 measurements. The SCD30 is designed to be energy-efficient, which is important for battery-powered and low-power IoT applications.
Blues Notecarrier A:
Notecarrier A is designed for building battery-powered wireless applications and has onboard cellular and GPS/GNSS antennas. It houses the LTE-M Global Notecard. The Notecarrier A has inbuilt solar charger IC for charging our LiPo battery.
Solar Panel:
The device uses a 6V 0.6W solar panel from Voltaic. The panel is highly efficient and can charge even at low lux levels.
STM32G0 MCU:
I have used a custom-designed STM32G0 based breakout board. You can use Blues Swan or any low-power MCUs. I have provided the schematic of the breakout board I have used for your reference.
Connect the battery, solar panel and the MCU to the notecarrier as per the above image. The connections are pretty straightforward and easy. Like mentioned before, this device uses a custom-made STM32G070KBT-based breakout board. The firmware is provided below with explanation for better understanding. The sensor and the Notecarrier are connected to the MCU on I2C.
Once the wiring part is done, the casing parts are to be 3D printed. The parts are given below in.stl format. Once the 3D printing part is complete, some post-printing process like removing support and sanding will be required depending upon positioning the model while slicing. Upon processing, 4 M3 inserts should be inserted on the legs that hold the notecarrier. The inserts can be easily inserted by using a solder iron as shown below.
#define uS_TO_S_FACTOR 1000
#define TIME_TO_SLEEP 570
#include "STM32LowPower.h"
#include <Arduino.h>
#include <SensirionI2cScd30.h>
#include <Wire.h>
SensirionI2cScd30 sensor;
static char errorMessage[128];
static int16_t error;
#include <Notecard.h>
#ifndef PRODUCT_UID
#define PRODUCT_UID "xxxxxxxxxxxxxxxxxxxxxxxx"
#pragma message "PRODUCT_UID is not defined in this example. Please ensure your Notecard has a product identifier set before running this example or define it in code here. More details at https://dev.blues.io/tools-and-sdks/samples/product-uid"
#endif
#define myProductID PRODUCT_UID
Notecard notecard;
void setup()
{
pinMode(PB2, OUTPUT); //Status
pinMode(PA8, OUTPUT); //Trigger
LowPower.begin();
Wire.setSDA(PA12);
Wire.setSCL(PA11);
Wire.begin();
digitalWrite(PA8, HIGH);
notecard.begin();
J *req = notecard.newRequest("hub.set");
JAddStringToObject(req, "product", PRODUCT_UID);
JAddStringToObject(req, "mode", "periodic");
notecard.sendRequestWithRetry(req, 5); // 5 seconds
Serial.begin(115200);
Wire.begin();
sensor.begin(Wire, SCD30_I2C_ADDR_61);
sensor.stopPeriodicMeasurement();
sensor.softReset();
delay(2000);
uint8_t major = 0;
uint8_t minor = 0;
error = sensor.readFirmwareVersion(major, minor);
if (error != NO_ERROR)
{
Serial.print("Error trying to execute readFirmwareVersion(): ");
errorToString(error, errorMessage, sizeof errorMessage);
Serial.println(errorMessage);
return;
}
Serial.print("firmware version major: ");
Serial.print(major);
Serial.print("\t");
Serial.print("minor: ");
Serial.print(minor);
Serial.println();
error = sensor.startPeriodicMeasurement(0);
if (error != NO_ERROR) {
Serial.print("Error trying to execute startPeriodicMeasurement(): ");
errorToString(error, errorMessage, sizeof errorMessage);
Serial.println(errorMessage);
return;
}
digitalWrite(PB2, HIGH);
}
void loop()
{
sensor.startPeriodicMeasurement(0);
float co2Concentration = 0.0;
float temperature = 0.0;
float humidity = 0.0;
for(int i = 0; i < 10; i++)
{
digitalWrite(PB2, HIGH);
delay(1000);
error = sensor.blockingReadMeasurementData(co2Concentration, temperature,
humidity);
if (error != NO_ERROR) {
Serial.print("Error trying to execute blockingReadMeasurementData(): ");
errorToString(error, errorMessage, sizeof errorMessage);
Serial.println(errorMessage);
return;
}
Serial.print("co2Concentration: ");
Serial.print(co2Concentration);
Serial.print("\t");
Serial.print("temperature: ");
Serial.print(temperature);
Serial.print("\t");
Serial.print("humidity: ");
Serial.print(humidity);
Serial.println();
digitalWrite(PB2, LOW);
delay(100);
}
sensor.stopPeriodicMeasurement();
J *req = notecard.newRequest("note.add");
if (req != NULL) {
JAddStringToObject(req, "file", "sensors.qo");
JAddBoolToObject(req, "sync", true);
J *body = JCreateObject();
if (body != NULL) {
JAddNumberToObject(body, "CO2", co2Concentration);
JAddNumberToObject(body, "Humidity", humidity);
JAddNumberToObject(body, "Temperature", temperature);
JAddItemToObject(req, "body", body);
}
notecard.sendRequest(req);
}
digitalWrite(PA8, LOW);
LowPower.deepSleep(TIME_TO_SLEEP * uS_TO_S_FACTOR);
}
Right now the device sends data every 5 minutes once. You can change the frequency by changing the below line in the firmware.
#define TIME_TO_SLEEP 570
Before uploading the code, you'll have to setup the Notehub. Once done, you'll need to add the ProductUID in the firmware in the below line:
#define PRODUCT_UID "xxxxxxxxxxxxxxxxxxxxxxxx"
Once everything is done, upload the below firmware in the MCU.
Setting up the Notehub & Notecard:Notehub is Blues' cloud service that enables the smooth transfer of data from a Notecard to the cloud application of your preference. Moreover, it comes at no cost, offering the benefit of up to 5, 000 events forwarded to a cloud app each month (data events sent from the Notecard to Notehub are always free of charge). You’ll need to create an account on the website and then create a new project as shown below.
Once a new project has been created, the productUID needs to be copied. The productUID is used by the Notehub to connect the Notecard and the project created.
Configuring Notecard:
First connect the Notecarrier A to a laptop via USB cable. A red LED blinks as soon as you connect. You can use the in-browser terminalprovided by Blues to connect with your Notecard.
You can proceed by clicking USB Notecard. To add the productUID, you’ll need to add the below request in the terminal.
{"req":"hub.set", "product":"com.xxx.xxxxx:incubator"}
To synchronize the Notecard with the Notehub, send the request below.
> {"req":"hub.sync"}
After the synchronization process is finished, you can see the Notecard connected to notehub.
Once this is done, you can connect the sensor and the MCU, every 10 minutes once, you can see the CO2 data in your events tab.
Routing the Data to Qubitro:
We will be displaying the sensor’s data using the Qubitro, a data streaming and visualization tool that's easy to set up and configure. We will need to create a Qubitro account.
📷📷
Once an account has been created you'll need to create a new project in Qubitro. Then click new source and select MQTT and enter the details. Once done, open the created MQTT source and select the connection details. It will show you all the credentials. We need these credentials to transfer our data to Qubitro.
We can create a route by clicking the Create Route link at the top right on the Notehub Route page. Select MQTT and enter the below mentioned details from your Qubitro account.
At the bottom of the page, define which data needs to be sent to Qubitro.
📷In the Notefiles section, select sensors.qo.
Go to data, and select JSONata in the transform data dropdown menu. Blues has a comprehensive tutorial about JSONata here. After that add the below code in the box below Transform Data. This allows Notehub to transfer only the below mentioned variables to Qubitro.
{
"temperature" : body.Temperature,
"humidity" : body.Humidity,
"CO2" : body.CO2,
"coordinates" : [tower_lat, tower_lon]
}
After setup, your data successfully transfers to Qubitro.
Using Location from Notecard:
There are 2 ways to get location data from the Notecard. The LTE-M Global notecard has GPS inbuilt. Additionally, location data can be accessed from the cell tower as well. I am using the tower based location data. To use GPS data, you need to enable GPS and send request current location data every time. A detailed explanation of using GPS in the Notecard is given here.
Data Visualization:
Now go to the Dashboards section and click on the Create Dashboard button. You will be asked to enter a name and a description for your dashboard. We will name it "Exposure Monitor". Then click on the Create button.
Once the dashboard is created, you can add and customize widgets as per your wish. I have created this dashboard for my personal use. The dashboard shows the places I have travelled along with the CO2 data. At some points, it is observed that the CO2 levels were two times more than the recommended levels.
Alerts:You can create alerts from your device once the recommended CO2 levels are crossed. Qubitro provides Rule functions for Mailgun, Twilio, Slack, etc. You can choose any and start configuring it.
To create a new Rule, go to devices and select Functions. Once you click Fucntione, you'll have to create a new Rule function and select any of them. This well-explained documentation will help you throughout the process.
Conclusion:Monitoring indoor CO2 levels has emerged as a critical tool for infection risk management, particularly in the context of the ongoing COVID-19 pandemic and other infectious diseases. High CO2 levels are not just a sign of poor ventilation and overcrowded spaces but also a potential indicator of heightened infection transmission risk. As we've seen, asymptomatic carriers can unknowingly contribute to the spread of diseases, making it imperative to identify areas with inadequate ventilation and overcrowding where interventions are needed.
The compact and travel-friendly design of the device described, featuring a solar panel, a battery, a microcontroller, a CO2 sensor, and cellular connectivity, represents a promising solution for monitoring CO2 levels effectively. By leveraging such innovative technology, organizations and building owners can ensure compliance with the guidelines set forth by health organizations like the CDC and WHO. This not only safeguards the health of occupants but also contributes to the broader goal of reducing disease transmission in indoor environments.
Get started by buying the same hardware I have used except the STM32 MCU. You can choose any STM32 based low power MCU or you can go ahead with Blues Swan.
Happy Making!
Comments