Wiki source code of 05 Lua Script

Last modified by Joe on 2026/03/03 15:34

Show last authors
1 = **1 **Arithmetic operations =
2
3 The example shows how to do the Addition, Subtraction, Multiplication and Division for HMI internal address.
4
5 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Arithmetic%20operations%20by%20Lua%20V1.0.zip]]
6
7 = **2 MQTT Client** =
8
9 The example shows how to connect to the MQTT server.(Test on MaQiaTTo)
10
11 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Lua%20MQTT%20Client.zip]]
12
13 = **3 Timer** =
14
15 The example shows how to use the Lua Timer function.
16
17 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/LuaTimer.zip]]
18
19 = **4 Trigger** =
20
21 The example shows how to use the Lua Trigger function.
22
23 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/LuaTrigger.zip]]
24
25 = **5 User Free Protocol** =
26
27 The example shows the simple write and read of User Free protocol
28
29 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Lua%20User%20Free%20Protocol.zip]]
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://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/ArabicKeyboard.zip]]
36
37 = **7 FTP Client** =
38
39 The example shows how  to establish the FTP server at WIN10 OS and make V2.0 HMI as FTP client.
40
41 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/FTP%20ClientV2.zip]]
42
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
51 (% class="box infomessage" %)
52 (((
53 Note:About how to set up the FTP server in Windows PC: **[[How to set up and manage an FTP server on Windows 10>>https://www.windowscentral.com/how-set-and-manage-ftp-server-windows-10]]**
54 )))
55
56 1.Enter PC (FTP Server) IP address and port number (Default 21).
57
58 (% style="text-align:center" %)
59 [[image:LuaFTPDemoIP&Port.png]]
60
61 2.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.
62
63 (% style="text-align:center" %)
64 [[image:LuaFTPDemoUpload.png]]
65
66 3.Change drive letter of file save path according to drop-down list (There are three option available: Flash, UDisk and SDCard).
67
68 (% style="text-align:center" %)
69 [[image:LuaFTPDemoDropBox.png]]
70
71 4.Change the filename of the file that needs to be downloaded from PC(Server).
72
73 (% style="text-align:center" %)
74 [[image:LuaFTPDemoDownload.png]]
75
76 5.Set the default configuration in file "Script_BG.lua"
77
78 (% style="text-align:center" %)
79 [[image:LuaFTPDemoInitial.png]]
80
81 (% class="box infomessage" %)
82 (((
83 ✎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 "~/~/".
84 )))
85
86 (% style="text-align:center" %)
87 [[image:LuaFTPDemoFilelist.png]]
88
89 **Common error:**
90
91 In the demo project, if there are some errors in HMI for testing, please check the following steps.
92
93 Error 1: 550 Access is denied
94
95 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
96
97 (% style="text-align:center" %)
98 [[image:qCzqnKTUhp.png]]
99
100 (% style="text-align:center" %)
101 [[image:vfrt3NElMX.png]]
102
103 (% style="text-align:center" %)
104 [[image:dAuz25bdvM.png]]
105
106 (% style="text-align:center" %)
107 [[image:rxQIJkX8ll.png]]
108
109 (% style="text-align:center" %)
110 [[image:vmG8WGu5P2.png]]
111
112
113 Error 2: No route to host
114
115 The previous steps are the same as Error 1 → Port → specific local ports→ input port number "21"→ Click "NEXT" continuously
116
117 (% style="text-align:center" %)
118 [[image:fdsxie8WHc.png]]
119
120 (% style="text-align:center" %)
121 [[image:4ALQq7niTV.png]]
122
123 = **8 Telegram Notification** =
124
125 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.
126
127 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Telegram.zip]]
128
129 = 9** LINE Notify(Not available now)** =
130
131 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.
132
133 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/line.zip]]
134
135
136 = 10** How to parse value from subscribing MQTT topic** =
137
138 (% class="box infomessage" %)
139 (((
140 **Only ig series can use this function.**
141 )))
142
143 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".
144
145 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/MQTT%20JSON%20parse.zip]]
146
147 And the subscribed content is like following:
148
149 {{code language="json"}}
150 {
151 "Cluster_ID": "2",
152 "timestamp": "07:01:45-18.02.2022",
153 "Cust_id": "TAM-1",
154 "Platform_id": "Pro44ead8a8dc3345ACC",
155 "version": "1.5",
156 "Line_active": "true",
157 "Total_sensor": "5",
158 "F1": [
159 {
160 "Counter": "0",
161 "Value": "11"
162 },
163 {
164 "Counter": "1",
165 "Value": "21.1"
166 },
167 {
168 "Counter": "2",
169 "Value": "9"
170 },
171 {
172 "Counter": "3",
173 "Value": "0.06"
174 },
175 {
176 "Counter": "4",
177 "Value": "9"
178 },
179 {
180 "Counter": "5",
181 "Value": "19"
182 },
183 {
184 "Counter": "6",
185 "Value": "9"
186 },
187 {
188 "Counter": "7",
189 "Value": "19"
190 },
191 {
192 "Counter": "8",
193 "Value": "22.89"
194 }
195 ],
196 "F2": [
197 {
198 "Counter": "0",
199 "Value": "1.1"
200 },
201 {
202 "Counter": "1",
203 "Value": "21.21"
204 },
205 {
206 "Counter": "2",
207 "Value": "19"
208 },
209 {
210 "Counter": "3",
211 "Value": "0.6"
212 },
213 {
214 "Counter": "4",
215 "Value": "8"
216 },
217 {
218 "Counter": "5",
219 "Value": "19.1"
220 },
221 {
222 "Counter": "6",
223 "Value": "5.1"
224 }
225 ],
226 "F4": [
227 {
228 "Counter": "0",
229 "Value": "11"
230 },
231 {
232 "Counter": "1",
233 "Value": "21.1"
234 },
235 {
236 "Counter": "2",
237 "Value": "9"
238 },
239 {
240 "Counter": "3",
241 "Value": "0.06"
242 },
243 {
244 "Counter": "4",
245 "Value": "9"
246 },
247 {
248 "Counter": "5",
249 "Value": "19"
250 },
251 {
252 "Counter": "6",
253 "Value": "9"
254 },
255 {
256 "Counter": "7",
257 "Value": "12.1"
258 },
259 {
260 "Counter": "8",
261 "Value": "18.1"
262 }
263 ]
264 }
265 {{/code}}
266
267 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).
268
269 (% style="text-align:center" %)
270 [[image:MQTTScreen.png]]
271
272 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:
273
274 (% style="text-align:center" %)
275 [[image:MQTTactualtestingresult.png]]
276
277 The JSON parser function is located on mqttAction.lua, called mqtt_msg_callback.
278
279 (% style="text-align:center" %)
280 [[image:MQTTJSONparsefunction.png]]
281
282 = **11 High-Low Byte Switch** =
283
284 The example shows how to convert high bytes and low bytes for one 16bit address. Main function is like following:
285
286 {{code language="lua"}}
287 local lowByte = val & 0x00ff
288 local shiftHigh = lowByte << 8
289 local highByte = val & 0xff00
290 local shiftLow = highByte >> 8
291 local newVal = shiftHigh|shiftLow
292 {{/code}}
293
294 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/byteswitch.zip]]
295
296 = **12 Week time setting** =
297
298 The example shows how to use day time to control functions:
299
300 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/week%20time.zip]]
301
302 = **13 MQTT Multi-link** =
303
304 (% class="box infomessage" %)
305 (((
306 **Only ig series can support this function.**
307 )))
308
309 The example shows use mqtt realize multi-machine function:
310
311 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/MQTT%20Multi-link.zip]]
312
313 = **14 CSV File Generation** =
314
315 The example shows convert the custom lua table data into csv string, then output as a file:
316
317 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/csvGenerate.zip]]
318
319 The following steps take HMI simulator as example:
320
321 ~1. Click button "Create Table" to draw lua table in screen.
322
323 (% style="text-align:center" %)
324 [[image:csvGenerateSteps.png]]
325
326 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.
327
328 (% style="text-align:center" %)
329 [[image:csvGenerateSimulationPath.png]]
330
331 3. Click button "upload" to upload csv file into server side. In this case, we can check the upload path for PC.
332
333 (% style="text-align:center" %)
334 [[image:csvGenerateServerPath.png]]
335
336 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":
337
338 (% style="text-align:center" %)
339 [[image:csvGenerateLuaCode.png]]
340
341 The table drawing is mainly using the following function to implement:
342
343 (% style="text-align:center" %)
344 [[image:csvLuaTableDrawing.png]]
345
346 = 15 **String customized length word-wrapped** =
347
348 The example shows automatically line break for long string content according to user input length.
349
350 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/CRLF.zip]]
351
352 The following are some demonstrated strings from offline simulator:
353
354 (% style="text-align:center" %)
355 [[image:WordWrapDisplayResult.png]]
356
357 = 16 Weather forecast HTTP API request =
358
359 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/]]
360
361 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/luahttp.zip]]
362
363 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):
364
365 {{code language="JSON"}}
366 {
367 "location": {
368 "name": "London",
369 "region": "City of London, Greater London",
370 "country": "United Kingdom",
371 "lat": 51.52,
372 "lon": -0.11,
373 "tz_id": "Europe/London",
374 "localtime_epoch": 1688961236,
375 "localtime": "2023-07-10 4:53"
376 },
377 "current": {
378 "last_updated_epoch": 1688960700,
379 "last_updated": "2023-07-10 04:45",
380 "temp_c": 14.0,
381 "temp_f": 57.2,
382 "is_day": 0,
383 "condition": {
384 "text": "Partly cloudy",
385 "icon": "//cdn.weatherapi.com/weather/64x64/night/116.png",
386 "code": 1003
387 },
388 "wind_mph": 4.3,
389 "wind_kph": 6.8,
390 "wind_degree": 220,
391 "wind_dir": "SW",
392 "pressure_mb": 1020.0,
393 "pressure_in": 30.12,
394 "precip_mm": 0.0,
395 "precip_in": 0.0,
396 "humidity": 88,
397 "cloud": 50,
398 "feelslike_c": 13.3,
399 "feelslike_f": 56.0,
400 "vis_km": 10.0,
401 "vis_miles": 6.0,
402 "uv": 1.0,
403 "gust_mph": 10.5,
404 "gust_kph": 16.9
405 },
406 "forecast": {
407 "forecastday": [
408 {
409 "date": "2023-07-10",
410 "date_epoch": 1688947200,
411 "day": {
412 "maxtemp_c": 24.4,
413 "maxtemp_f": 75.9,
414 "mintemp_c": 14.1,
415 "mintemp_f": 57.4,
416 "avgtemp_c": 19.6,
417 "avgtemp_f": 67.2,
418 "maxwind_mph": 15.4,
419 "maxwind_kph": 24.8,
420 "totalprecip_mm": 0.0,
421 "totalprecip_in": 0.0,
422 "totalsnow_cm": 0.0,
423 "avgvis_km": 10.0,
424 "avgvis_miles": 6.0,
425 "avghumidity": 60.0,
426 "daily_will_it_rain": 0,
427 "daily_chance_of_rain": 0,
428 "daily_will_it_snow": 0,
429 "daily_chance_of_snow": 0,
430 "condition": {
431 "text": "Partly cloudy",
432 "icon": "//cdn.weatherapi.com/weather/64x64/day/116.png",
433 "code": 1003
434 },
435 "uv": 5.0
436 },
437 "astro": {
438 "sunrise": "04:55 AM",
439 "sunset": "09:16 PM",
440 "moonrise": "12:26 AM",
441 "moonset": "02:01 PM",
442 "moon_phase": "Last Quarter",
443 "moon_illumination": "51",
444 "is_moon_up": 1,
445 "is_sun_up": 0
446 },
447 "hour": [
448 {
449 "time_epoch": 1688943600,
450 "time": "2023-07-10 00:00",
451 "temp_c": 16.2,
452 "temp_f": 61.2,
453 "is_day": 0,
454 "condition": {
455 "text": "Clear",
456 "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png",
457 "code": 1000
458 },
459 "wind_mph": 7.2,
460 "wind_kph": 11.5,
461 "wind_degree": 223,
462 "wind_dir": "SW",
463 "pressure_mb": 1021.0,
464 "pressure_in": 30.14,
465 "precip_mm": 0.0,
466 "precip_in": 0.0,
467 "humidity": 74,
468 "cloud": 6,
469 "feelslike_c": 16.2,
470 "feelslike_f": 61.2,
471 "windchill_c": 16.2,
472 "windchill_f": 61.2,
473 "heatindex_c": 16.2,
474 "heatindex_f": 61.2,
475 "dewpoint_c": 11.6,
476 "dewpoint_f": 52.9,
477 "will_it_rain": 0,
478 "chance_of_rain": 0,
479 "will_it_snow": 0,
480 "chance_of_snow": 0,
481 "vis_km": 10.0,
482 "vis_miles": 6.0,
483 "gust_mph": 10.7,
484 "gust_kph": 17.3,
485 "uv": 1.0
486 },
487 {
488 "time_epoch": 1688947200,
489 "time": "2023-07-10 01:00",
490 "temp_c": 15.7,
491 "temp_f": 60.3,
492 "is_day": 0,
493 "condition": {
494 "text": "Overcast",
495 "icon": "//cdn.weatherapi.com/weather/64x64/night/122.png",
496 "code": 1009
497 },
498 "wind_mph": 7.2,
499 "wind_kph": 11.5,
500 "wind_degree": 232,
501 "wind_dir": "SW",
502 "pressure_mb": 1021.0,
503 "pressure_in": 30.14,
504 "precip_mm": 0.0,
505 "precip_in": 0.0,
506 "humidity": 75,
507 "cloud": 100,
508 "feelslike_c": 15.7,
509 "feelslike_f": 60.3,
510 "windchill_c": 15.7,
511 "windchill_f": 60.3,
512 "heatindex_c": 15.7,
513 "heatindex_f": 60.3,
514 "dewpoint_c": 11.3,
515 "dewpoint_f": 52.3,
516 "will_it_rain": 0,
517 "chance_of_rain": 0,
518 "will_it_snow": 0,
519 "chance_of_snow": 0,
520 "vis_km": 10.0,
521 "vis_miles": 6.0,
522 "gust_mph": 10.5,
523 "gust_kph": 16.9,
524 "uv": 1.0
525 },
526 ...
527 {
528 "time_epoch": 1689026400,
529 "time": "2023-07-10 23:00",
530 "temp_c": 19.0,
531 "temp_f": 66.2,
532 "is_day": 0,
533 "condition": {
534 "text": "Overcast",
535 "icon": "//cdn.weatherapi.com/weather/64x64/night/122.png",
536 "code": 1009
537 },
538 "wind_mph": 9.4,
539 "wind_kph": 15.1,
540 "wind_degree": 192,
541 "wind_dir": "SSW",
542 "pressure_mb": 1015.0,
543 "pressure_in": 29.96,
544 "precip_mm": 0.0,
545 "precip_in": 0.0,
546 "humidity": 66,
547 "cloud": 100,
548 "feelslike_c": 19.0,
549 "feelslike_f": 66.2,
550 "windchill_c": 19.0,
551 "windchill_f": 66.2,
552 "heatindex_c": 19.0,
553 "heatindex_f": 66.2,
554 "dewpoint_c": 12.4,
555 "dewpoint_f": 54.3,
556 "will_it_rain": 0,
557 "chance_of_rain": 0,
558 "will_it_snow": 0,
559 "chance_of_snow": 0,
560 "vis_km": 10.0,
561 "vis_miles": 6.0,
562 "gust_mph": 13.0,
563 "gust_kph": 20.9,
564 "uv": 1.0
565 }
566 ]
567 }
568 ]
569 }
570 }
571 {{/code}}
572
573 The core code is from file API_WEATHER.lua, and function name is get7DayWeatherapiByCityname.
574
575 (% style="text-align:center" %)
576 [[image:WeatherHTTPAPI.png]]
577
578 The HMI offline simulator result:
579
580 (% style="text-align:center" %)
581 [[image:WeatherHTTPtestdisplay.png]]
582
583 = 17 **CSV File Reading** =
584
585 The example shows how to read the csv file into HMI, and then display as table.
586
587 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/csvRead.zip]]
588
589 The core code is from file readcsv.lua:
590
591 1) The file path is set as Sheet_2023_06_13_15_29_45.csv at the root path for USB;
592
593 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;
594
595 (% style="text-align:center" %)
596 [[image:CSVreadwithsemicolon.png]]
597
598 3) The reading content is a two-dimensional table, can use the table index to locate the specify data cell;
599
600 For example, want to read the 2nd row C column from the table, the table index will be like table[2][3].
601
602 (% style="text-align:center" %)
603 [[image:celllocation.png]]
604
605 = 18 How to convert a number to a string =
606
607 The example shows how to convert a number to a string using the "tostring()" function.
608
609 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Number%20to%20string.zip]]
610
611 Note:This demo converts a 64-bit floating to a string,you can change the data format of "@W_HDW0" depand on requirements
612
613 The core code is from file convert.lua:
614
615 (% style="text-align:center" %)
616 [[image:convert.lua.png]]
617
618 The HMI offline simulator result:
619
620 (% style="text-align:center" %)
621 [[image:Converttestdisplay.png]]
622
623 = 19 HUAWEI CLOUD & OpenCloud =
624
625 About the details, please check the powerpoint or video of Lua MQTT & OpenCloud [[Jump To>>doc:PIStudio.Download.1 Manual.WebHome]]
626
627 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/HuaweiMQ%281%29.zip]]
628
629 = 20 UDP Multicast =
630
631 The example shows how to use UDP multicast feature to send and receive data.
632
633 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/UDP%20Multicast.zip]]
634
635 About the details, please check the [[UDP module>>https://docs.we-con.com.cn/bin/view/PIStudio/09%20Lua%20Editor/Lua%20Script/#HUDPmodule-1]]
636
637 = 21 ATC module **send SMS** =
638
639 The example shows how to use HMI to customize communication with the ATC SMS module via Lua script to send SMS.
640
641 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/SMS.zip]]
642
643 = 22 TCP Client =
644
645 The example shows how to use the Lua Socket TCP module to connect with a TCP server.
646
647 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/TCP%20ClientV1.1.zip]]
648
649 ~1. Set the initial values of Server IP and port number.
650
651 (% style="text-align:center" %)
652 [[image:vcbt6CE6EL.png]]
653
654 2. Set the actual receive length of TCP message according to the actual needs.
655
656 (% style="text-align:center" %)
657 [[image:tPN1mbz7ny.png]]
658
659 = 23 Lua SMS =
660
661 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).
662
663 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Lua%20SMS%20Library.zip]]
664
665 = 24 ATC module Calling =
666
667 The example shows how to use HMI to customize communication with the ATC-3101 module via Lua script to make phone call.
668
669 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/lua%20ATC%20calling.rar]]
670
671 (% class="box infomessage" %)
672 (((
673 Note:Due to differences in operators, it is recommended to test before use.
674 )))
675
676 = 25 Lua SQLite =
677
678 The example shows how to generate a user customized database and table via Lua script.
679
680 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/SQL%20demo.zip]]
681
682 ~1. Choose the designate storage path of db file, here we choose the U disk;
683
684 (% style="text-align:center" %)
685 [[image:lgvAY47My2.png]]
686
687 2. Create the database a.db and create the table filer;
688
689 (% style="text-align:center" %)
690 [[image:SbfZ7qC2qr.png]]
691
692 3. Write the data of HDW10, then click Add data to insert new record into the table filer;
693
694 (% style="text-align:center" %)
695 [[image:sMi8nKsDCy.png]]
696
697 4. Export the file a.db to PC, and using the DB Browser to view the created data(Because it is not standard data record file, not able to be recognized correctly by DataLogTool);
698
699 (% style="text-align:center" %)
700 [[image:xT8f08pfY0.png]]
701
702 = 26 Send attachment picture with SMTP by Gmail =
703
704 The project is to send mail message with text and attachment picture called test.png.
705
706 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/SMTP%20for%20Gmail%28with%20Attachment%20picture%20%29.zip]]
707
708 = 27 TTS function =
709
710 The project is to show a Music Player and alarm sound with TTS function in Lua script. Please note that  use PI version 10.4 or higher to open the project.
711
712 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Music%20player.pi2]]
713
714 = 28 Google Sheets API =
715
716 The example shows how to send the data into the Google sheets API via Lua script. [[Jump to Video>>https://youtu.be/VKjr3_MVNzc]]
717
718 {{warning}}
719 since the HMI lacks a built-in library for cryptographic signatures (RS256/JWT), user can automate this by sending the token to the HMI via external communication. Token need to be manual input in this project.
720 {{/warning}}
721
722 [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/GoogleSheet.zip]]