Hướng dẫn chi tiết
Bài 5: Xem dữ liệu trên MQTT Dashboard
Kết nối MQTTX tới mqtt.iotlabs.vn, subscribe các topic của gateway và xem dữ liệu realtime. Tùy chọn: Mosquitto local, Node-RED.
Cập nhật 10/05/2026
Công cụ: MQTTX
MQTTX là MQTT client miễn phí, tải tại mqttx.app.
Bước 1 — Tạo kết nối trong MQTTX
- Nhấn + New Connection
- Điền thông tin:
Name: IoTLabs Gateway Host: mqtt.iotlabs.vn Port: 1883 Username: [tài khoản IoTLabs] Password: [mật khẩu IoTLabs]
- Nhấn Connect — thanh trạng thái xanh = kết nối thành công
Bước 2 — Subscribe nhận dữ liệu
Nhấn + Add Subscription, điền topic:
iotlabs/org_demo/gateways/gw_edu_001/#
Ký tự # nhận tất cả topic con của gateway.
Topics cụ thể
| Dữ liệu | Topic |
|---|---|
| Door sensor | iotlabs/org_demo/gateways/gw_edu_001/devices/door_sensor_01/telemetry |
| BLE node n01 | iotlabs/org_demo/gateways/gw_edu_001/devices/n01/telemetry |
| NRF node | iotlabs/org_demo/gateways/gw_edu_001/devices/nrf_soil_01/telemetry |
| Gateway status | iotlabs/org_demo/gateways/gw_edu_001/status |
Mosquitto CLI (tùy chọn)
# Subscribe
mosquitto_sub -h mqtt.iotlabs.vn -u YOUR_USER -P YOUR_PASS \
-t "iotlabs/org_demo/gateways/gw_edu_001/#" -v
# Test publish
mosquitto_pub -h mqtt.iotlabs.vn -u YOUR_USER -P YOUR_PASS \
-t "iotlabs/org_demo/gateways/gw_edu_001/devices/test/telemetry" \
-m '{"mode":"gpio","metrics":{"door_open":true}}'
Mosquitto Local (tự cài)
# macOS
brew install mosquitto && brew services start mosquitto
# Ubuntu
sudo apt install mosquitto mosquitto-clients
sudo systemctl start mosquitto
Sau đó trong config.h đổi: #define MQTT_HOST "192.168.1.100" (IP máy local).
Node-RED Dashboard (nâng cao)
npm install -g node-red→node-red- Mở
http://localhost:1880 - Kéo node mqtt in → cấu hình host
mqtt.iotlabs.vn+ topic - Kéo node json → debug → nhấn Deploy
