
03,MQTT 設定
116 Comments
MQTT 設定
什麼是MQTT?
如果要使用MQTT (一種及時通訊的方法,就像是Line 一樣,馬上就能拿到資料)
在你的電腦安裝MQTT :
Linux lnstall
$ sudo apt-get install mosquitto mosquitto-clients
Linux Get iFrogLab LoRa Gateway MQTT message
$ mosquitto_sub -d -t ifroglab/mqtt -h test.mosquitto.org
Mac Install
$ brew install mosquitto
Mac Get iFrogLab LoRa Gateway MQTT message
$ mosquitto_sub -d -t ifroglab/mqtt -h test.mosquitto.org
Android, iOS, Raspberry Pi , Linux 等,可以參考此文章。
更多其他平台的設定,可以看官方設定這裡。
如果要接收MQTT 的資料:
我們會把LoRa 所收到的資料,透過 test.mosquitto.org 的群組ifroglab/mqtt 送出,
所以只要透過MQTT Mosquitto 就能收到,例如
mosquitto_sub -d -t ifroglab/mqtt -h test.mosquitto.org
如果要修改MQTT 的名稱:
請把檔案 ap-01-lora-gateway-2-read-httpGet.py 打開找一下
mqtt=” mosquitto_pub -d -t ifroglab/mqtt -m ‘%s’ -h test.mosquitto.org”%(HexString);
把ifroglab/mqtt 改成你要的名稱,就可以了。