nodeMCU (ESP8266)

Exercici 1

Començarem amb un exemple força senzill per assegurar-nos que tota la infraestructura funciona perfectament, és a dir, crearem una app tal com indica el següent vídeo.

El connexionat és així:

L'sketch és aquest:

Exercici 2

Ara farem aquesta app:

El connexionat és:

I l'sketch és aquest:

Exercici 3

App:

Connexionat:

Sketch:

Exercici 4

  1. Instal·lem node-red segons aquesta pràctica
  2. Instal·la l'app Telegram al mòbil (android o iphone), a l'ordinador, al chrome, o al firefox.
  3. Creat un bot que ens permetrà controlar el sistema domòtic. Tutorial.
  4. Personalitza aquest flow.
[{"id":"887f2da2.c7379","type":"inject","z":"f83b0604.a2883","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":185,"y":153,"wires":[["d4b17ce0.2b57d"]]},{"id":"d4b17ce0.2b57d","type":"debug","z":"f83b0604.a2883","name":"","active":true,"console":"false","complete":"false","x":461,"y":151.10765075683594,"wires":[]},{"id":"9b7e8c7f.c3397","type":"http request","z":"f83b0604.a2883","name":"off Q15","method":"GET","ret":"txt","url":"http://vps249990.ovh.net:8080/74bfb40bcd5f4472b5f7d84c48346a03/update/D15?value=0","tls":"","x":464.00347900390625,"y":275.30902099609375,"wires":[[]]},{"id":"18f8ca96.957d25","type":"http request","z":"f83b0604.a2883","name":"on Q15","method":"GET","ret":"txt","url":"http://vps249990.ovh.net:8080/74bfb40bcd5f4472b5f7d84c48346a03/update/D15?value=1","tls":"","x":462.51039123535156,"y":336.6458282470703,"wires":[[]]},{"id":"be749de8.29e64","type":"inject","z":"f83b0604.a2883","name":"off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":162,"y":275,"wires":[["9b7e8c7f.c3397"]]},{"id":"dfcac1b8.30f31","type":"inject","z":"f83b0604.a2883","name":"on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":163.00694274902344,"y":333.99305725097656,"wires":[["18f8ca96.957d25"]]},{"id":"fa252618.ca875","type":"function","z":"f83b0604.a2883","name":"headers","func":" msg.headers = \n {\n \"Content-type\" : \"application/json\" \n };\n //msg.payload=\"[ \\\"0\\\"]\"\n return msg;","outputs":1,"noerr":0,"x":476.22222900390625,"y":489,"wires":[["583d990.8a58ce8"]]},{"id":"f0ece3ad.b5cf9","type":"trigger","z":"f83b0604.a2883","op1":"[ \"0\"]","op2":"[ \"1\"]","op1type":"str","op2type":"str","duration":"5","extend":false,"units":"s","reset":"","name":"","x":311.88885498046875,"y":488.88885498046875,"wires":[["fa252618.ca875"]]},{"id":"ebdd852f.f0de88","type":"inject","z":"f83b0604.a2883","name":"DISPARA","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"x":155,"y":489.6666259765625,"wires":[["f0ece3ad.b5cf9"]]},{"id":"583d990.8a58ce8","type":"http request","z":"f83b0604.a2883","name":"ON-OFF Q13","method":"PUT","ret":"txt","url":"http://vps249990.ovh.net:8080/74bfb40bcd5f4472b5f7d84c48346a03/pin/D13","tls":"","x":660.8333129882812,"y":488.83331298828125,"wires":[[]]},{"id":"b0579bea.509","type":"comment","z":"f83b0604.a2883","name":"INTERMITÈNCIA Q13","info":"","x":157,"y":445,"wires":[]},{"id":"1233cc36.bbb7ac","type":"comment","z":"f83b0604.a2883","name":"Hola món!","info":"","x":158.5,"y":112,"wires":[]},{"id":"eb84139.8c227f","type":"comment","z":"f83b0604.a2883","name":"ON-OFF Q15","info":"","x":155,"y":231,"wires":[]},{"id":"ccdd828.eedcc8","type":"debug","z":"f83b0604.a2883","name":"","active":true,"console":"false","complete":"false","x":726.5,"y":597,"wires":[]},{"id":"8092224d.957d5","type":"inject","z":"f83b0604.a2883","name":"DISPARA","topic":"","payload":"","payloadType":"date","repeat":"4","crontab":"","once":false,"x":132,"y":632,"wires":[["d77225b3.0d4f98"]]},{"id":"d77225b3.0d4f98","type":"http request","z":"f83b0604.a2883","name":"GET I14","method":"GET","ret":"txt","url":"http://vps249990.ovh.net:8080/74bfb40bcd5f4472b5f7d84c48346a03/get/V14","tls":"","x":314,"y":635,"wires":[["762187cd.9bd0c"]]},{"id":"cd34558d.414b7","type":"comment","z":"f83b0604.a2883","name":"ALARMA I14","info":"","x":131,"y":591,"wires":[]},{"id":"762187cd.9bd0c","type":"function","z":"f83b0604.a2883","name":"","func":"if (msg.payload=='[\"255\"]')\n{\n    msg.payload='Alarma I14';\n    return msg;\n}","outputs":1,"noerr":0,"x":490.5,"y":635,"wires":[["ccdd828.eedcc8","d7421714.cbacb"]]},{"id":"d7421714.cbacb","type":"e-mail","z":"f83b0604.a2883","server":"smtp.gmail.com","port":"465","secure":true,"name":"jnogues@gmail.com","dname":"","x":757.5,"y":635,"wires":[]},{"id":"a0b1181b.3caf5","type":"telegram receiver","z":"f83b0604.a2883","name":"","bot":"a1fa1f33.62a238","x":141,"y":1047,"wires":[["cb01c6f0.295ba"],[]]},{"id":"cb01c6f0.295ba","type":"debug","z":"f83b0604.a2883","name":"","active":true,"console":"false","complete":"false","x":458,"y":1041,"wires":[]},{"id":"2efe6823.6f8d28","type":"inject","z":"f83b0604.a2883","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":121,"y":1143,"wires":[["bdc7a93c.626a3"]]},{"id":"ff4541a5.f05618","type":"telegram sender","z":"f83b0604.a2883","name":"","bot":"a1fa1f33.62a238","x":543,"y":1143,"wires":[[]]},{"id":"bdc7a93c.626a3","type":"function","z":"f83b0604.a2883","name":"","func":"\n    msg.payload ={ \"chatId\": 226661846, \"type\": \"message\", \"content\": \"Alarma I2!!\" };\n    return msg;\n","outputs":1,"noerr":0,"x":303,"y":1143,"wires":[["ff4541a5.f05618"]]},{"id":"d214909f.66f5a","type":"telegram command","z":"f83b0604.a2883","name":"/q2on","command":"/q2on","bot":"a1fa1f33.62a238","x":99,"y":1264,"wires":[["b2e0c8e9.1b2cd"],[]]},{"id":"16cb9c2f.fc88dc","type":"debug","z":"f83b0604.a2883","name":"","active":true,"console":"false","complete":"true","x":655.5,"y":1280,"wires":[]},{"id":"b2e0c8e9.1b2cd","type":"http request","z":"f83b0604.a2883","name":"ON D2","method":"GET","ret":"txt","url":"http://vps249990.ovh.net:8080/74bfb40bcd5f4472b5f7d84c48346a03/update/D2?value=0","tls":"","x":386,"y":1260,"wires":[["16cb9c2f.fc88dc"]]},{"id":"f5103baf.5b3f18","type":"telegram command","z":"f83b0604.a2883","name":"/q2off","command":"/q2off","bot":"a1fa1f33.62a238","x":99,"y":1315,"wires":[["b629059d.28aa48"],[]]},{"id":"b629059d.28aa48","type":"http request","z":"f83b0604.a2883","name":"OFF D2","method":"GET","ret":"txt","url":"http://vps249990.ovh.net:8080/74bfb40bcd5f4472b5f7d84c48346a03/update/D2?value=1","tls":"","x":388,"y":1310,"wires":[["16cb9c2f.fc88dc"]]},{"id":"590a9b64.e30c44","type":"comment","z":"f83b0604.a2883","name":"ON-OFF Q2 telegram","info":"","x":149,"y":1228,"wires":[]},{"id":"9dfd2982.277e08","type":"comment","z":"f83b0604.a2883","name":"TELEGRAM","info":"","x":121,"y":991,"wires":[]},{"id":"aa3ce95d.88e97","type":"debug","z":"f83b0604.a2883","name":"","active":true,"console":"false","complete":"false","x":891.5,"y":1442,"wires":[]},{"id":"39061817.02c28","type":"inject","z":"f83b0604.a2883","name":"DISPARA","topic":"","payload":"","payloadType":"date","repeat":"4","crontab":"","once":false,"x":113,"y":1446,"wires":[["4073ec3d.4fdf34"]]},{"id":"4073ec3d.4fdf34","type":"http request","z":"f83b0604.a2883","name":"GET I14","method":"GET","ret":"txt","url":"http://vps249990.ovh.net:8080/74bfb40bcd5f4472b5f7d84c48346a03/get/V14","tls":"","x":296,"y":1445,"wires":[["99418fdc.1b0c5"]]},{"id":"fa9b8b94.891948","type":"comment","z":"f83b0604.a2883","name":"ALARMA I14","info":"","x":113,"y":1401,"wires":[]},{"id":"99418fdc.1b0c5","type":"function","z":"f83b0604.a2883","name":"","func":"if (msg.payload=='[\"255\"]'){\n    msg.payload ={ \"chatId\": 226661846, \"type\": \"message\", \"content\": \"Alarma I14!!\" };\n    return msg;\n}\n","outputs":1,"noerr":0,"x":483,"y":1445,"wires":[["4555a767.5c91f"]]},{"id":"4555a767.5c91f","type":"telegram sender","z":"f83b0604.a2883","name":"","bot":"a1fa1f33.62a238","x":685,"y":1446,"wires":[["aa3ce95d.88e97"]]},{"id":"9852621d.2ded4","type":"blynk-websockets-in-write","z":"f83b0604.a2883","name":"","pin":"3","client":"83af8116.73e798","x":167.5,"y":1624,"wires":[["abd26df0.e170a8"]]},{"id":"2ef8089d.5462b","type":"blynk-websockets-out-write","z":"f83b0604.a2883","name":"","pin":"6","client":"83af8116.73e798","x":443.5,"y":1705,"wires":[]},{"id":"abd26df0.e170a8","type":"debug","z":"f83b0604.a2883","name":"","active":true,"console":"false","complete":"false","x":433.5,"y":1622,"wires":[]},{"id":"47c7ba56.a422ec","type":"inject","z":"f83b0604.a2883","name":"","topic":"","payload":"255","payloadType":"str","repeat":"","crontab":"","once":false,"x":136.5,"y":1750,"wires":[["2ef8089d.5462b"]]},{"id":"e14cfe1a.f71e58","type":"inject","z":"f83b0604.a2883","name":"","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":129,"y":1704,"wires":[["2ef8089d.5462b"]]},{"id":"782ee3e.d434f9c","type":"comment","z":"f83b0604.a2883","name":"BLYNK","info":"","x":97,"y":1596,"wires":[]},{"id":"a1fa1f33.62a238","type":"telegram bot","z":"","botname":"BerLaiBot","usernames":"","chatids":""},{"id":"83af8116.73e798","type":"blynk-websockets-client","z":"","name":"","path":"ws://vps249990.ovh.net:8080/websockets","key":"74bfb40bcd5f4472b5f7d84c48346a03"}]