En aquesta pràctica intercomunicarem una app de blynk amb un LOGO!, mitjançant node-red. Ens assegurem de tenir instal·lat el node node-red-contrib-blynk-websockets.

Primer, carregarem aquest programa al Logo! IoT-logo-04.zip.

Segon, crearem una app de blynk com aquesta:

Tercer, importem aquest flow. Caldrà configurar el token del nostre projecte de blynk.

[{"id":"af580256.1e8ae","type":"s7 out","z":"3490053.d9c057a","endpoint":"94cd9c57.c1ff4","variable":"q1","name":"","x":571.8181762695312,"y":300.9090881347656,"wires":[]},{"id":"8ff7816c.2d8a68","type":"blynk-websockets-in-write","z":"3490053.d9c057a","name":"","pin":"60","client":"8d8d0583.3298f8","x":229.333251953125,"y":304.5252990722656,"wires":[["750dff74.1315e8","af580256.1e8ae"]]},{"id":"750dff74.1315e8","type":"debug","z":"3490053.d9c057a","name":"","active":true,"console":"false","complete":"payload","x":589.3331909179688,"y":249.70712280273438,"wires":[]},{"id":"3cbb21c9.ea622e","type":"blynk-websockets-in-write","z":"3490053.d9c057a","name":"","pin":"61","client":"8d8d0583.3298f8","x":230.333251953125,"y":371.5252990722656,"wires":[["bf7429c.9f615d8"]]},{"id":"8312d46a.2acc18","type":"blynk-websockets-in-write","z":"3490053.d9c057a","name":"","pin":"62","client":"8d8d0583.3298f8","x":232.333251953125,"y":432.5252990722656,"wires":[["8edca360.953be8"]]},{"id":"4d69489d.a7d638","type":"blynk-websockets-in-write","z":"3490053.d9c057a","name":"","pin":"63","client":"8d8d0583.3298f8","x":232.333251953125,"y":496.5252990722656,"wires":[["55438531.754b74"]]},{"id":"bf7429c.9f615d8","type":"s7 out","z":"3490053.d9c057a","endpoint":"94cd9c57.c1ff4","variable":"q2","name":"","x":570.333251953125,"y":369.16168212890625,"wires":[]},{"id":"8edca360.953be8","type":"s7 out","z":"3490053.d9c057a","endpoint":"94cd9c57.c1ff4","variable":"q3","name":"","x":569.2423095703125,"y":432.07073974609375,"wires":[]},{"id":"55438531.754b74","type":"s7 out","z":"3490053.d9c057a","endpoint":"94cd9c57.c1ff4","variable":"q4","name":"","x":566.6060180664062,"y":493.8888854980469,"wires":[]},{"id":"7e5a7a64.e76674","type":"s7 in","z":"3490053.d9c057a","endpoint":"94cd9c57.c1ff4","mode":"single","variable":"I1","diff":true,"name":"","x":181.818115234375,"y":629.9999694824219,"wires":[["ead00b62.a06c78"]]},{"id":"25861c5.b4f63e4","type":"blynk-websockets-out-write","z":"3490053.d9c057a","name":"","pin":"64","client":"8d8d0583.3298f8","x":570.4545288085938,"y":629.9999389648438,"wires":[]},{"id":"ead00b62.a06c78","type":"function","z":"3490053.d9c057a","name":"","func":"if (msg.payload== 1){\n    msg.payload=\"255\";\n}\nelse {\n    msg.payload=\"0\";    \n}\nreturn msg;","outputs":1,"noerr":0,"x":348.1817321777344,"y":629.9999694824219,"wires":[["25861c5.b4f63e4"]]},{"id":"3aa370f8.b0fb48","type":"s7 in","z":"3490053.d9c057a","endpoint":"94cd9c57.c1ff4","mode":"single","variable":"I2","diff":true,"name":"","x":179.09091186523438,"y":692.727294921875,"wires":[["19401c06.8bff6c"]]},{"id":"1471b23c.4ce45e","type":"s7 in","z":"3490053.d9c057a","endpoint":"94cd9c57.c1ff4","mode":"single","variable":"I3","diff":true,"name":"","x":173.63638305664062,"y":749.9998779296875,"wires":[["2c55696f.ff23ce"]]},{"id":"eb94f9bd.b82838","type":"s7 in","z":"3490053.d9c057a","endpoint":"94cd9c57.c1ff4","mode":"single","variable":"I4","diff":true,"name":"","x":177.27273559570312,"y":814.54541015625,"wires":[["190c76a1.3872a1"]]},{"id":"45b39ebd.00255","type":"blynk-websockets-out-write","z":"3490053.d9c057a","name":"","pin":"65","client":"8d8d0583.3298f8","x":568.1818237304688,"y":690.0000610351562,"wires":[]},{"id":"19401c06.8bff6c","type":"function","z":"3490053.d9c057a","name":"","func":"if (msg.payload== 1){\n    msg.payload=\"255\";\n}\nelse {\n    msg.payload=\"0\";    \n}\nreturn msg;","outputs":1,"noerr":0,"x":334.09092018821025,"y":693.6363580877131,"wires":[["45b39ebd.00255"]]},{"id":"3955a7af.4bd1","type":"blynk-websockets-out-write","z":"3490053.d9c057a","name":"","pin":"66","client":"8d8d0583.3298f8","x":564.5454711914062,"y":747.2727661132812,"wires":[]},{"id":"2c55696f.ff23ce","type":"function","z":"3490053.d9c057a","name":"","func":"if (msg.payload== 1){\n    msg.payload=\"255\";\n}\nelse {\n    msg.payload=\"0\";    \n}\nreturn msg;","outputs":1,"noerr":0,"x":341.3636474609375,"y":745.4546508789062,"wires":[["3955a7af.4bd1"]]},{"id":"acd9f35e.2b19d8","type":"blynk-websockets-out-write","z":"3490053.d9c057a","name":"","pin":"67","client":"8d8d0583.3298f8","x":560,"y":809.9999389648438,"wires":[]},{"id":"190c76a1.3872a1","type":"function","z":"3490053.d9c057a","name":"","func":"if (msg.payload== 1){\n    msg.payload=\"255\";\n}\nelse {\n    msg.payload=\"0\";    \n}\nreturn msg;","outputs":1,"noerr":0,"x":327.72723388671875,"y":812.727294921875,"wires":[["acd9f35e.2b19d8"]]},{"id":"94cd9c57.c1ff4","type":"s7 endpoint","z":"","address":"192.168.1.70","port":"102","rack":"0","slot":"2","cycletime":"500","name":"","vartable":[{"addr":"DB1,B105","name":"q1"},{"addr":"DB1,B106","name":"q2"},{"addr":"DB1,B107","name":"q3"},{"addr":"DB1,B108","name":"q4"},{"addr":"DB1,B120","name":"A0"},{"addr":"DB1,B10","name":"I1"},{"addr":"DB1,DW20","name":"C002"},{"addr":"DB1,B11","name":"I2"},{"addr":"DB1,B12","name":"I3"},{"addr":"DB1,B13","name":"I4"}]},{"id":"8d8d0583.3298f8","type":"blynk-websockets-client","z":"","name":"","path":"ws://vps249990.ovh.net:8080/websockets","key":"33cf442ca9a14a91b1f576aa143e6dd5"}]