Tutorial de Node-RED: Construye tu propio cuadro de mandos meteorológico con Raspberry Pi PLC / Panel PC

Crea un tablero de control Node-RED de clima ambiental con tu PLC y Panel PC basados en Raspberry Pi
19 de enero de 2022 por
Tutorial de Node-RED: Construye tu propio cuadro de mandos meteorológico con Raspberry Pi PLC / Panel PC
Boot & Work Corp. S.L., Fernandez Queralt Martinez

Introducción

¿Te gustaría construir tu propio sistema de vigilancia meteorológica con un cuadro de mando Node-RED?

En esta entrada del blog, vamos a obtener el tiempo de OpenWeatherMap.orgy mostrarlo con diferentes widgets en un panel de control Node-RED.

Últimas publicaciones

Your Dynamic Snippet will be displayed here... This message is displayed because you did not provided both a filter and a template to use.

OpenWeather es una plataforma que se define como un "enfoque científico y a la vez sencillo de la previsión meteorológica". Gratis. Sin anuncios".

Puedes visitar el official website >

En esta entrada del blog, vamos a utilizar el nodo Node-RED de openweathermap: node-red-node-openweathermap, que encuesta openweathermap.org para los datos meteorológicos actuales cuando se recibe una entrada.

Node-Red-Node-Openweathermap

Para instalarlo, puedes ir al Menú > Gestionar Paleta > Instalar > Tipo: node-red-node-openweathermap y haz clic en Instalar.

Node-Red-Node-Openweathermap

O también puedes ir al directorio .node-red/ e instalar los nodos desde allí:

cd /home/$USER/.node-red
npm install node-red-node-openweathermap

Una vez instalado, ya puedes ir a la sección de nodos, donde encontrarás los nodos de openweathermap  

En este caso, vamos a utilizar el mapa de openweather, no el de openweather in.

Odoo • Text and Image

Suéltalo en el flujo de Node-RED y haz doble clic para editarlo. Verás que el primer parámetro es la clave de la API. Vaya al parámetro OpenWeather's website >>>y generar una nueva clave API.

Una vez validada (puede tardar entre 10 minutos y 2 horas después del registro exitoso), pega la clave API en el nodo.

OpenWeather - Node-RED Tutorial

Por último, en la ubicación, puedes elegir entre "Ciudad, País" o "Coordenadas". Selecciona la opción que más te convenga. Ahora:

  1. Añadir un nodo de inyección
  2. Conéctalo al nodo openweathermap
  3. Añadir un nodo de depuración

¡Y observa toda la información que recibe!

Node-red - Node-RED Tutorial

A partir de ahí, enlaza el msg.payload con los nodos del cuadro de mandos, y muestra los widgets con la información meteorológica como quieras. Por ejemplo:

Add a gauge node. 
Type: Donut. 
Label: Humidity.
Value format: {{payload.humidity}}
Units: %
Range: min:0, max:100

Obtén la salida del nodo openweathermap y conéctela a este nodo de calibre. 

Odoo • Image and Text

Ve al panel de control:
http://<hostname>:1880/ui 
¡y observa la humedad mostrada!

Haz lo mismo con el resto de los parámetros y crea un increíble Cuadro de Mando basado en los datos de OpenWeather.

Prueba

Ahora, copia este flows.json de abajo, ve al menú de Node-RED, haz clic en Importar > Pegar este JSON, haz clic en Hecho. ¡Y compara nuestro Dashboard de Node-RED con el tuyo!

[{"id":"365e1c699342165e","type":"tab","label":"Industrial Shields","disabled":false,"info":""},{"id":"b9dee3a556739916","type":"ui_clock","z":"365e1c699342165e","name":"","group":"7db45a2e2009a112","order":11,"width":8,"height":5,"x":650,"y":180,"wires":[]},{"id":"e0972d3fd6d6c9a4","type":"inject","z":"365e1c699342165e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":150,"y":180,"wires":[["b9dee3a556739916","b1430528ef3895d0"]]},{"id":"b1430528ef3895d0","type":"function","z":"365e1c699342165e","name":"","func":"var timestamp = msg.payload;\nlet time = new Date(timestamp).toLocaleTimeString();\n\nreturn {\n payload: time\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":220,"wires":[["9393aeb7e03490ca"]]},{"id":"9393aeb7e03490ca","type":"ui_text","z":"365e1c699342165e","group":"7db45a2e2009a112","order":3,"width":3,"height":1,"name":"Digital time","label":"","format":"{{msg.payload}}","layout":"row-left","className":"digital_time","x":670,"y":220,"wires":[]},{"id":"a013259e744decff","type":"ui_template","z":"365e1c699342165e","group":"7db45a2e2009a112","name":"","order":1,"width":1,"height":1,"format":"<style>\n .digital_time {\n    transform:scale(2);\n }\n .detail {\n    background-color: #d5f1f5!important;\n }\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":120,"y":100,"wires":[[]]},{"id":"4eb77cabb4f9444f","type":"openweathermap","z":"365e1c699342165e","name":"Sant Fruitos de Bages","wtype":"current","lon":"1.8927576326477862","lat":"41.75378886310762","city":"","country":"","language":"en","credentials":{},"x":420,"y":420,"wires":[["ab4acb74419ab405","8dd824dc58735374","4996ccbeb5e6b649","2b84cbfd3cc5504b","f2b63f8d53efc3c2","b6121c56a78e25fc","67873c3d7922c7e6","af92e1e759c9f31f","7e96f0e3c94beb2d","a23cb98025c36305","bb71bd10a3215a00"]]},{"id":"963951af63e630ec","type":"inject","z":"365e1c699342165e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":420,"wires":[["4eb77cabb4f9444f"]]},{"id":"ab4acb74419ab405","type":"ui_gauge","z":"365e1c699342165e","name":"humidity","group":"7db45a2e2009a112","order":48,"width":7,"height":3,"gtype":"donut","title":"Humidity","label":"%","format":"{{payload.humidity}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"humidity","x":980,"y":440,"wires":[]},{"id":"8dd824dc58735374","type":"ui_level","z":"365e1c699342165e","group":"7db45a2e2009a112","order":16,"width":3,"height":9,"name":"Temperature","label":"Temperature","colorHi":"#e60000","colorWarn":"#99ff00","colorNormal":"#55c1f7","colorOff":"#595959","min":"-20","max":"50","segWarn":"10","segHigh":"25","unit":"ºC","layout":"sv","channelA":"","channelB":"","decimals":"1","animations":"soft","shape":"1","colorschema":"fixed","textoptions":"default","colorText":"#eeeeee","fontLabel":"","fontValue":"","fontSmall":"","colorFromTheme":true,"textAnimations":false,"hideValue":false,"tickmode":"off","peakmode":false,"property":"payload.tempc","peaktime":3000,"x":990,"y":280,"wires":[]},{"id":"4996ccbeb5e6b649","type":"ui_text","z":"365e1c699342165e","group":"7db45a2e2009a112","order":26,"width":3,"height":2,"name":"Max temp","label":"Max Temp","format":"{{msg.payload.temp_maxc}}","layout":"col-center","className":"temp_maxc","x":980,"y":340,"wires":[]},{"id":"2b84cbfd3cc5504b","type":"ui_text","z":"365e1c699342165e","group":"7db45a2e2009a112","order":40,"width":3,"height":2,"name":"Min temp","label":"Min Temp","format":"{{msg.payload.temp_minc}}","layout":"col-center","className":"temp_minc","x":980,"y":380,"wires":[]},{"id":"37a8d713c66a4d12","type":"ui_media","z":"365e1c699342165e","group":"7db45a2e2009a112","name":"Sunset","width":2,"height":2,"order":44,"category":"sunset","file":"sunset.png","layout":"adjust","showcontrols":true,"loop":true,"onstart":false,"scope":"local","tooltip":"","x":980,"y":120,"wires":[[]]},{"id":"6be68b441503eb66","type":"ui_media","z":"365e1c699342165e","group":"7db45a2e2009a112","name":"Sunrise","width":2,"height":2,"order":42,"category":"sunrise","file":"sunrise.png","layout":"adjust","showcontrols":true,"loop":true,"onstart":false,"scope":"local","tooltip":"","x":980,"y":80,"wires":[[]]},{"id":"cc8236d93cd45261","type":"inject","z":"365e1c699342165e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":690,"y":40,"wires":[["6be68b441503eb66","37a8d713c66a4d12","7f81c1141dcd8ad4"]]},{"id":"8da6a24e984139d5","type":"ui_text","z":"365e1c699342165e","group":"7db45a2e2009a112","order":34,"width":2,"height":1,"name":"Sunrise","label":"","format":"{{msg.payload}}","layout":"row-spread","className":"","x":980,"y":600,"wires":[]},{"id":"854988610da3ecf4","type":"ui_text","z":"365e1c699342165e","group":"7db45a2e2009a112","order":36,"width":2,"height":1,"name":"Sunset","label":"","format":"{{msg.payload}}","layout":"row-spread","className":"","x":980,"y":640,"wires":[]},{"id":"f2b63f8d53efc3c2","type":"function","z":"365e1c699342165e","name":"","func":"var timestamp = new Date(msg.payload.sunset * 1000);\nlet sunset = timestamp.toLocaleTimeString();\n\nreturn {\n payload: sunset\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":640,"wires":[["854988610da3ecf4"]]},{"id":"b6121c56a78e25fc","type":"function","z":"365e1c699342165e","name":"","func":"var timestamp = new Date(msg.payload.sunrise * 1000);\nlet sunrise = timestamp.toLocaleTimeString();\n\nreturn {\n payload: sunrise\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":600,"wires":[["8da6a24e984139d5"]]},{"id":"67873c3d7922c7e6","type":"ui_gauge","z":"365e1c699342165e","name":"","group":"7db45a2e2009a112","order":5,"width":7,"height":3,"gtype":"gage","title":"Wind Speed","label":"m/s","format":"{{payload.windspeed}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":990,"y":500,"wires":[]},{"id":"af92e1e759c9f31f","type":"ui_gauge","z":"365e1c699342165e","name":"","group":"7db45a2e2009a112","order":20,"width":7,"height":4,"gtype":"compass","title":"Wind Direction","label":"","format":"{{payload.winddirection}}","min":0,"max":"360","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":1000,"y":540,"wires":[]},{"id":"7f81c1141dcd8ad4","type":"ui_media","z":"365e1c699342165e","group":"7db45a2e2009a112","name":"Clouds","width":2,"height":2,"order":46,"category":"clouds","file":"cloud.png","layout":"adjust","showcontrols":true,"loop":true,"onstart":false,"scope":"local","tooltip":"","x":980,"y":40,"wires":[[]]},{"id":"7e96f0e3c94beb2d","type":"ui_text","z":"365e1c699342165e","group":"7db45a2e2009a112","order":7,"width":6,"height":2,"name":"Detail","label":"The weather in Industrial Shields is:","format":"{{msg.payload.detail}}","layout":"col-center","className":"detail","x":970,"y":240,"wires":[]},{"id":"a23cb98025c36305","type":"ui_text","z":"365e1c699342165e","group":"7db45a2e2009a112","order":38,"width":2,"height":1,"name":"Clouds","label":"","format":"{{msg.payload.clouds}} %","layout":"col-center","className":"clouds","x":980,"y":200,"wires":[]},{"id":"bb71bd10a3215a00","type":"debug","z":"365e1c699342165e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":560,"wires":[]},{"id":"30f3e3454da83bbc","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":2,"width":4,"height":1},{"id":"c8041cae2af09b51","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":4,"width":2,"height":1},{"id":"999caae0cbedb848","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":6,"width":2,"height":1},{"id":"53b61fe30ff3fe07","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":8,"width":10,"height":1},{"id":"dc1e24cd4c7e81bd","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":9,"width":2,"height":1},{"id":"3761e382becbe8d3","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":10,"width":1,"height":1},{"id":"5e647f4dad03071e","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":12,"width":1,"height":1},{"id":"e9883e7c56b75fd0","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":13,"width":8,"height":1},{"id":"9b8a26405a90a80e","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":14,"width":1,"height":1},{"id":"2e8928f2e5aaa9b2","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":15,"width":10,"height":1},{"id":"769ebca867cf73fc","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":17,"width":3,"height":1},{"id":"7dada49fba1995e2","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":18,"width":1,"height":1},{"id":"850da32851e6a0e6","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":19,"width":1,"height":1},{"id":"98071772c5dba46f","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":21,"width":2,"height":1},{"id":"3c301e8aea9cf7b5","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":22,"width":3,"height":1},{"id":"a435ae784ce411d6","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":23,"width":1,"height":1},{"id":"d439e05bab4165a3","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":24,"width":1,"height":1},{"id":"067fbe3dcfa4cdb9","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":25,"width":2,"height":1},{"id":"403ed683658b35a2","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":27,"width":1,"height":1},{"id":"c54c72e77460d078","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":28,"width":1,"height":1},{"id":"3bcae4f3391fff56","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":29,"width":2,"height":1},{"id":"120690c0a8f7747f","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":30,"width":10,"height":1},{"id":"abc8e5975c54e41a","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":31,"width":2,"height":1},{"id":"0eb050516bd6680a","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":32,"width":3,"height":1},{"id":"86991dce8d0c65bf","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":33,"width":1,"height":1},{"id":"415e4ef1ba7f42c8","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":35,"width":1,"height":1},{"id":"bb95314a25dcfa90","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":37,"width":1,"height":1},{"id":"80e15bb9955d5f8c","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":39,"width":10,"height":1},{"id":"0b29779892d37d37","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":41,"width":1,"height":1},{"id":"9dcead4e3a34a64d","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":43,"width":1,"height":1},{"id":"3e44359de53d2935","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":45,"width":1,"height":1},{"id":"f48d791ced5169ef","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":47,"width":1,"height":1},{"id":"c77b19b02fd0095c","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":49,"width":2,"height":1},{"id":"c1ceaf64b7abbbac","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":50,"width":1,"height":1},{"id":"ba0110a4a78ae81f","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":51,"width":1,"height":1},{"id":"cc07fe5f80997e15","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":52,"width":1,"height":1},{"id":"bbd5de8c6088d6dc","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":53,"width":1,"height":1},{"id":"da9c6c91045b7228","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":54,"width":2,"height":1},{"id":"c2724abffe5b2da1","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":55,"width":3,"height":1},{"id":"f4a22a7e73e05034","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":56,"width":10,"height":1},{"id":"8f881cf38520304b","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":57,"width":2,"height":1},{"id":"7aea4797d33889eb","type":"ui_spacer","z":"365e1c699342165e","name":"spacer","group":"7db45a2e2009a112","order":58,"width":3,"height":1},{"id":"7db45a2e2009a112","type":"ui_group","name":"","tab":"eb94216d.968598","order":1,"disp":true,"width":25,"collapse":false,"className":"clock"},{"id":"eb94216d.968598","type":"ui_tab","name":"Industrial Shields","icon":"","order":5,"disabled":false,"hidden":false}]
Odoo • Image and Text

Buscar en nuestro blog

Tutorial de Node-RED: Construye tu propio cuadro de mandos meteorológico con Raspberry Pi PLC / Panel PC
Boot & Work Corp. S.L., Fernandez Queralt Martinez 19 de enero de 2022
Compartir

¿Estás buscando tu Controlador Lógico Programable ideal?

Echa un vistazo a esta comparativa de producto de varios controladores industriales basados en Arduino.

Comparamos entradas, salidas, comunicaciones y otras especificaciones con las de los equipos de otras marcas destacadas.


Industrial PLC comparison >>>