Changes for page Through MQTT to upload data
Last modified by Xiaoling on 2022/09/02 18:11
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Attachments (0 modified, 8 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -23,7 +23,9 @@ 23 23 24 24 = 3. What does this example shows? How it works? = 25 25 26 +((( 26 26 The server we use here is ThingSpeak which has an intuitive chart to show the test result for our test.The ThingSpeak IoT service now supports MQTT subscriptions to receive instant updates when [[ThingSpeak>>url:https://thingspeak.com/]] channel gets updated. The method here is general and can be used with other IoT servers for MQTT connection as well. 28 +))) 27 27 28 28 [[image:image-20220531135402-1.png]] 29 29 ... ... @@ -37,17 +37,25 @@ 37 37 38 38 [[image:image-20220531135521-3.png]] 39 39 42 +((( 40 40 Schematic diagram: uplink.In this section, we will try to program LG01 to uplink data to ThingSpeak. The data flow in this example.We have already tried ① and ② in the above simple LoRa example. Now we will try the step ③ first, after it work as expect, we will integrate these three steps together for a complete uplink example. 44 +))) 41 41 42 42 43 43 44 44 [[image:image-20220531135607-4.png]] 45 45 50 +((( 46 46 Schematic diagram:downlink.In this section, we will try to program LG01 to fetch download data from ThingSpeak, then broadcast this data to local LoRa network. The end node will get this message and check if they need to do something. Similar with Uplink Example, we will first try to do it in PC, then do it in Linux side, and finally integrate it with LoRa. 52 +))) 47 47 54 +((( 48 48 MQTT agreement to achieve the need: client and server There are three identities in the MQTT protocol: Publish, Broker (server), Subscribe. Among them, the publisher and the subscriber of the message are all clients, the broker is the server, and the publisher can be both the subscriber and the subscriber. MQTT transmission of information is divided into: Topic and payload in two parts Topic, can be understood as the type of message subscribers Subscribe, you will receive the theme of the message content (payload) The payload, which can be understood as the content of the message, refers to the specific content to be used by the subscribers. 56 +))) 49 49 58 +((( 50 50 To use the server, we need to register an account on [[ThingSpeak>>url:https://thingspeak.com/]] . Then create a channel and type the channel info. As shown below, the Channel ID is the unique ID to store our data in [[ThingSpeak>>url:https://thingspeak.com/]] . 60 +))) 51 51 52 52 53 53 = 4. Preparation = ... ... @@ -252,10 +252,14 @@ 252 252 1. ((( 253 253 [[image:image-20220531142023-35.png]] 254 254 265 + 255 255 256 256 ))) 257 257 1. ((( 258 -[[~[~[image:https://wiki.dragino.com/images/thumb/7/70/MQTT_result_2.png/400px-MQTT_result_2.png~|~|alt="MQTT result 2.png" height="190" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_result_2.png]] 269 +[[image:image-20220531142155-36.png]] 270 + 271 + 272 + 259 259 ))) 260 260 261 261 = 5. FAQ = ... ... @@ -266,18 +266,25 @@ 266 266 267 267 For example: for ThingSpeak, a MQTT publish command is: 268 268 269 -{{{mosquitto_pub -h mqtt.thingspeak.com -p 1883 -u dragino -P QZXTAKE88V3S7O2J -i dragino_Client -t channels/200893/publish/B9Z0R25QNVEBKIFY -m "field1=34&field2=89&status=MQTTPUBLISH" 270 -}}} 283 +(% class="box infomessage" %) 284 +((( 285 +**mosquitto_pub -h mqtt.thingspeak.com -p 1883 -u dragino -P QZXTAKE88V3S7O2J -i dragino_Client -t channels/200893/publish/B9Z0R25QNVEBKIFY -m "field1=34&field2=89&status=MQTTPUBLISH"** 286 +))) 271 271 272 272 What now we need to put in the LG01 is how to combine this command. 273 273 274 274 1. LG01 web console -> Sensor -> MQTT 275 275 1. Choose general Server 276 -1. [[ ~[~[image:https://wiki.dragino.com/images/thumb/e/ea/MQTT_Configure1.png/600px-MQTT_Configure1.png~|~|height="367" width="600"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Configure1.png]](((292 +1. [[image:image-20220531142342-37.png]]((( 277 277 Refer to your server to fill in. 294 + 295 + 296 + 278 278 ))) 279 -1. [[ ~[~[image:https://wiki.dragino.com/images/0/07/MQTT_Configure2.png~|~|height="93" width="538"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Configure2.png]](((298 +1. [[image:image-20220531142447-38.png]]((( 280 280 Ex:ThingSpeak Server 300 + 301 + 281 281 ))) 282 282 283 283 According to MQTT commands: mosquitto_pub, we need to put ... ... @@ -296,7 +296,7 @@ 296 296 297 297 User can also enable MQTT debug in the LG01 ~-~-> IoT Server settings and run logread in Linux console to see how the mqtt command is compose. below is an example: 298 298 299 -[[ ~[~[image:https://wiki.dragino.com/images/thumb/8/81/MQTT_Configure3.png/600px-MQTT_Configure3.png~|~|height="114" width="600"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Configure3.png]]320 +[[image:image-20220531142525-39.png]] 300 300 301 301 MQTT Logread example 302 302 ... ... @@ -305,19 +305,31 @@ 305 305 306 306 LG01 for 4.3.3 version,we have added watchdog feature. In order to avoid the gateway running process will get stuck. So add writing action on every times. 307 307 308 -* [[ ~[~[image:https://wiki.dragino.com/images/thumb/f/f2/Wathcdog.png/400px-Wathcdog.png~|~|height="184" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:Wathcdog.png]](((329 +* [[image:image-20220531142558-40.png]]((( 309 309 Enable Sensor->Micro-Controller settings 331 + 332 + 333 + 310 310 ))) 311 -* [[ ~[~[image:https://wiki.dragino.com/images/thumb/8/82/MQTT_Sketch_2.png/400px-MQTT_Sketch_2.png~|~|height="233" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Sketch_2.png]](((335 +* [[image:image-20220531142629-41.png]]((( 312 312 Open the sketch [[MQTT_Simple_Server>>url:https://github.com/dragino/Arduino-Profile-Examples/tree/master/libraries/Dragino/examples/LoRa/MQTT_Simple_Server]].(Board:Dragino Yun + UNO or LG01/OLG01,Port:Network ports.)and upload. 337 + 338 + 339 + 313 313 ))) 314 -* [[ ~[~[image:https://wiki.dragino.com/images/2/21/Loop.png~|~|height="181" width="388"~]~]>>url:https://wiki.dragino.com/index.php/File:Loop.png]](((341 +* [[image:image-20220531142659-42.png]]((( 315 315 Each time the function loops, it uses the watchdog function once. 343 + 344 + 345 + 316 316 ))) 317 -* [[ ~[~[image:https://wiki.dragino.com/images/thumb/3/35/Dog.png/400px-Dog.png~|~|height="161" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:Dog.png]](((347 +* [[image:image-20220531142720-43.png]]((( 318 318 Open SSH and check watchdog result.If the result change constantly,the feature enable successfully. 349 + 350 + 351 + 319 319 ))) 320 -* [[ ~[~[image:https://wiki.dragino.com/images/thumb/a/ac/Checkdog.png/400px-Checkdog.png~|~|height="222" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:Checkdog.png]](((353 +* [[image:image-20220531142748-44.png]]((( 321 321 If the time doesnt's change,you can refer it to calculate for checking status. 322 322 ))) 323 323
- image-20220531142342-37.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Xiaoling - Size
-
... ... @@ -1,0 +1,1 @@ 1 +27.4 KB - Content
- image-20220531142447-38.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Xiaoling - Size
-
... ... @@ -1,0 +1,1 @@ 1 +4.7 KB - Content
- image-20220531142525-39.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Xiaoling - Size
-
... ... @@ -1,0 +1,1 @@ 1 +69.1 KB - Content
- image-20220531142558-40.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Xiaoling - Size
-
... ... @@ -1,0 +1,1 @@ 1 +43.9 KB - Content
- image-20220531142629-41.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Xiaoling - Size
-
... ... @@ -1,0 +1,1 @@ 1 +38.2 KB - Content
- image-20220531142659-42.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Xiaoling - Size
-
... ... @@ -1,0 +1,1 @@ 1 +5.1 KB - Content
- image-20220531142720-43.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Xiaoling - Size
-
... ... @@ -1,0 +1,1 @@ 1 +13.3 KB - Content
- image-20220531142748-44.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.Xiaoling - Size
-
... ... @@ -1,0 +1,1 @@ 1 +11.5 KB - Content