Last modified by Xiaoling on 2022/09/02 18:11

From version 50.2
edited by Xiaoling
on 2022/09/02 18:10
Change comment: There is no comment for this version
To version 50.1
edited by Xiaoling
on 2022/05/31 14:38
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,4 +1,4 @@
1 -**Table of Contents: **
1 +**Contents: **
2 2  
3 3  {{toc/}}
4 4  
... ... @@ -7,14 +7,11 @@
7 7  
8 8  = 1. What is MQTT API? =
9 9  
10 +{{{MQTT is a publish/subscribe model that runs over TCP/IP sockets or WebSockets. MQTT over WebSockets can be secured with SSL.}}}
10 10  
11 -MQTT is a publish/subscribe model that runs over TCP/IP sockets or WebSockets. MQTT over WebSockets can be secured with SSL.
12 12  
13 -
14 -
15 15  = 2. MQTT Features =
16 16  
17 -
18 18  The MQTT protocol runs on TCP / IP or other network protocols and provides an ordered, lossless, bidirectional connection. Features include:
19 19  
20 20  * The publish / subscribe messaging pattern used, which provides one-to-many messaging for decoupling from the application.
... ... @@ -27,15 +27,10 @@
27 27  
28 28  
29 29  
30 -
31 -
32 32  = 3. What does this example shows? How it works? =
33 33  
34 -
35 35  (((
36 36  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.
37 -
38 -
39 39  )))
40 40  
41 41  [[image:image-20220531135402-1.png]]
... ... @@ -48,7 +48,6 @@
48 48  working principle
49 49  
50 50  
51 -
52 52  [[image:image-20220531135521-3.png]]
53 53  
54 54  (((
... ... @@ -59,7 +59,6 @@
59 59  
60 60  [[image:image-20220531135607-4.png]]
61 61  
62 -
63 63  (((
64 64  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.
65 65  )))
... ... @@ -76,13 +76,9 @@
76 76  
77 77  = 4. Preparation =
78 78  
79 -
80 80  == 4.1 Hardware ==
81 81  
82 -
83 83  1. [[image:image-20220531135650-5.png]](((
84 -
85 -
86 86  Listening on the LoRa wireless channel, while there is new LoRa packet arrives, parse it and send out to IoT Server.
87 87  
88 88  
... ... @@ -89,17 +89,11 @@
89 89  
90 90  )))
91 91  1. [[image:image-20220531135750-6.png]](((
92 -
93 -
94 94  The LoRa End node keeps getting temperature and humidity from the sensor and sends out via LoRa periodically.
95 -
96 -
97 -
98 98  )))
99 99  
100 100  == 4.2 Software ==
101 101  
102 -
103 103  1. [[4.3.4 version>>url:http://www.dragino.com/downloads/index.php?dir=motherboards/ms14/Firmware/IoT/]]
104 104  1. [[MQTT_Client>>url:https://github.com/dragino/Arduino-Profile-Examples/tree/master/libraries/Dragino/examples/IoTServer/ThingSpeak/MQTT_Client]]
105 105  1. [[MQTT_Simple_Server MQTT_Simeple_Server>>url:https://github.com/dragino/Arduino-Profile-Examples/tree/master/libraries/Dragino/examples/LoRa/MQTT_Simple_Server]]
... ... @@ -107,20 +107,14 @@
107 107  
108 108  
109 109  
110 -
111 -
112 112  == 4.3 Server(For example) ==
113 113  
114 -
115 115  * [[ThingSpeak>>url:https://thingspeak.com/]]
116 116  
117 117  
118 118  
119 -
120 -
121 121  == 4.4 Configure IoT Server ==
122 122  
123 -
124 124  * Need this keys:
125 125  
126 126  1. [[image:image-20220531140054-8.png]](((
... ... @@ -130,8 +130,6 @@
130 130  
131 131  )))
132 132  1. [[image:image-20220531140326-13.png]](((
133 -
134 -
135 135  Account->My Profile,MQTT API Key
136 136  
137 137  
... ... @@ -147,9 +147,8 @@
147 147  == 4.5 Configure LG01 settings ==
148 148  
149 149  
150 -Tips:  Please confirm that your LG01 version is 4.3.3.
122 +Tips:Please confirm that your LG01 version is 4.3.3.
151 151  
152 -
153 153  [[image:image-20220531140248-11.png]]
154 154  
155 155  **Overview**
... ... @@ -161,7 +161,6 @@
161 161  **Senosor->IOT Server**
162 162  
163 163  
164 -
165 165  [[image:image-20220531140458-15.png]]
166 166  
167 167  **MQTT->Configure MQTT Server**
... ... @@ -182,44 +182,29 @@
182 182  
183 183  [[image:image-20220531140651-18.png]]
184 184  
185 -
186 186  Configure network access.**Network->Internet Access**
187 187  
188 188  
189 -
190 190  == 4.6 Try MQTT API call with LG01 Linux command ==
191 191  
192 -
193 193  === 4.6.1 Input the command at the console ===
194 194  
195 -
196 196  1. [[image:image-20220531140811-19.png]](((
197 -
198 -
199 199  Open this Application.
200 200  
201 -
202 202  
203 203  )))
204 204  1. [[image:image-20220531140842-20.png]](((
205 -
206 -
207 207  Input passward(dragino).After into the console.
208 208  
209 -
210 210  
211 211  )))
212 212  1. [[image:image-20220531140915-21.png]](((
213 -
214 -
215 215  First, we need to make sure the LG01 has internet access. We can log in the SSH and ping an Internet address and see if it get through. As below
216 216  
217 -
218 218  
219 219  )))
220 220  1. [[image:image-20220531140955-22.png]](((
221 -
222 -
223 223  LG01 has built-in Linux tool mosquitto. It is a very powerful tool for http communication. We can use this tool to handle MQTT API call in LG01. Input this command and replace your keys.
224 224  
225 225  
... ... @@ -226,11 +226,7 @@
226 226  
227 227  )))
228 228  1. [[image:image-20220531141026-23.png]](((
229 -
230 -
231 231  Go to Server check out result.We success to use LG01 to uplink data to ThingSpeak,the mosquitto_pub command is executed in the Linux side, finally, we will have to call mosquitto_pub command with sensor data variable in Arduino side. This is through the process class in Arduino and we will show it in the final sketch.
232 -
233 -
234 234  )))
235 235  
236 236  * This command:
... ... @@ -250,13 +250,9 @@
250 250  )))
251 251  
252 252  
253 -
254 254  === 4.6.2 Input the command at the console(LG01 new version:4.3.4) ===
255 255  
256 -
257 257  1. [[image:image-20220531141150-24.png]](((
258 -
259 -
260 260  Open this Application.
261 261  
262 262  
... ... @@ -265,7 +265,6 @@
265 265  1. (((
266 266  [[image:image-20220531141400-27.png]]
267 267  
268 -
269 269  Check the settings.
270 270  
271 271  
... ... @@ -274,7 +274,6 @@
274 274  1. (((
275 275  [[image:image-20220531141601-30.png]]
276 276  
277 -
278 278  input this command.
279 279  
280 280  
... ... @@ -281,8 +281,6 @@
281 281  
282 282  )))
283 283  1. [[image:image-20220531141515-29.png]](((
284 -
285 -
286 286  Check the result.
287 287  
288 288  
... ... @@ -291,7 +291,6 @@
291 291  
292 292  == 4.7 Updata data to Server(Through MQTT) ==
293 293  
294 -
295 295  * This version of Sketch implements these features:
296 296  
297 297  1. Read the LG01 configuration information from Linux.
... ... @@ -299,11 +299,7 @@
299 299  1. Send reply after then receive LoRa node data.
300 300  1. Sketch will write active content to /tmp/iot/status periodically (every 5 minutes).(Watchdog feature)
301 301  
302 -
303 -
304 304  1. [[image:image-20220531143822-49.png]](((
305 -
306 -
307 307  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.
308 308  
309 309  
... ... @@ -310,8 +310,6 @@
310 310  
311 311  )))
312 312  1. [[image:image-20220531141800-32.png]](((
313 -
314 -
315 315  Open Serial monitor.
316 316  
317 317  
... ... @@ -318,8 +318,6 @@
318 318  
319 319  )))
320 320  1. [[image:image-20220531143748-48.png]](((
321 -
322 -
323 323  Open the Sketch [[MQTT_Client>>url:https://github.com/dragino/Arduino-Profile-Examples/tree/master/libraries/Dragino/examples/IoTServer/ThingSpeak/MQTT_Client]]. (Board:Arduino/Genuino Uno.Port:Serial ports.)and upload.
324 324  
325 325  
... ... @@ -326,8 +326,6 @@
326 326  
327 327  )))
328 328  1. [[image:image-20220531141927-34.png]](((
329 -
330 -
331 331  Open Serial monitor.
332 332  
333 333  
... ... @@ -349,10 +349,8 @@
349 349  
350 350  = 5. FAQ =
351 351  
352 -
353 353  == 5.1 Configure to support general mqtt server ==
354 354  
355 -
356 356  First, try to run **mosquitto_pub** in Linux console to send a data to MQTT server.
357 357  
358 358  For example: for ThingSpeak, a MQTT publish command is:
... ... @@ -367,8 +367,6 @@
367 367  1. LG01 web console -> Sensor -> MQTT
368 368  1. Choose general Server
369 369  1. [[image:image-20220531142342-37.png]](((
370 -
371 -
372 372  Refer to your server to fill in.
373 373  
374 374  
... ... @@ -375,8 +375,6 @@
375 375  
376 376  )))
377 377  1. [[image:image-20220531142447-38.png]](((
378 -
379 -
380 380  Ex:ThingSpeak Server
381 381  
382 382  
... ... @@ -400,17 +400,13 @@
400 400  
401 401  [[image:image-20220531142525-39.png]]
402 402  
403 -
404 404  MQTT Logread example
405 405  
406 406  
407 -
408 408  == 5.2 What is Watchdog feature? ==
409 409  
410 -
411 411  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.
412 412  
413 -
414 414  * [[image:image-20220531142558-40.png]](((
415 415  Enable Sensor->Micro-Controller settings
416 416  
... ... @@ -418,8 +418,6 @@
418 418  
419 419  )))
420 420  * [[image:image-20220531142629-41.png]](((
421 -
422 -
423 423  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.
424 424  
425 425  
... ... @@ -426,8 +426,6 @@
426 426  
427 427  )))
428 428  * [[image:image-20220531142659-42.png]](((
429 -
430 -
431 431  Each time the function loops, it uses the watchdog function once.
432 432  
433 433  
... ... @@ -434,8 +434,6 @@
434 434  
435 435  )))
436 436  * [[image:image-20220531142720-43.png]](((
437 -
438 -
439 439  Open SSH and check watchdog result.If the result change constantly,the feature enable successfully.
440 440  
441 441  
... ... @@ -442,8 +442,6 @@
442 442  
443 443  )))
444 444  * [[image:image-20220531142748-44.png]](((
445 -
446 -
447 447  If the time doesnt's change,you can refer it to calculate for checking status.
448 448  )))
449 449