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

From version 18.1
edited by Xiaoling
on 2022/05/31 14:06
Change comment: Uploaded new attachment "image-20220531140611-17.png", version {1}
To version 44.2
edited by Xiaoling
on 2022/05/31 14:32
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,3 +1,5 @@
1 +**Contents: **
2 +
1 1  {{toc/}}
2 2  
3 3  
... ... @@ -21,9 +21,12 @@
21 21  * Notification mechanism, notify the transmission of both sides when an exception occurs
22 22  
23 23  
26 +
24 24  = 3. What does this example shows? How it works? =
25 25  
29 +(((
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.
31 +)))
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  
45 +(((
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.
47 +)))
41 41  
42 42  
43 43  
44 44  [[image:image-20220531135607-4.png]]
45 45  
53 +(((
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.
55 +)))
47 47  
57 +(((
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.
59 +)))
49 49  
61 +(((
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/]] .
63 +)))
51 51  
52 52  
53 53  = 4. Preparation =
... ... @@ -64,7 +64,6 @@
64 64  The LoRa End node keeps getting temperature and humidity from the sensor and sends out via LoRa periodically.
65 65  )))
66 66  
67 -
68 68  == 4.2 Software ==
69 69  
70 70  1. [[4.3.4 version>>url:http://www.dragino.com/downloads/index.php?dir=motherboards/ms14/Firmware/IoT/]]
... ... @@ -72,12 +72,10 @@
72 72  1. [[MQTT_Simple_Server MQTT_Simeple_Server>>url:https://github.com/dragino/Arduino-Profile-Examples/tree/master/libraries/Dragino/examples/LoRa/MQTT_Simple_Server]]
73 73  1. [[DHTlib>>url:https://github.com/goodcheney/Lora/blob/patch-1/Lora%20Shield/Examples/DHTlib.zip]]
74 74  
75 -
76 76  == 4.3 Server(For example) ==
77 77  
78 78  * [[ThingSpeak>>url:https://thingspeak.com/]]
79 79  
80 -
81 81  == 4.4 Configure IoT Server ==
82 82  
83 83  * Need this keys:
... ... @@ -98,7 +98,6 @@
98 98  [[image:image-20220531140304-12.png]]
99 99  )))
100 100  
101 -
102 102  == 4.5 Configure LG01 settings ==
103 103  
104 104  Tips:Please confirm that your LG01 version is 4.3.3.
... ... @@ -105,82 +105,113 @@
105 105  
106 106  [[image:image-20220531140248-11.png]]
107 107  
108 -Overview
117 +**Overview**
109 109  
110 110  
111 111  
112 112  [[image:image-20220531140425-14.png]]
113 113  
114 -Senosor->IOT Server
123 +**Senosor->IOT Server**
115 115  
116 116  
117 117  [[image:image-20220531140458-15.png]]
118 118  
119 -MQTT->Configure MQTT Server
128 +**MQTT->Configure MQTT Server**
120 120  
121 121  
122 122  
123 123  [[image:image-20220531140538-16.png]]
124 124  
125 -MQTT->MQTT Channel
134 +**MQTT->MQTT Channel**
126 126  
127 127  
128 128  
129 -[[~[~[image:https://wiki.dragino.com/images/thumb/3/36/MQTT_LG01_Configure_4.png/400px-MQTT_LG01_Configure_4.png~|~|height="257" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_LG01_Configure_4.png]]
138 +[[image:image-20220531140611-17.png]]
130 130  
131 -Sensor->LoRa/LoraWAN
140 +**Sensor->LoRa/LoraWAN**
132 132  
133 -[[~[~[image:https://wiki.dragino.com/images/thumb/6/61/MQTT_LG01_Configure_5.png/400px-MQTT_LG01_Configure_5.png~|~|height="230" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_LG01_Configure_5.png]]
134 134  
135 -Configure network access.Network->Internet Access
136 136  
144 +[[image:image-20220531140651-18.png]]
137 137  
146 +Configure network access.**Network->Internet Access**
147 +
148 +
138 138  == 4.6 Try MQTT API call with LG01 Linux command ==
139 139  
140 140  === 4.6.1 Input the command at the console ===
141 141  
142 -1. [[~[~[image:https://wiki.dragino.com/images/8/84/3_1.png~|~|height="99" width="93"~]~]>>url:https://wiki.dragino.com/index.php/File:3_1.png]](((
153 +1. [[image:image-20220531140811-19.png]](((
143 143  Open this Application.
155 +
156 +
144 144  )))
145 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/d/d7/3_2.png/400px-3_2.png~|~|height="230" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:3_2.png]](((
158 +1. [[image:image-20220531140842-20.png]](((
146 146  Input passward(dragino).After into the console.
160 +
161 +
147 147  )))
148 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/5/5d/3_5.png/400px-3_5.png~|~|height="310" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:3_5.png]](((
163 +1. [[image:image-20220531140915-21.png]](((
149 149  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
165 +
166 +
150 150  )))
151 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/6/63/3_3.png/400px-3_3.png~|~|height="213" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:3_3.png]](((
168 +1. [[image:image-20220531140955-22.png]](((
152 152  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.
170 +
171 +
172 +
153 153  )))
154 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/3/35/3_4.png/500px-3_4.png~|~|height="180" width="500"~]~]>>url:https://wiki.dragino.com/index.php/File:3_4.png]](((
174 +1. [[image:image-20220531141026-23.png]](((
155 155  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.
156 156  )))
157 157  
158 158  * This command:
159 159  
160 -{{{mosquitto_pub -h mqtt.thingspeak.com -p 1883 -u dragino -P UZ4NGHKJMKS9WR5E -i dragino_Client -t channels/399171/publish/A4NNF6G8G63JOIUV -m "field1=23.5&field2=57.5&status=MQTTPUBLISH"
161 -}}}
180 +(% class="box infomessage" %)
181 +(((
182 +**mosquitto_pub -h mqtt.thingspeak.com -p 1883 -u dragino -P UZ4NGHKJMKS9WR5E  -i dragino_Client -t channels/399171/publish/A4NNF6G8G63JOIUV -m "field1=23.5&field2=57.5&status=MQTTPUBLISH"**
183 +)))
162 162  
163 163  * Need replace:
164 164  
165 -{{{UZ4NGHKJMKS9WR5E //MQTT API
166 -399171 //Channel ID
167 -A4NNF6G8G63JOIUV //Write API Key
168 -}}}
187 +(% class="box infomessage" %)
188 +(((
189 +**UZ4NGHKJMKS9WR5E  ~/~/MQTT API
190 +399171            ~/~/Channel ID
191 +A4NNF6G8G63JOIUV  ~/~/Write API Key**
192 +)))
169 169  
170 170  
171 171  === 4.6.2 Input the command at the console(LG01 new version:4.3.4) ===
172 172  
173 -1. [[~[~[image:https://wiki.dragino.com/images/8/84/3_1.png~|~|height="99" width="93"~]~]>>url:https://wiki.dragino.com/index.php/File:3_1.png]](((
197 +1. [[image:image-20220531141150-24.png]](((
174 174  Open this Application.
199 +
200 +
201 +
175 175  )))
176 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/6/6e/MQTT_Command_2.png/400px-MQTT_Command_2.png~|~|height="76" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Command_2.png]](((
203 +1. (((
204 +[[image:image-20220531141400-27.png]]
205 +
177 177  Check the settings.
207 +
208 +
209 +
178 178  )))
179 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/8/8d/MQTT_Command_1.png/400px-MQTT_Command_1.png~|~|height="343" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Command_1.png]](((
211 +1. (((
212 +[[image:image-20220531141601-30.png]]
213 +
180 180  input this command.
215 +
216 +
217 +
181 181  )))
182 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/d/de/MQTT_Command_3.png/400px-MQTT_Command_3.png~|~|height="207" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Command_3.png]](((
219 +1. [[image:image-20220531141515-29.png]](((
183 183  Check the result.
221 +
222 +
223 +
184 184  )))
185 185  
186 186  == 4.7 Updata data to Server(Through MQTT) ==
... ... @@ -192,25 +192,42 @@
192 192  1. Send reply after then receive LoRa node data.
193 193  1. Sketch will write active content to /tmp/iot/status periodically (every 5 minutes).(Watchdog feature)
194 194  
195 -
196 -1. [[~[~[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]](((
235 +1. [[image:image-20220531141656-31.png]](((
197 197  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.
237 +
238 +
239 +
198 198  )))
199 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/7/73/MQTT_Sketch2.png/400px-MQTT_Sketch2.png~|~|height="540" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Sketch2.png]](((
241 +1. [[image:image-20220531141800-32.png]](((
200 200  Open Serial monitor.
243 +
244 +
245 +
201 201  )))
202 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/9/98/MQTT_Sketch_1.png/400px-MQTT_Sketch_1.png~|~|height="261" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Sketch_1.png]](((
247 +1. [[image:image-20220531141842-33.png]](((
203 203  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.
249 +
250 +
251 +
204 204  )))
205 -1. [[~[~[image:https://wiki.dragino.com/images/thumb/3/3d/MQTT_Sketch3.png/400px-MQTT_Sketch3.png~|~|height="371" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_Sketch3.png]](((
253 +1. [[image:image-20220531141927-34.png]](((
206 206  Open Serial monitor.
255 +
256 +
257 +
207 207  )))
208 208  1. Go to IoT Server to check the result.
209 209  1. (((
210 -[[~[~[image:https://wiki.dragino.com/images/thumb/4/43/MQTT_result_1.png/400px-MQTT_result_1.png~|~|alt="MQTT result 1.png" height="181" width="400"~]~]>>url:https://wiki.dragino.com/index.php/File:MQTT_result_1.png]]
261 +[[image:image-20220531142023-35.png]]
262 +
263 +
264 +
211 211  )))
212 212  1. (((
213 -[[~[~[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]]
267 +[[image:image-20220531142155-36.png]]
268 +
269 +
270 +
214 214  )))
215 215  
216 216  = 5. FAQ =
... ... @@ -221,18 +221,25 @@
221 221  
222 222  For example: for ThingSpeak, a MQTT publish command is:
223 223  
224 -{{{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"
225 -}}}
281 +(% class="box infomessage" %)
282 +(((
283 +**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"**
284 +)))
226 226  
227 227  What now we need to put in the LG01 is how to combine this command.
228 228  
229 229  1. LG01 web console -> Sensor -> MQTT
230 230  1. Choose general Server
231 -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]](((
290 +1. [[image:image-20220531142342-37.png]](((
232 232  Refer to your server to fill in.
292 +
293 +
294 +
233 233  )))
234 -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]](((
296 +1. [[image:image-20220531142447-38.png]](((
235 235  Ex:ThingSpeak Server
298 +
299 +
236 236  )))
237 237  
238 238  According to MQTT commands: mosquitto_pub, we need to put
... ... @@ -251,7 +251,7 @@
251 251  
252 252  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:
253 253  
254 -[[~[~[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]]
318 +[[image:image-20220531142525-39.png]]
255 255  
256 256  MQTT Logread example
257 257  
... ... @@ -260,20 +260,33 @@
260 260  
261 261  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.
262 262  
263 -* [[~[~[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]](((
327 +* [[image:image-20220531142558-40.png]](((
264 264  Enable Sensor->Micro-Controller settings
329 +
330 +
331 +
265 265  )))
266 -* [[~[~[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]](((
333 +* [[image:image-20220531142629-41.png]](((
267 267  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.
335 +
336 +
337 +
268 268  )))
269 -* [[~[~[image:https://wiki.dragino.com/images/2/21/Loop.png~|~|height="181" width="388"~]~]>>url:https://wiki.dragino.com/index.php/File:Loop.png]](((
339 +* [[image:image-20220531142659-42.png]](((
270 270  Each time the function loops, it uses the watchdog function once.
341 +
342 +
343 +
271 271  )))
272 -* [[~[~[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]](((
345 +* [[image:image-20220531142720-43.png]](((
273 273  Open SSH and check watchdog result.If the result change constantly,the feature enable successfully.
347 +
348 +
349 +
274 274  )))
275 -* [[~[~[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]](((
351 +* [[image:image-20220531142748-44.png]](((
276 276  If the time doesnt's change,you can refer it to calculate for checking status.
277 277  )))
278 278  
279 -== ==
355 +(% class="wikigeneratedid" id="H" %)
356 +
image-20220531140651-18.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +35.0 KB
Content
image-20220531140811-19.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +14.5 KB
Content
image-20220531140842-20.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +21.4 KB
Content
image-20220531140915-21.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +29.9 KB
Content
image-20220531140955-22.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +36.1 KB
Content
image-20220531141026-23.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +22.8 KB
Content
image-20220531141150-24.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +14.6 KB
Content
image-20220531141303-26.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +35.4 KB
Content
image-20220531141400-27.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +17.0 KB
Content
image-20220531141515-29.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +36.1 KB
Content
image-20220531141601-30.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +34.5 KB
Content
image-20220531141656-31.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +38.8 KB
Content
image-20220531141800-32.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +32.9 KB
Content
image-20220531141842-33.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +39.2 KB
Content
image-20220531141927-34.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +26.8 KB
Content
image-20220531142023-35.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +34.5 KB
Content
image-20220531142155-36.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.Xiaoling
Size
... ... @@ -1,0 +1,1 @@
1 +42.9 KB
Content
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