Skip to main content

Learn how to read machine data with an edge device, use Azure for visualization, and prepare the data for further processing. 

Based on a proof of concept, the core element here is an edge device that interrogates the database of a production robot outfitted with an OPC-UA interface, and uploads the data to IoT Central. 

The edge device interrogates the database and uploads the data to IoT Central. A Visual Studio Code application is uploaded as docker images in the Azure container registry, and deployed on the device via IoT Central. The data are then exported to Azure’s blob storage.

 

Hardware Preparation

First, you must install the Ubuntu Server 18.4 on the device, followed by IoT Edge runtime, which functions as the runtime environment to execute the code on the edge device with containers. For details, click here. The documentation also shows how to link the device to IoT Central.

Software Preparation  

Next, you set up the environment in which you want to develop the edge device code. Use Visual Studio Code with the Azure IoT Extension here, and create a new IoT solution in Python and develop the code to read data from the machine.  

 

Our IoT Edge solution is in two modules. The DataModule reads the data, whereas the UploadModule filters, formats, and sends the data to IoT Central. Use routers for the modules to communicate with IoT Central: in config.json define which inputs and outputs go where from which module. Below is the JSON configuration for the module: 

In our case, output1 from the DataModule goes to input1 of the UploadModule. In turn, output1 from the UploadModule goes to $upstream, which is IoT Central. You can access the inputs and outputs with the Python code, by receiving or sending asynchronous messages there. Below is the relevant Python code to read and send messages:  

Container image and deployment build 

Once you have a version of the code you wish to deploy, create docker images with the IoT extension, and upload them into the container registry.  

The extension also creates a deployment file for you. This has all the information the edge device needs for migration to the latest version, such as, “Which modules are needed in which version?”, “How to reach the registry, including credentials, network configurations”, etc.  

Reading and visualizing in IoT Central 

Next, create a new device template in IoT Central for “Azure IoT Edge” and upload the first deployment file for that. IoT Central will recognize the module you want to deploy. You must also define details of the data for each module. In your case, send a JSON comprising four dictionaries at the highest level. This means, you first set up four elements of type object, and the respective subfields as double, string, Boolean, etc.  

You can define the desired visualization under views, for which you have a choice of several standard ones. Your goal should be to get a quick look at the data covering the last few minutes or hours. Since IoT Central does not work as a comprehensive visualizing or reporting tool, use PowerBI instead, for instance, to get detailed reports.  

 

Once the template is ready, save and migrate it to your device. The procedure to update the version in your device is similar: in place of a new template, you create a new version from the existing one; save this and then migrate it to the device. The Edge device automatically downloads the new software version and restarts the necessary modules, without you having to directly connect with the device. This is one strength of IoT Central: one can update many Edge devices without accessing them directly – but the devices must be connected to IoT Central.  

 

The overview of devices has many tabs:  

  • View displays the visualized data 

  • Modules shows which module is running in which version on the device 

  • Raw Data shows the unprocessed data 

 

For long-term storage of the data, you must select Data Export from the menu and configure the telemetry for export. This allows you to use the data for other purposes.  

Summary 

You are now capable of deploying your own code on a device, which interrogates a production robot to visualize and save the data in Azure. The next possible steps could be to process and visualize all the data collected, again in Azure: we’ll delve into this soon in another blog.   

 

Azure offers all the tools you need to collect and process IoT data. You can use the combination of your own programming in your Python modules and a pre-defined path to deploy the code and further process data in IoT Central. This gives you the flexibility, as needed, without having to develop new things when a standard process is feasible.  

 

 

 

Interested in taking your IoT data to the cloud, or initiating visualization, reports, and predictive maintenance? Get in touch. We’ll gladly guide you along each step of your journey into the Internet of Things!

Take your first step!