The implementation of smart HVAC maintenance using Machine Learning (ML) involves leveraging data analytics to early detect equipment failures and performance issues. By collecting and analyzing data from sensors like accelerometers, ML algorithms can detect faults early, improving system reliability, reducing downtime, and leading to cost savings. This approach is vital for outdoor HVAC units, which are often remote and challenging to monitor visually. Traditional scheduled maintenance may not catch issues in time, leading to costly mechanical failures between service intervals.
Here, we present a prototype of a device that addresses the problem of monitoring and ensuring the efficient operation of HVAC systems. To achieve this, we use the AVR-IoT Cellular Mini and an Arduino Nicla. The primary goal of this project is to record data from the accelerometer's x, y, and z axes. This data is going to be analyzed using a model trained in Edge Impulse. The AVR-IoT Cellular Mini's communication capabilities enable us to obtain real-time information about the HVAC system's status. This provides immediate awareness of any operational deviations, allowing for swift action.
Hardware- AVR IoT Mini Cellular Board: This is the main component responsible for establishing and handling communication with the Cloud and controlling the display.
- Arduino Nicla Sense Me: Used to run the machine learning anomaly model.
- Oled display 128x32 I2C: Used to show local information.
- Lithium Ion Cylindrical Battery - 3.7v 2200mAh: Allows the device to be used without requiring a permanent outlet power connection.
In the following figure, the connection between the components is shown. For communicating the Nicla and the AVR IoT board, we only use one terminal: PIN_PA7 on the AVR IoT board and GPIO3 on the Nicla. This connection is used to alert the AVR board of the occurrence of an anomaly.
The display is connected to the SDA and SCL terminals of the IoT board, corresponding to the Wire1 I2C port. The battery is connected to the AVR IoT board, while the Arduino Nicla Sense Me takes the voltage from the 3V3 and GND terminals.
For the AVR IoT board, the following libraries are going to be used:
- Adafruit_SSD1306.h for controlling the oled I2C display.
- AVR-IoT-Cellular to enable the communication using the cellular network.
The Arduino Nicla Sense Me was used to collect samples from the HVAC unit in operation and subsequently send them to the Edge Impulse platform for the development of the anomaly detection model based on ML. Samples from the three axes of the accelerometer (AccX, AccY, AccZ) were collected at a sampling frequency of 10 Hz. For feature extraction, a spectral analysis processing block was used, which extracts information about the frequency and power characteristics of a signal over time. For the analysis, each sample was divided into windows of 1000 ms with a 500 ms increment.
The anomaly detection model is based on the K-means algorithm, which is a popular clustering algorithm used in machine learning to partition a dataset into a predetermined number of clusters. The algorithm iteratively assigns data points to the nearest cluster centroid and then recalculates the centroids based on the mean of the data points in each cluster. This process continues until the centroids no longer change significantly or a specified number of iterations is reached. K-means aims to minimize the within-cluster sum of squares, making it effective for grouping data points based on similarity. Once the cluster or clusters in the data have been detected, any new data falling outside this area is considered an anomaly.
The figure shows the grouping of samples taken during the proper operation of the HVAC unit. Subsequently, the model was trained and tested.
Afterwards, Edge Impulse generated a library with the model which was used in our Nicla Sense Me firmware.
The firmware code uploaded to the Arduino returns an anomaly score based on the inference made. A threshold was set for the score, above which, the Nicla sets a HIGH level on GPIO3 terminal to inform the AVR IoT of the occurrence of an anomaly.
The figure illustrates how the model responds with a high anomaly score to an induced test anomaly.
For this project, we will utilize Azure as our cloud provider. Azure offers a free tier that enables us to create various types of resources at no cost, allowing to develop prototypes for solutions like this.
The cloud resources we are going to use for this project are shown in the following figure:
Resource group: This serves as a logical container holding related resources for a specific solution. Essentially, they function as folders for our other resources, facilitating clear separation and grouping, especially when managing multiple projects on the cloud.
To create a Resource Group, we initiate the process by selecting "Create a Resource" from the Azure Portal website. Then, we select "Resource Group", choose the appropriate Subscription, and name the resource group.
IoT Hub: This resource serves as a central message hub between our IoT devices and other resources hosted on the cloud. It enables secure communication (utilizing X.509 certificates in our case) and facilitates the ingestion of telemetry messages seamlessly.
To create this resource, we once again begin from the portal, click on "Create resource", select "IoT Hub", choose the resource group created in the previous step, assign a name to the hub, and in the Networking tab, select TLS v1.2.
Cosmos DB account: This database service allows us to store data without a specific schema. It is designed to be globally distributed, with fast scaling and throughput capabilities.
To create this resource, after selecting to create an Azure Cosmos DB, we choose "Azure Cosmos DB for NoSQL", select the previously created resource group, provide a name for the account, and leave the rest of the parameters as default.
Following the creation of the Cosmos DB account, we need to add a database and a container to store the messages sent by the device. For this, we provide a database and container name, as depicted in the figure.
App Service: This acts as a web hosting server, providing the infrastructure required for hosting the web application.
To provision the board, we first upload the provision.ino sketch, available under the examples of the AVR-IoT-Cellular library.
Then, using PuTTY, we initialize the provision for Azure, following these command selections:
Method to provision: MQTT.
Service: Azure IoT Hub.
Root CA: DigiCert Global Root G2.
Azure IoT Hub hostname: smarthvac.azure-devices.net.
The sketch returns the device ID and the thumbprint used by Azure to validate our device. Now, we need to add our device to the IoT Hub.
On the IoT Hub resource, click on "Devices" and then on "Add Device". We select "X.509 Self Signed" as Authentication type and fill in the data provided by the provision sketch.
Lastly, we need to add a route that allows us to save the telemetry messages in the Cosmos DB account. For this, we navigate to the "Message routing" tab and click on "Add Route". We select "Cosmos DB endpoint" as a type, fill in the data with the database and container created earlier, and use "true" as the Routing query for Device Telemetry Message. This configuration will save all data sent by the device to the database.
In the setup function, we initialize all the components. If any initialization fails, a message is printed on the Serial port and displayed on the OLED display. For the OLED display, we are using the I2C interface Wire1.
// ...
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C // 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, OLED_RESET);
// ...
void setup() {
// ...
pinMode(ANOMALY_TERMINAL, PIN_DIR_INPUT);
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Log.error(F("SSD1306 allocation failed"));
while (true) {}
}
if (!initTopics()) {
Log.error(F("Unable to initialize the MQTT topics. Stopping..."));
printTextDisplay("Memory error");
while (true) {}
}
printTextDisplay("Connecting...");
if (!Lte.begin()) {
Log.error(F("Failed to connect to operator"));
printTextDisplay("Connection error");
while (true) {}
}
// Attempt to connect to Azure
if (MqttClient.beginAzure()) {
MqttClient.subscribe(mqtt_sub_topic);
MqttClient.onReceive(onReceive);
} else {
printTextDisplay("Azure IoT error");
while (true) {}
}
}
In the loop function, we continuously read the anomaly terminal. If a HIGH level is detected, indicating an anomaly, then a message is sent to the Cloud.
void loop() {
printTextDisplay("Status: running");
if (digitalRead(ANOMALY_TERMINAL) == HIGH) {
Log.info("anomaly detected");
printTextDisplay("Anomaly detected!");
delay(2000);
const bool published_successfully = MqttClient.publish(mqtt_pub_topic, "{\"Anomaly\": true}");
if (published_successfully) {
Log.info(F("Published message"));
} else {
Log.error(F("Failed to publish\r\n"));
}
}
}
Web ApplicationA web application was developed to display the measurements from the device saved on the cloud. The application was built using Asp.Net Core and C# language. We won't delve into the entire web application development here, but we'll mention what is needed to replicate the project. All the code, except for the keys required to connect, is available on the GitHub link and in the Attachments section.
Smart HVAC Systems is a fictional company created by us that provided IoT and ML solutions to predict maintenance. The website consists of a landing page, showcasing information for the fictional company, and a Demo Device section displaying the most recent 10 anomalies detected. We are limiting it to 10 due to the constraints of the Cosmos DB account for the free tier.
If you wish to run this application on your own, you will need the keys to access the database. For that, you can navigate to the Keys tab in the Cosmos DB account and copy the URI, the primary key, and the database and container names.
Copy those values into the CosmosDB section of the file appsettings.json as follows:
"CosmoDb": {
"Account": "URI",
"Key": "Primary Key",
"DatabaseName": "Database Name",
"ContainerName": "Container Name"
}
ResultsFor the implementation, we utilized a plastic box. We used a magnet to attach the device to the exterior of the HVAC unit. This small magnet does not affect the performance of the unit. Its use facilitates easy removal and placement of the device without needing to compromise the aesthetics of the HVAC unit.
The next figure shows the components of the implemented system.
The following figure shows the device in operation.
The video shows the device in operation and how it responds to a test anomaly induced the HVAC unit.
And the online web application is shown in the next figure:
Here some useful statistics about the anomalies detected are shown, like time of last anomaly detected, and the average of anomalies per hour/day.
Future workSome things that remained pending in this version of the prototype and that will be resolved in future revisions are:
- Adding a switch that allows turning off the device without needing to open the case and disconnect the battery.
- Improving the case, perhaps by using a 3D printer, to obtain a more elegant design.
- Establishing Cloud-to-Device communication, allowing control from the web application of the anomaly detection algorithm. In this way, it could be stopped remotely to save battery when system monitoring is not desired.
- Adding more sensors that allow obtaining other useful information for the maintenance system, such as sensing electrical consumption.
We hope you enjoy this project and do not forget to leave your comments and feedback!
Comments