Building an IoT Data Hub for Smart Manufacturing
Use streaming data from edge devices to power machine learning models and smart applications by integrating MongoDB Atlas with Microsoft Azure IoT.
Industries: Manufacturing and Mobility
Products and tools: Atlas, Time Series, Atlas App Services, Atlas Device Sync, Atlas Triggers, Atlas Charts, Connector for Business Intelligence
Partners: Microsoft Azure
Solution Overview
The modern factory floor is full of unique machines and widgets, each producing its own sets of data, and interconnecting with each other to make a complex system that supports complex manufacturing processes and produces countless goods.
Being able to understand how the system is operating, and how to troubleshoot errors and bottlenecks, is critical to driving operational efficiency and building smarter manufacturing applications.
This solution shows how MongoDB Atlas can be used to radically simplify an IoT landscape, taking data from disparate edge devices and using that data to power smart applications for a variety of data consumers.
Other Applicable Industries and Use Cases
Automotive: Automotive is a subset of manufacturing. Car makers need to develop efficient production factories and manage a complex inventory of parts and services in order to maximize throughput of finished cars.
Telecommunications: Telecommunications is at the heart of edge and IoT as more people around the world conduct their lives and businesses through mobile and connected devices.
Healthcare: The healthcare industry is proving to be one of the largest industries affected by IoT. Wearable and connected devices are critical for providing care both within medical institutions and increasingly in other areas, such as within a patient’s own home and on their personal devices.
Reference Architectures
Without MongoDB:
It’s common in many manufacturing environments to have unique systems running their own proprietary software, often with a relational database in the background, or a niche database covering time-series and graph use cases.
The challenge with this approach is that as the number and type of databases becomes unmanageable, architectural complexity increases, and it becomes more difficult to move data between disparate systems and connect them to newer, smarter applications.
Figure 1: Reference Architecture Without MongoDB
With MongoDB:
With MongoDB Atlas, architectural complexity is reduced, as the versatility of the document model allows teams to structure data in any way their application needs. The expressive API and indexing also allow teams to query data any way they want.
Figure 2: Reference Architecture With MongoDB
Data Model Approach
Sensors in a factory may be streaming time-series data for multiple machines, capturing the following data points:
Product Type
Air Temperature (K)
Process Temperature (K)
Rotational Speed (rpm)
Torque (Nm)
Tool Wear (min)
In a relational database, you would likely have to create multiple tables to effectively store this varied data. But with MongoDB and the flexible document data model, you can use a single collection to store all sensor data coming in using time-series collections . For example:
{ "device_id": 1, "sensor_id": 12345, "start_date": ISODate("2023-01-31T10:00:00.000Z"), "end_date": ISODate("2023-01-31T10:59:59.000Z"), "measurements": [ { "timestamp": ISODate("2023-01-31T10:00:00.000Z"), "temperature": 298.1 "speed": 1551 "torque": 42.8 "failure": “No failure” }, { "timestamp": ISODate("2023-01-31T10:01:00.000Z"), "temperature": 302.4 "speed": 1410 "torque": 65.7 "failure": “Power failure” }, ... { "timestamp": ISODate("2023-01-31T10:42:00.000Z"), "temperature": 298.8 "speed": 1455 "torque": 41.3 "failure": “Tool wear failure” } ], "transaction_count": 4223, "avg_temperature": 300.7 }
We can then use the MongoDB aggregation framework to easily query time-series data. For example, we can group documents by the date of the sensor measurement and return functions like average.
Building the Solution
Figure 3: Solution Overview
This solution showcases how you can build a smart manufacturing hub using MongoDB Atlas and Azure IoT Edge. The example use case is sending sensor data from CNC machines to Azure IoT Hub, with selected data streamed to MongoDB Atlas for use in a variety of data consumers, such as factory workers with mobile devices, and analysts using MongoDB Charts.
To illustrate this solution in practice, we will create a machine learning model that will predict the root cause of machine failure based on sensor data. The detailed guide and associated sample data, functions, and code can be found in this solution repository.
Train your ML model
You can use MongoDB as a feature store to train ML models, and once models are trained, those binaries can be converted and stored in another MongoDB collection for analysis. Refer to this notebook to train your ML model, and once your models are trained, use this model to make predictions using Azure functions.
Set up Azure IoT Hub
We use Azure IoT Hub to connect, monitor, provision, and configure IoT devices. Use this link to set up IoT Hub in your Azure account, and when you’re ready, register a new device.
Simulate IoT data
To generate data for our sample solution, we built this web app to simulate data flow to Azure IoT.
Serve data to Azure Stream Analytics
Once data is in Azure IoT Hub, it can then be served to Stream Analytics for filtering, then pushed into MongoDB. Follow these instructions to set up a Stream Analytics job, then add IoT Hub as an input for that job.
Use Azure functions to push data to MongoDB Atlas
Now that data is in Stream Analytics, you can push it to a time-series collection in MongoDB Atlas using this function to serve a variety of use cases and data consumers. You canalso run your machine learning model to get failure inferences using this function.
Use MongoDB Atlas to turn data into insights
Once your machine failure data is in MongoDB Atlas, you can easily put it in the hands of users through MongoDB’s platform services. You can build a mobile app using Atlas Device Sync to send notifications and alerts to floor supervisors, or you can use Mongo Charts to create visualizations for BI teams.
Technologies and Products Used
MongoDB modern, multi-cloud database platform:
Partner technologies:
Key Considerations
This solution walks you through a simple configuration to learn how to generate IoT data, use it to run machine learning models, and store that data in MongoDB Atlas to use in business applications.
MongoDB is a great choice for IoT applications because it is a highly scalable document-based database that can handle the high volumes of data that IoT applications generate.
MongoDB’s flexible document model makes it well-suited to handle the different types of data structures needed to store a wide range of IoT devices and ML models, without requiring separate databases for different data types.
Author
Diana Annie Jenosh, MongoDB
Utsav Talwar, MongoDB
Dr. Humza Akhtar, MongoDB