MQTT - 將 PM2.5 數據上傳到 LASS 系統

LASS 簡介

The LASS stands for “Location Aware Sensor System”. It is an open project and was started only for the interest of public welfare. Find detailed introduction here. Practically, LASS is based on MQTT protocol to collect all kinds of uploaded data, and for those who need these data can subscribe top as well. Find more LASS information at their official hackpad.

材料准備

  • AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1

  • PlanTower PMS3003 or PMS5003 x1

範例説明

這個範例裡,我們會使用到Ameba網站裡提到的其它應用,包括:

  • MQTT:: 用來連上LASS的MQTT-Broker,其中Client為“FT1_0XXXX”, 後面四位數為Ameba的Wifi Mac後4碼,outTopic則是“LASS/Test/Pm25Ameba/clientID ” 後面的clientID為實際上Ameba的MQTT client ID

  • NTP: 上傳的資料裡需要時間的註記

  • PM2.5: 上傳的資料裡帶有PM2.5的資訊

Open the example. “File” “Examples” “AmebaMQTTClient” “lass_basic”

../../../../_images/image119.png

This example requires internet connection, so make sure you fill in SSID and PASS into AP information that you wish to connect. Also, LASS requires GPS information. There is no GPS sensor included in this example, so you must manually provide GPS information. Use Google Map to find the coordinates you plan to place your Ameba. You can see in this example that the latitude is 24.7814033, and the longitude is 120.9933676

../../../../_images/image217.png

我們將GPS的資訊填入gps_lat與gps_lon裡

../../../../_images/image313.png

接著按照UART – PlanTower PMS3003的範例接線方式將sensor接上

AMB21 / AMB22:

../../../../_images/image4-1.png

AMB23:

../../../../_images/image4-2.png

BW16:

../../../../_images/image4-3.png

BW16-TypeC:

../../../../_images/image4-4.png

接著編譯程式碼並上傳到Ameba, 按下Reset按鈕之後, Ameba就會每一分鐘嘗試讀取PM2.5的資料, 並上傳到LASS MQTT-Broker。打開Serial Monitor,可以看到上傳的資訊,包括client id, topic, 目前的pm2.5數值。

../../../../_images/image511.png

We can also use MQTTlens to verify if the data is properly uploaded. Enter “gpssensor.ddns.net” as the MQTT-Broker server and “LASS/Test/PM25/live” as the subscribe topic to receive data.

裡面的資訊裡,時間使用UTC格式,而PM2.5的資料放在s_d0的地方,在圖中可以看到s_d0=9代表PM2.5的數值是9,代表整個publish/subscribe的流程都成功運作。

../../../../_images/image66.png