Recently, PM 2.5 becomes a very popular issue. There are many products such like LASS4U, airbox and so on, to help us understand the influence of air pollution.  Among this, LASS (Location Aware Sensing System, http://lass-net.org/) , an open source and nonprofit “envirnment detecting system, can collect many meaningful data to monitor the quality of air. Besides,  Its hardware has better specification and completement. It can collect the data of CO2, temperature、humidity 、PM2.5, (PM1、PM10), and the touchscreen allows user to get the instant information without opening web page and application.

Besides, NAS also play an important role in this issue due to the importance of data storage. The following will simply introduce how to transfer LASS4U data to NAS by Node-Red, and process it via IoT system.   

First, you need to prepare:

(How to install Node-Red or Freeboard, you can refer to previous tutorial)

  1. QNAP NAS

  2. Node-Red

  3. Freeboard or Dashboard


 

Get the MQTT information from LASS4U:

MQTT Host: gpssensor.ddns.net:1883

MQTT Topic: LASS/Test/LASS4U

Now, you can build a MQTT node by Node-Red, and add server and fill in LASS4U topic:

[gallery size="full" columns="1" ids="3209"]

After building the connecting, check the number of LASS4U:

[gallery columns="1" size="full" ids="3210"]

The version of mine is FT2_0018.

 

Then, start to process the  LASS4U data. The figure shows the function node of Node-Red.

[gallery size="full" columns="1" ids="3211"]

This node is used to process the subscribed data of MQTT via LASS4U., which refer to the topic of LASS/Test/LASS4U. If you want to process multiple LASS4Us, you can use the function node multi-output feature to create different data streams.
if(msg.payload.indexOf("FT2_0118")!=-1){
return [msg, null];
}else if(msg.payload.indexOf("FT2_0004")!=-1){
return [null, msg];
}

2, 4 Mainly, the two devices FT2_0118 and FT2_0004 are respectively directed to two different outputs.

[gallery size="full" columns="1" ids="3212"]

Through the debug node, you can check whether there is data that normally grabs LASS4U.

The following is the environmental data of the FT2_0118 device captured from LASS4U:

|ver_format=3|FAKE_GPS=1|app=LASS4U|ver_app=beta|device_id=FT2_0118|date=2017-02-13|time=04:23:57|device=Ameba|gps_lon=24.796937|gps_lat=121.005882|s_t2=21.41|s_h2=50.61|s_d0=10.00|s_g8=664.00|s_d2=8.00|s_d1=10.00

The definition of each field:

date: date

time: time

gps_lon: The GPS position currently set for this device

gps_lat: The GPS position currently set for this device

s_t2: temperature

s_h2: humidity

s_g8: Co2

s_d2: PM 2.5

s_d1: PM2.1

Aftering getting the definition of each field, process the LASS4U data again, and show the required sensing data on dashboard.

[gallery size="full" columns="1" ids="3213"]

First, the data of the LASS4U needs to be cut first by the split node and pushed to the Process Sensor Data for processing. The second step is to push the processed data to the Dashboard through the output 1~7.

First, split the LASS4U data by split node, and push it to Process Sensor Data. The second step  is to push the processed data to the Dashboard through the output 1~7.

 

Process the sensed data by function node:
var sensorData = msg.payload;
if(sensorData.indexOf("gps_lon")!=-1){
var sensorValue = sensorData.replace('gps_lon=', '')
msg.payload = sensorValue;

return [msg, null, null, null, null, null, null];
}else if(sensorData.indexOf("gps_lat")!=-1){
var sensorValue = sensorData.replace('gps_lat=', '')
msg.payload = sensorValue;

return [null, msg, null, null, null, null, null];
}else if(sensorData.indexOf("s_t2")!=-1){
var sensorValue = sensorData.replace('s_t2=', '')
msg.payload = sensorValue;

return [null, null, msg, null, null, null, null];
}else if(sensorData.indexOf("s_h2")!=-1){
var sensorValue = sensorData.replace('s_h2=', '')
msg.payload = sensorValue;

return [null, null, null, msg, null, null, null];
}else if(sensorData.indexOf("s_g8")!=-1){
var sensorValue = sensorData.replace('s_g8=', '')
msg.payload = sensorValue;

return [null, null, null, null, msg, null, null];
}else if(sensorData.indexOf("s_d2")!=-1){
var sensorValue = sensorData.replace('s_d2=', '')
msg.payload = sensorValue;

return [null, null, null, null, null, msg, null];
}else if(sensorData.indexOf("s_d1")!=-1){
var sensorValue = sensorData.replace('s_d1=', '')
msg.payload = sensorValue;

return [null, null, null, null, null, msg, null];
}

 

1: Get the splitted data, and it will be transferred separately.

2-6: Process the gps-lon data, and remove  the string “gps_lon=”

6, 11, 16…... mainly the corresponding output positions of the function node

return [msg, null, null, null, null, null, null]; //output 1

return [null, null, null, msg, null, null, null]; //output 4

[gallery columns="1" size="full" ids="3214"]

After the success, we can see the LASS4U data shown on the  NAS dashboard

Follow-up: In addition to the real-time rendering of LASS4U data to the NAS, Node-Red can also quickly process and transfer data to the back-end database and front-end web pages. It can even analyze the data and send it to the cloud service platform. To make the data more diversified.

 
arrow
arrow
    全站熱搜

    tttt 發表在 痞客邦 留言(0) 人氣()