This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
Topicを適当に決めて、Pubしてみます
char mTopic[]="test-topc-1009A/sensor";
#code: Arduino SDK
2秒間隔で、数値を加算し、Pubしてます。
*) macアドレスを指定してますので、
複数設置する場合は重複に注意してください。
# mqtt_arduino_1.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Received PUBLISH (d0, q0, r0, m0, 'test-topc-1009A/sensor', ... (2 bytes))
29
Received PUBLISH (d0, q0, r0, m0, 'test-topc-1009A/sensor', ... (2 bytes))
30
Received PUBLISH (d0, q0, r0, m0, 'test-topc-1009A/sensor', ... (2 bytes))
31
デバイス側のPub と、Sub 確認ができましたので、次 は
browser表示方法を検討します。
# 表示アプリ (MQTT over WebSocket)
上記の paho-mqtt JS版使います。
mqttws31.js, jquery 読み込み
topic は、デバイス側で指定とあわせる
var mTopic="test-topc-1009A/sensor";
clientId (クライアントID)は、重複した場合、
後勝ち(後で開いた画面の表示が有効、前は停止)になるようです。
Paho.MQTT.Client インスタンスを呼出、
connect コールバック内で、
subscribe 実行します
#code : mqtt-sub-sample-js-1.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
下記が表示されましたが、書込みは問題ないようでした。
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85