Updated with additional resources

In the era of Industry 4.0, NEXCOM is looking to adopt IoT technologies and undergo a digital transformation. They decided to work with Microsoft to bring more connectivity and intelligent capability to their products. The Microsoft Taiwan DX team and NEXCOM worked together to ease the adoption of an Azure IoT solution and resolve any technical issues in the journey.

The following were key participants in the NEXCOM hackfest with Microsoft:

  • Bob Chen – Chief Architect, R&D, NEXCOM
  • CL Chiang – IoT BG Director, NEXCOM
  • Allan Chen – IoT BG Manager, NEXCOM
  • Jennifer Chiu – DX Audience Evangelism Manager, Microsoft
  • Herman Wu – DX Technical Evangelist, Microsoft

Customer profile

Taiwan-based NEXCOM is a market leader for industrial device manufacturing, with more than 250 R&D employees. Its key product line includes gateways, embedded systems, industrial PCs, and factory automation products.

NEXCOM recently restructured and renamed one of its business units as IoT Automation Solutions (IAS) to broaden its industrial IoT vision. Also, it divided its sales force into six dedicated business units to target rapidly expanding vertical markets. These business units include IoT Automation Solutions (IAS), Intelligent Digital Security (IDS), Internet of Things (IoT), Interactive Signage Platform (ISP), Mobile Computing Solutions (MCS), and Network and Communication Solutions (NCS).

Problem statement

An IoT solution includes a lot of new technologies for telemetry information ingestion, process, analytics, security, and reporting. NEXCOM has very good products for industrial scenarios, but connecting these products to the cloud requires new skill sets. NEXCOM knows it faces a learning curve for these skills. Also, Azure has a lot of IoT-related components. NEXCOM wants help sorting out which components are best for which parts of the scenario and how to integrate them.

Solution and steps

After discussions with NEXCOM, we decided the Azure IoT Suite remote monitoring solution template would be a good starting point for quickly creating a fully functional and scalable IoT solution. With the Azure IoT suite:

  • Telemetry information from the NEXCOM gateway is collected, analyzed, and stored.
  • Users can get the latest device status from the NEXCOM Smart Gateway web portal.
  • Users can control the NEXCOM gateway from the NEXCOM Smart Gateway web portal.
  • Abnormal events can be detected in real time.

NEXCOM Smart Gateway Solution Discussion 2

The following technologies are used in the solution:

  • Azure IoT Hub
  • Azure Event Hubs
  • Azure Stream Analytics
  • Azure DocumentDB
  • Azure App Service
  • Power BI visuals
  • Azure Blob storage

IoT devices

NEXCOM NISE 50C industrial gateway is used to connect to the Azure IoT Hub. It sends telemetry information through the MQTT protocol. NISE 50C supports Windows 10 IoT core and Android 4.4. In this case, it will need to send data to the Azure IoT Hub every 30 seconds. The payload of each data package is about 800 bytes.

Security

Security is essential and fundamental to the industrial IoT solution. In the solution, we ensure the system is secure through:

  • IoT Hub identity registry. IoT Hub securely stores device identities and security keys in the identity registry. It also provides access control policies for device registry.
  • Connection security. TLS with X.509-based certificates is used to encrypt the communication channel.
  • Cloud security. Azure IoT Suite uses Azure Active Directory (Azure AD) for user authentication and authorization. All security keys are stored in secure storage.

Architecture

The final system architecture is shown in the following diagram.

NEXCOM Smart Gateway Reference Architecture Design

  1. NEXCOM Smart Gateway sends telemetry data to Azure IoT Hub every 30 seconds.
  2. Telemetry information is processed by different Azure Stream Analytics jobs based on telemetry type.
  3. If telemetry data meets the alert criteria, an alerts event is triggered.
  4. From the portal, the user can send commands to the NEXCOM Smart Gateway to control the device.
  5. Telemetry information is displayed using Power BI visuals.
  6. NEXCOM Smart Gateway properties and command history are saved in DocumentDB.

Code artifacts

The solution has these three key parts:

  • NEXCOM Smart Gateway connection to Azure IoT Hub through MQTT
  • Azure IoT Suite setup and configuration
  • Customized real-time dashboard

NEXCOM Smart Gateway connection to Azure IoT Hub

Because NEXCOM already adopted MQTT for IoT device communication, MQTT compatibility is important to them. In the solution, we validate the connectivity on Windows 10 IoT core. We use C# programming language and a third-party MQTT library, uPLibrary.Networking.M2Mqtt, instead of a standard Azure IoT Hub SDK to verify MQTT connectivity behavior. NEXCOM can apply the same MQTT parameters using a Java version of MQTT SDK on their Android version gateway.


	
	        static string deviceID = "NEXCOMSmartGatewayDeviceID";
	        static string iotBrokerAddress = "xxxxxx.azure-devices.net";
	        static string userName = xxxxx.azure-devices.net/"+ deviceID;
	        static string password = "SharedAccessSignature sr=xxxx.azure-devices.net%2fdevices%2fXXXXXXXXXXXXXXXXXXXX";
	        static string topics = "devices/"+ deviceID + "/messages/events/ ";

			//Creat MQTT Client with default port 8883 using TLS protocol
            MqttClient mqttc = new MqttClient(iotBrokerAddress, 8883, true, null, null, MqttSslProtocols.TLSv1_0);
 
            byte code = mqttc.Connect(deviceID, userName, password);

            string strValue = Convert.ToString("NEXCOM IoT telemetry data");
     
            mqttc.MqttMsgPublishReceived += onReceive;

            mqttc.Subscribe(new[] { "devices/" + deviceID + "/messages/devicebound/#" }, new[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE });

            float temp = 80;
            while (true)
            {
                if(!mqttc.IsConnected)
                {
                    Console.WriteLine(DateTime.Now.ToString() + "[MQTT Client]" + " is Disconnected");
                    break;
                }

                // get temperature value... 
                temp = temp + 1;
                // ...publish it to the broker 
                Debug.WriteLine("[MQTT Client] Start to send : " + temp.ToString());
                Console.WriteLine(DateTime.Now.ToString()+"[MQTT Client] Start to send : " + temp.ToString());
               
				//Publish telemetry data using AT LEAST ONCE QOS Level
                mqttc.Publish(topics, Encoding.UTF8.GetBytes(strValue + temp), MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE, false);

                Debug.WriteLine("[MQTT Client] Sent : "+temp.ToString());
                Console.WriteLine(DateTime.Now.ToString() + "[MQTT Client] Sent : " + temp.ToString());

                Thread.Sleep(1000);
                if (temp > 200) temp = 80;

            }

Azure IoT Suite setup and configuration

Azure IoT Suite contains several components such as IoT Hub, Stream Analytics, DocumentDB, and App Service. We used Azure IoT Suite to deploy the script to set up the NEXCOM Smart Gateway portal and used Visual Studio 2015 to customize the portal, which is based on ASP.NET MVC5.

NEXCOM S Azure IoT Suite Solution deployed on Azure

Here is the customized NEXCOM Smart Gateway portal remote monitor.

NEXCOM Smart Gateway portal remote monitor

Confirmation that all NEXCOM devices are connected to the portal. The user now can send commands to devices on the portal.

NEXCOM Smart Gateway portal device properties and commands to device

Customized real-time dashboard

Telemetry information visualization is important for an IoT dashboard—most IoT dashboards need to display real-time data. To achieve the real-time requirements of the dashboard, we leveraged the Power BI Visual JavaScript library to display data in a different chart type.


            // Create Defaul Style 
 			var createDefaultStyles = function createDefaultStyles() {
            
            var dataColors = new powerbi.visuals.DataColorPalette();
            
            return {
                titleText: {
                    color: { value: 'rgba(51,51,51,1)' },
                    fontFamily: 'Verdana'
                },
                subTitleText: {
                    color: { value: 'rgba(145,145,145,1)' }
                },
                colorPalette: {
                    dataColors: dataColors,
                },
                labelText: {
                    color: {
                        value: 'rgba(51,51,51,1)'
                    },
                    fontSize: '11px'
                },
                isHighContrast: false,
            };
        };
        
        var createVisual = function createVisual() {
            
            var height;
            var pluginService;
            var singleVisualHostServices;
            var width;
            
            // Use PowerBI Visual 
            pluginService = powerbi.visuals.visualPluginFactory.create();
            singleVisualHostServices = powerbi.visuals.defaultVisualHostServices;
            
            height = $(targetControl).height();
            width = $(targetControl).width();
             
			// Choose Charting type
            visual = pluginService.getPlugin('columnChart').create();
              
            visual.init({
                // empty DOM element the visual should attach to.
                element: targetControl,
                // host services
                host: singleVisualHostServices,
                style: createDefaultStyles(),
                viewport: {
                    height: height,
                    width: width
                },
                settings: { slicingEnabled: true },
                interactivity: { isInteractiveLegend: false, selection: false },
                animation: { transitionImmediate: true }
            });
            
            hasVisualBeenInitialized = true;
        };
        
        var init = function init(telemetryHistorySettings) {
            
            targetControl = telemetryHistorySettings.targetControl;
            
            targetControlContainer =
                telemetryHistorySettings.targetControlContainer;
            
            targetControlSubtitle =
                telemetryHistorySettings.targetControlSubtitle;
            
            targetControlTitle = telemetryHistorySettings.targetControlTitle;
            
            createVisual();
        };
        
        // Prepare Data
        var produceGraphData = function produceGraphData(data) {
            
            var dateTime;
            var i;
            var item;
            var results;
            
            results = {
                timestamps: []
            };
            
            if (data[0]) {
                for (var field in data[0].values) {
                    results[field.toLowerCase()] = [];
                }            
                for (i = 0 ; i < data.length ; ++i) {
                    item = data[i];
                    for (var field in item.values) {
                        results[field.toLowerCase()].push(item.values[field]);
                    }
                    
                    dateTime = new Date(item.timestamp);
                    if (!dateTime.replace) {
                        dateTime.replace = ('' + this).replace;
                    }
                    
                    results.timestamps.push(dateTime);
                }
            }
            
            return results;
        };

Opportunities going forward

NEXCOM products are used in facilities and factories worldwide. With NEXCOM’s increased understanding of the Microsoft IoT solution and a successful proof of concept, it is designing a solution that can further leverage the connectivity and intelligent capability powered by Azure. In the next step, NEXCOM will work with Microsoft to enhance the IoT device monitor dashboard and analytic report.

“The co-work directly with Microsoft largely reduced the learning curve of adopting Azure IoT solutions for us. It would take months to build the solution, but we did it in weeks. The IoT market is booming and time-to-market is very important.”

—Allan Chen, NEXCOM IoT BG manager

Without the great teamwork between NEXCOM and Microsoft, it would not have been possible to achieve this result.

NEXCOM Smart Gateway solution team discussion

Additional resources