Dazdata BI is the first to integrate MQTT.js to realize real-time flow data visualization of Iot devices

 

Industrial equipment monitoring is integrated into the BI data screen. At present, there is no successful precedent for BI software. To realize this application scenario, two key problems must be solved:

1. MQTT is currently the basic protocol for IoT device data collection. To realize IoT device data collection, MQTT protocol must be connected.

2. At the same time, it is necessary to realize that the browser front-end can display timely streaming data of Iot devices, and at the same time improve the streaming data access display of the front-end visualization components.

Only when the above requirements are met can real-time flow data visualization of Iot devices be realized. Dazdata BI is the first to integrate the MQTT.js protocol, and at the same time fully supports the stream data support of visual components, opening up the application field of BI software cutting into industrial equipment monitoring.

Core code principle:

//Create mqtt subscription connection    

const client  = mqtt.connect('mqtt://192.168.98.130:12121')

//mqtt message response    

client.on('message', function (topic, message) {

    //mqtt receives data    

    showData.push([Date.now(),message.toString()])

    //Visual component display refresh    

    let option = Object.assign(

        baseOption,{series:[{data:showData,type:'line',smooth: true}]}

    );

    option && myChart.setOption(option);}

})

Guess you like

Origin blog.csdn.net/weixin_64346951/article/details/127298107