Wiki source code of 05 Lua Script

Version 64.1 by Molly on 2024/10/23 18:34

Hide last authors
Leo Wei 1.1 1 = **1 64bits Address Basic Algorithm** =
2
3 The example shows how to do the Addition, Subtraction, Multiplication and Division for HMI internal address.
4
Molly 63.1 5 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/64bitCalculation.zip]]
Leo Wei 1.1 6
Hunter 12.1 7 = **2 MQTT Client** =
Leo Wei 1.1 8
9 The example shows how to connect to the MQTT server.(Test on MaQiaTTo)
10
Molly 64.1 11 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Lua%20MQTT%20Client.zip]]
Leo Wei 1.1 12
13 = **3 Timer** =
14
15 The example shows how to use the Lua Timer function.
16
17 [[Download link>>https://drive.google.com/file/d/1iwD2Kca9SIAGCYFBaQbn26zdc4kIUuSV/view?usp=sharing]]
18
19 = **4 Trigger** =
20
21 The example shows how to use the Lua Trigger function.
22
23 [[Download link>>https://drive.google.com/file/d/1GDCbbMgNSixonXP2erA0VoJbo7qagsCv/view?usp=sharing]]
24
25 = **5 User Free Protocol** =
26
27 The example shows the simple write and read of User Free protocol
28
Hunter 14.1 29 [[Download link>>https://drive.google.com/file/d/1v8UZvdclq3OGEajkbd78w7_XY2bY2qAe/view?usp=sharing]]
Leo Wei 1.1 30
31 = **6 Arabic Keypad** =
32
33 The example shows how to use the Lua to achieve the Arabic keypad. Also available for other non-English language like Cyrillic.
34
35 [[Download link>>https://drive.google.com/file/d/1JqpTRRqj6db32aLn7tqqO8dWT6EuXBEL/view?usp=sharing]]
Hunter 3.1 36
37 = **7 FTP Client** =
38
Joe 62.1 39 The example shows how  to establish the FTP server at WIN10 OS and make V2.0 HMI as FTP client.
Hunter 3.1 40
Hunter 46.1 41 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/FTP%20ClientV2.zip]]
Hunter 17.1 42
Joe 62.1 43 (% class="box infomessage" %)
44 (((
45 Note: The above demo can work normal in OS V2.0. But if HMI OS  is V3.0, please change "r+" to "r" in the script.
46 )))
47
48 (% style="text-align:center" %)
49 [[image:dZyxVCtWDz.png]]
50
Hunter 15.1 51 ~1. About how to set up the FTP server in Windows PC: **[[Build an FTP Site on IIS>>https://docs.microsoft.com/en-us/iis/publish/using-the-ftp-service/scenario-build-an-ftp-site-on-iis]] **,** [[How to set up and manage an FTP server on Windows 10>>https://www.windowscentral.com/how-set-and-manage-ftp-server-windows-10]]**
Hunter 7.1 52
Hunter 15.1 53 2. Enter PC (FTP Server) IP address and port number (Default 21).
Hunter 7.1 54
Hunter 15.1 55 (% style="text-align:center" %)
56 [[image:LuaFTPDemoIP&Port.png]]
Hunter 8.1 57
Hunter 15.1 58 3. Change the filename of the file that needs to be uploaded. If run on as Offline Simulator, the simulate upload path of "udisk:1.png" will be "C:\WECON\USB\1.png" on the PC.
Hunter 8.1 59
Hunter 15.1 60 (% style="text-align:center" %)
61 [[image:LuaFTPDemoUpload.png]]
62
63 4. Change drive letter of file save path according to drop-down list (There are three option available: Flash, UDisk and SDCard).
64
65 (% style="text-align:center" %)
66 [[image:LuaFTPDemoDropBox.png]]
67
68 5. Change the filename of the file that needs to be downloaded from PC(Server).
69
70 (% style="text-align:center" %)
71 [[image:LuaFTPDemoDownload.png]]
72
73 6. Set the default configuration in file "Script_BG.lua"
74
75 (% style="text-align:center" %)
76 [[image:LuaFTPDemoInitial.png]]
77
Joe 57.2 78 (% class="box infomessage" %)
79 (((
Hunter 16.1 80 ✎Note: If want to confirm whether it is downloaded successfully, please add a File list object to check in HMI project. If saved path is root path (same to the all three drive), please set the folder as "~/~/".
Joe 57.2 81 )))
Hunter 15.1 82
Hunter 16.1 83 (% style="text-align:center" %)
84 [[image:LuaFTPDemoFilelist.png]]
85
Joe 57.2 86 **Common error:**
87
88 In the demo project, if there are some errors in HMI for testing, please check the following steps.
89
90 Error 1: 550 Access is denied
91
Joe 58.1 92 Open Windows Settings → Update & Security→ Windows Security→ Firewall & network protection→ Advanced setting→ Inbound Rules→ New Rules→ Next → choose "This program path"→ input ‘’C:\Windows\System32\svchost.exe‘’→ Click “NEXT” continuously
Joe 57.2 93
94 (% style="text-align:center" %)
95 [[image:qCzqnKTUhp.png]]
96
97 (% style="text-align:center" %)
98 [[image:vfrt3NElMX.png]]
99
100 (% style="text-align:center" %)
101 [[image:dAuz25bdvM.png]]
102
103 (% style="text-align:center" %)
104 [[image:rxQIJkX8ll.png]]
105
106 (% style="text-align:center" %)
107 [[image:vmG8WGu5P2.png]]
108
Joe 58.2 109
110 Error 2: No route to host
111
112 The previous steps are the same as Error 1 → Port → specific local ports→ input port number “21”→ Click “NEXT” continuously
113
114 (% style="text-align:center" %)
115 [[image:fdsxie8WHc.png]]
116
117 (% style="text-align:center" %)
118 [[image:4ALQq7niTV.png]]
119
Hunter 4.1 120 = **8 Telegram Notification** =
121
Hunter 5.1 122 The example shows how to use Bot API to push the notification to channel or group of Telegram. Please change the Token and Chat id to users' own one.
Hunter 4.1 123
124 [[Download link>>https://drive.google.com/file/d/1wV0O79TJ2mgUEBkKcjrb53PM8DkTQxVo/view?usp=sharing]]
Theodore Xu 18.1 125
126
127 = 9** LINE Notify** =
128
Theodore Xu 21.1 129 This example shows how to use the LINE Notify to send message into LINE group. When monitoring bit "@B_HDX0.0" changes, it will trigger and send the message. Please replace with your own Token.
Theodore Xu 18.1 130
Theodore Xu 19.1 131 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/line.zip]]
Hunter 21.2 132
133
134 = 10** How to parse value from subscribing MQTT topic** =
135
Hunter 21.3 136 This example shows how to parse value from subscribing MQTT topic. Get the value and calculate the average value for group F1, F2, F3 and F4. The testing topic name is "testtopic/test/no1/123456".
137
Hunter 22.1 138 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/MQTT%20JSON%20parse.zip]]
Hunter 21.3 139
Hunter 21.2 140 And the subscribed content is like following:
141
142 {{code language="json"}}
143 {
144 "Cluster_ID": "2",
145 "timestamp": "07:01:45-18.02.2022",
146 "Cust_id": "TAM-1",
147 "Platform_id": "Pro44ead8a8dc3345ACC",
148 "version": "1.5",
149 "Line_active": "true",
150 "Total_sensor": "5",
151 "F1": [
152 {
153 "Counter": "0",
154 "Value": "11"
155 },
156 {
157 "Counter": "1",
158 "Value": "21.1"
159 },
160 {
161 "Counter": "2",
162 "Value": "9"
163 },
164 {
165 "Counter": "3",
166 "Value": "0.06"
167 },
168 {
169 "Counter": "4",
170 "Value": "9"
171 },
172 {
173 "Counter": "5",
174 "Value": "19"
175 },
176 {
177 "Counter": "6",
178 "Value": "9"
179 },
180 {
181 "Counter": "7",
182 "Value": "19"
183 },
184 {
185 "Counter": "8",
186 "Value": "22.89"
187 }
188 ],
189 "F2": [
190 {
191 "Counter": "0",
192 "Value": "1.1"
193 },
194 {
195 "Counter": "1",
196 "Value": "21.21"
197 },
198 {
199 "Counter": "2",
200 "Value": "19"
201 },
202 {
203 "Counter": "3",
204 "Value": "0.6"
205 },
206 {
207 "Counter": "4",
208 "Value": "8"
209 },
210 {
211 "Counter": "5",
212 "Value": "19.1"
213 },
214 {
215 "Counter": "6",
216 "Value": "5.1"
217 }
218 ],
219 "F4": [
220 {
221 "Counter": "0",
222 "Value": "11"
223 },
224 {
225 "Counter": "1",
226 "Value": "21.1"
227 },
228 {
229 "Counter": "2",
230 "Value": "9"
231 },
232 {
233 "Counter": "3",
234 "Value": "0.06"
235 },
236 {
237 "Counter": "4",
238 "Value": "9"
239 },
240 {
241 "Counter": "5",
242 "Value": "19"
243 },
244 {
245 "Counter": "6",
246 "Value": "9"
247 },
248 {
249 "Counter": "7",
250 "Value": "12.1"
251 },
252 {
253 "Counter": "8",
254 "Value": "18.1"
255 }
256 ]
257 }
258 {{/code}}
259
Hunter 21.3 260 So we decode this json into lua object, and then assign the values from "Value" field into table (addresses HDW1~~HDW101, HDW112~~HDW202, HDW213~~HDW313, HDW324~~HDW424).
Hunter 21.2 261
262 (% style="text-align:center" %)
263 [[image:MQTTScreen.png]]
264
Hunter 21.3 265 Due to the MQTT code is not able to running on the simulator from PC, following picture is the testing result from actual HMI screen:
266
267 (% style="text-align:center" %)
268 [[image:MQTTactualtestingresult.png]]
269
270 The JSON parser function is located on mqttAction.lua, called mqtt_msg_callback.
271
272 (% style="text-align:center" %)
273 [[image:MQTTJSONparsefunction.png]]
274
Hunter 23.1 275 = **11 High-Low Byte Switch** =
Hunter 24.1 276
Hunter 26.1 277 The example shows how to convert high bytes and low bytes for one 16bit address. Main function is like following:
Hunter 25.1 278
279 {{code language="lua"}}
280 local lowByte = val & 0x00ff
281 local shiftHigh = lowByte << 8
282 local highByte = val & 0xff00
283 local shiftLow = highByte >> 8
284 local newVal = shiftHigh|shiftLow
285 {{/code}}
286
Hunter 27.1 287 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/byteswitch.zip]]
Theodore Xu 28.1 288
289 = **12 Week time setting** =
290
Theodore Xu 29.1 291 The example shows how to use day time to control functions:
292
Theodore Xu 28.1 293 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/week%20time.zip]]
Theodore Xu 30.1 294
Theodore Xu 31.1 295 = **13 MQTT Multi-link** =
Theodore Xu 30.1 296
297 The example shows use mqtt realize multi-machine function:
298
299 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/MQTT%20Multi-link.zip]]
Hunter 31.2 300
301 = **14 CSV File Generation** =
302
Hunter 34.1 303 The example shows convert the custom lua table data into csv string, then output as a file:
Hunter 31.2 304
Hunter 32.1 305 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/csvGenerate.zip]]
Hunter 31.2 306
Hunter 32.1 307 The following steps take HMI simulator as example:
308
309 ~1. Click button "Create Table" to draw lua table in screen.
310
311 (% style="text-align:center" %)
312 [[image:csvGenerateSteps.png]]
313
314 2. Click button "Save as csv" to save the file into HMI storage path. On the HMI simulator, user can enter the simulation path of U disk to check the file whether create successfully.
315
316 (% style="text-align:center" %)
317 [[image:csvGenerateSimulationPath.png]]
318
319 3. Click button "upload" to upload csv file into server side. In this case, we can check the upload path for PC.
320
321 (% style="text-align:center" %)
322 [[image:csvGenerateServerPath.png]]
323
Hunter 35.1 324 The csv file generation is mainly using the following function to implement, the customized data is argument tab, and csv file storage path in HMI is "udisk:weather1.csv":
Hunter 32.1 325
326 (% style="text-align:center" %)
327 [[image:csvGenerateLuaCode.png]]
328
Hunter 35.1 329 The table drawing is mainly using the following function to implement:
330
331 (% style="text-align:center" %)
332 [[image:csvLuaTableDrawing.png]]
Hunter 36.1 333
Hunter 37.1 334 = 15 **String customized length word-wrapped** =
Hunter 36.1 335
Hunter 37.1 336 The example shows automatically line break for long string content according to user input length.
337
Hunter 38.1 338 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/CRLF.zip]]
339
Hunter 37.1 340 The following are some demonstrated strings from offline simulator:
341
342 (% style="text-align:center" %)
343 [[image:WordWrapDisplayResult.png]]
Hunter 38.2 344
345 = 16 Weather forecast HTTP API request =
346
347 The example shows how to parse value from HTTP response body, and display into HMI internal address. The test forecast official website is [[https:~~/~~/www.weatherapi.com/>>url:https://www.weatherapi.com/]]
348
Hunter 39.1 349 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/luahttp.zip]]
Hunter 38.2 350
Hunter 39.1 351 From the API explorer of weatherapi, the one day forecast response would be like the follows(Because the original data of JSON is very long, there we just show the part of it):
352
Hunter 38.2 353 {{code language="JSON"}}
354 {
355 "location": {
356 "name": "London",
357 "region": "City of London, Greater London",
358 "country": "United Kingdom",
359 "lat": 51.52,
360 "lon": -0.11,
361 "tz_id": "Europe/London",
362 "localtime_epoch": 1688961236,
363 "localtime": "2023-07-10 4:53"
364 },
365 "current": {
366 "last_updated_epoch": 1688960700,
367 "last_updated": "2023-07-10 04:45",
368 "temp_c": 14.0,
369 "temp_f": 57.2,
370 "is_day": 0,
371 "condition": {
372 "text": "Partly cloudy",
373 "icon": "//cdn.weatherapi.com/weather/64x64/night/116.png",
374 "code": 1003
375 },
376 "wind_mph": 4.3,
377 "wind_kph": 6.8,
378 "wind_degree": 220,
379 "wind_dir": "SW",
380 "pressure_mb": 1020.0,
381 "pressure_in": 30.12,
382 "precip_mm": 0.0,
383 "precip_in": 0.0,
384 "humidity": 88,
385 "cloud": 50,
386 "feelslike_c": 13.3,
387 "feelslike_f": 56.0,
388 "vis_km": 10.0,
389 "vis_miles": 6.0,
390 "uv": 1.0,
391 "gust_mph": 10.5,
392 "gust_kph": 16.9
393 },
394 "forecast": {
395 "forecastday": [
396 {
397 "date": "2023-07-10",
398 "date_epoch": 1688947200,
399 "day": {
400 "maxtemp_c": 24.4,
401 "maxtemp_f": 75.9,
402 "mintemp_c": 14.1,
403 "mintemp_f": 57.4,
404 "avgtemp_c": 19.6,
405 "avgtemp_f": 67.2,
406 "maxwind_mph": 15.4,
407 "maxwind_kph": 24.8,
408 "totalprecip_mm": 0.0,
409 "totalprecip_in": 0.0,
410 "totalsnow_cm": 0.0,
411 "avgvis_km": 10.0,
412 "avgvis_miles": 6.0,
413 "avghumidity": 60.0,
414 "daily_will_it_rain": 0,
415 "daily_chance_of_rain": 0,
416 "daily_will_it_snow": 0,
417 "daily_chance_of_snow": 0,
418 "condition": {
419 "text": "Partly cloudy",
420 "icon": "//cdn.weatherapi.com/weather/64x64/day/116.png",
421 "code": 1003
422 },
423 "uv": 5.0
424 },
425 "astro": {
426 "sunrise": "04:55 AM",
427 "sunset": "09:16 PM",
428 "moonrise": "12:26 AM",
429 "moonset": "02:01 PM",
430 "moon_phase": "Last Quarter",
431 "moon_illumination": "51",
432 "is_moon_up": 1,
433 "is_sun_up": 0
434 },
435 "hour": [
436 {
437 "time_epoch": 1688943600,
438 "time": "2023-07-10 00:00",
439 "temp_c": 16.2,
440 "temp_f": 61.2,
441 "is_day": 0,
442 "condition": {
443 "text": "Clear",
444 "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png",
445 "code": 1000
446 },
447 "wind_mph": 7.2,
448 "wind_kph": 11.5,
449 "wind_degree": 223,
450 "wind_dir": "SW",
451 "pressure_mb": 1021.0,
452 "pressure_in": 30.14,
453 "precip_mm": 0.0,
454 "precip_in": 0.0,
455 "humidity": 74,
456 "cloud": 6,
457 "feelslike_c": 16.2,
458 "feelslike_f": 61.2,
459 "windchill_c": 16.2,
460 "windchill_f": 61.2,
461 "heatindex_c": 16.2,
462 "heatindex_f": 61.2,
463 "dewpoint_c": 11.6,
464 "dewpoint_f": 52.9,
465 "will_it_rain": 0,
466 "chance_of_rain": 0,
467 "will_it_snow": 0,
468 "chance_of_snow": 0,
469 "vis_km": 10.0,
470 "vis_miles": 6.0,
471 "gust_mph": 10.7,
472 "gust_kph": 17.3,
473 "uv": 1.0
474 },
475 {
476 "time_epoch": 1688947200,
477 "time": "2023-07-10 01:00",
478 "temp_c": 15.7,
479 "temp_f": 60.3,
480 "is_day": 0,
481 "condition": {
482 "text": "Overcast",
483 "icon": "//cdn.weatherapi.com/weather/64x64/night/122.png",
484 "code": 1009
485 },
486 "wind_mph": 7.2,
487 "wind_kph": 11.5,
488 "wind_degree": 232,
489 "wind_dir": "SW",
490 "pressure_mb": 1021.0,
491 "pressure_in": 30.14,
492 "precip_mm": 0.0,
493 "precip_in": 0.0,
494 "humidity": 75,
495 "cloud": 100,
496 "feelslike_c": 15.7,
497 "feelslike_f": 60.3,
498 "windchill_c": 15.7,
499 "windchill_f": 60.3,
500 "heatindex_c": 15.7,
501 "heatindex_f": 60.3,
502 "dewpoint_c": 11.3,
503 "dewpoint_f": 52.3,
504 "will_it_rain": 0,
505 "chance_of_rain": 0,
506 "will_it_snow": 0,
507 "chance_of_snow": 0,
508 "vis_km": 10.0,
509 "vis_miles": 6.0,
510 "gust_mph": 10.5,
511 "gust_kph": 16.9,
512 "uv": 1.0
513 },
514 ...
515 {
516 "time_epoch": 1689026400,
517 "time": "2023-07-10 23:00",
518 "temp_c": 19.0,
519 "temp_f": 66.2,
520 "is_day": 0,
521 "condition": {
522 "text": "Overcast",
523 "icon": "//cdn.weatherapi.com/weather/64x64/night/122.png",
524 "code": 1009
525 },
526 "wind_mph": 9.4,
527 "wind_kph": 15.1,
528 "wind_degree": 192,
529 "wind_dir": "SSW",
530 "pressure_mb": 1015.0,
531 "pressure_in": 29.96,
532 "precip_mm": 0.0,
533 "precip_in": 0.0,
534 "humidity": 66,
535 "cloud": 100,
536 "feelslike_c": 19.0,
537 "feelslike_f": 66.2,
538 "windchill_c": 19.0,
539 "windchill_f": 66.2,
540 "heatindex_c": 19.0,
541 "heatindex_f": 66.2,
542 "dewpoint_c": 12.4,
543 "dewpoint_f": 54.3,
544 "will_it_rain": 0,
545 "chance_of_rain": 0,
546 "will_it_snow": 0,
547 "chance_of_snow": 0,
548 "vis_km": 10.0,
549 "vis_miles": 6.0,
550 "gust_mph": 13.0,
551 "gust_kph": 20.9,
552 "uv": 1.0
553 }
554 ]
555 }
556 ]
557 }
558 }
559 {{/code}}
560
Hunter 39.1 561 The core code is from file API_WEATHER.lua, and function name is get7DayWeatherapiByCityname.
562
563 (% style="text-align:center" %)
564 [[image:WeatherHTTPAPI.png]]
565
566 The HMI offline simulator result:
567
568 (% style="text-align:center" %)
569 [[image:WeatherHTTPtestdisplay.png]]
Hunter 40.1 570
571 = 17 **CSV File Reading** =
572
573 The example shows how to read the csv file into HMI, and then display as table.
574
575 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/csvRead.zip]]
Hunter 41.1 576
Hunter 43.1 577 The core code is from file readcsv.lua:
Hunter 41.1 578
Hunter 43.1 579 1) The file path is set as Sheet_2023_06_13_15_29_45.csv at the root path for USB;
Hunter 42.1 580
581 2) Remember to change csv separator in the second parameter from function csv_csvToTable according to user's need, this demo is using **semicolon** as separator;
582
Hunter 41.1 583 (% style="text-align:center" %)
Hunter 42.1 584 [[image:CSVreadwithsemicolon.png]]
Hunter 43.1 585
586 3) The reading content is a two-dimensional table, can use the table index to locate the specify data cell;
587
588 For example, want to read the 2nd row C column from the table, the table index will be like table[2][3].
589
590 (% style="text-align:center" %)
591 [[image:celllocation.png]]
592
Devin Chen 48.1 593 = 18 How to convert a number to a string =
Devin Chen 47.1 594
595 The example shows how to convert a number to a string using the "tostring()" function.
596
Devin Chen 49.1 597 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Number%20to%20string.zip]]
Devin Chen 47.1 598
Devin Chen 50.1 599 Note:This demo converts a 64-bit floating to a string,you can change the data format of "@W_HDW0" depand on requirements
Devin Chen 49.1 600
Devin Chen 47.1 601 The core code is from file convert.lua:
602
603 (% style="text-align:center" %)
604 [[image:convert.lua.png]]
605
606 The HMI offline simulator result:
607
608 (% style="text-align:center" %)
609 [[image:Converttestdisplay.png]]
Hunter 51.1 610
Hunter 52.1 611 = 19 HUAWEI CLOUD & OpenCloud =
Hunter 53.1 612
613 About the details, please check the powerpoint or video of Lua MQTT & OpenCloud [[Jump To>>doc:PIStudio.Download.1 Manual.WebHome]]
614
615 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/HuaweiMQ%281%29.zip]]
Devin Chen 54.1 616
617 = 20 UDP Multicast =
618
619 The example shows how to use UDP multicast feature to send and receive data.
620
621 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/UDP%20Multicast.zip]]
622
623 About the details, please check the [[UDP module>>https://docs.we-con.com.cn/bin/view/PIStudio/09%20Lua%20Editor/Lua%20Script/#HUDPmodule-1]]
Theodore Xu 55.1 624
625 = 21 ATC module **send SMS** =
626
627 The example shows how to use HMI to customize communication with the ATC SMS module via Lua script to send SMS.
628
629 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/SMS.zip]]
Hunter 56.1 630
631 = 22 TCP Client =
632
633 The example shows how to use the Lua Socket TCP module to connect with a TCP server.
634
Hunter 57.1 635 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/TCP%20ClientV1.1.zip]]
Hunter 56.1 636
637 ~1. Set the initial values of Server IP and port number.
638
639 (% style="text-align:center" %)
640 [[image:vcbt6CE6EL.png]]
641
642 2. Set the actual receive length of TCP message according to the actual needs.
643
644 (% style="text-align:center" %)
645 [[image:tPN1mbz7ny.png]]
Hunter 60.1 646
647 = 23 Lua SMS =
648
649 The example shows how to use HMI built-in 4G module to send SMS via Lua script. This demo requires the HMI model name with (G) or (AG).
650
Hunter 61.1 651 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Lua%20SMS%20Library.zip]]