close
2017-02-13-13.14.55-e1486963093157

LASS4U & QNAP NAS

The topic focusing on PM 2.5 was very popular. In the last two years, similar products such as LASS4U and air boxes have successively emerged, helping the public understand the impact of air pollution. Among these products, LASS (Location Aware Sensing System, http://lass-net.org/), an open-source public-welfare environment sensor network system from Taiwan, provides significant data and helps the public to monitor the air quality of their surroundings. From the author’s view, LASS4U is the one featured with highest hardware specifications and integrity among multiple projects. In addition to monitoring carbon dioxide, temperature, humidity, and PM2.5 (PM1, PM10), it also features a touch screen, which allows users to access real-time information without opening web pages or a mobile app. 

Certainly, NAS is also an integral part - as data storage is very important. Next, I will show you how to import LASS4U data via NAS Node-Red and how to process air pollution data with the powerful NAS IoT system.

First, prepare the following items (if you are not clear about how to install Node-Red or Freeboard, refer to previous articles):

  1. QNAP NAS

  2. Node-Red

  3. Freeboard or Dashboard


We can acquire relevant MQTT information from LASS4U:

  • MQTT Host: gpssensor.ddns.net:1883

  • MQTT Topic: LASS/Test/LASS4U


Then, set one MQTT node directly with Node-Red, add a new server and insert it into the topic LASS4U:

 

MQTT_LASS4U-1024x342

After connecting MQTT successfully, find LASS4U No.:

LASS4U_No-768x1024

 

The current No. is FT2_0018.

Next, let’s start processing LASS4U data. The following diagram shows the function node newly added with Node-Red.

Screen-Shot-2017-02-13-at-12.12.57-PM-1024x300

 

This node is mainly used to process MQTT data subscribed via LASS4U. Since LASS4U will transfer the data of all devices to the topic LASS/Test/LASS4U, various data streams can be established by using the multiple output feature of function node in case of processing of multiple LASS4Us.
if(msg.payload.indexOf("FT2_0118")!=-1){
return [msg, null];
}else if(msg.payload.indexOf("FT2_0004")!=-1){
return [null, msg];
}

2, 4 Mainly lead the two devices FT2_0118 and FT2_0004 to two different outputs separately.

LASS4U_Node-300x243

 

With debug node, we can check whether normally-captured LASS4U data exists.

The following information is environment data of FT2_0118 captured with 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

Definitions of data for each field:

date: date

time: time

gps_lon: current GPS location set on this device

gps_lat: current GPS location set on this device

s_t2: current temperature

s_h2: current humidity

s_g8: current CO2 density

s_d2: current PM 2.5

s_d1: current PM 1.0

After acquiring definitions of data for each field, then we need one more processing of LASS4U data. After processing the required sensor data, we push them to the Dashboard and have the related data displayed.

First, split LASS4U data with split node and push them to Process Sensor Data for processing. Second, output the processed data as 1 to 7 and push them separately to the Dashboard.

LASS4U_Sensor-1024x1018

 

Similarly, process the sensor data with 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:  Acquire the split data, and transfer them in sequence separately.
2~6:
 Process gps_lon data and remove strings in “gps_lon=”.1:  Acquire the split data, and transfer them in sequence separately.

6, 11, 16…: mainly correspond to each output location of function node

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

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

After successful operation, we can see LASS4U data shown on NAS Dashboard.

LASS4U_Dashboard-1024x580

Subsequently: with Node-Red, we can not only realize real-time displaying of LASS4U data on NAS but also quickly process the data and transfer it to backend database and frontend web pages. Moreover, we can even transfer the processed and analyzed data to a cloud-based service platform for diverse usage purposes.

To know more about QIoT Container please visit our website.

 
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 tttt 的頭像
    tttt

    觀察筆記

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