Node-RED Tutorial: Build your own Weather Dashboard using Raspberry Pi PLC / Panel PC
Create an ambient weather Node-RED Dashboard with your Raspberry Pi based PLC and Panel PC
19 January, 2022 by
Node-RED Tutorial: Build your own Weather Dashboard using Raspberry Pi PLC / Panel PC
Boot & Work Corp. S.L., Fernandez Queralt Martinez

Introduction

Would you like to build your own weather monitoring system with a Node-RED dashboard?

In this blog post, we are going to get the weather from OpenWeatherMap.org and display it with different widgets in a Node-RED dashboard!

Latest Posts

OpenWeather is a platform that defines itself as a "scientific yet simple approach to the weather forecast. Free. No ads.".

You can visit the official website >

In this blog post, we are going to use the openweathermap Node-RED node: node-red-node-openweathermap, which polls openweathermap.org for current weather data when an input is received.

Node-Red-Node-Openweathermap

To install it, you can either go to the Menu > Manage Palette > Install > Type: node-red-node-openweathermap and click on Install.

Node-Red-Node-Openweathermap

Or you can also go to the .node-red/ directory and install the nodes from there:

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

Once installed, you can already go to the nodes section, where you will find the openweathermap nodes 

In this case, we are going to use the openweather map, not the openweather map in.

Odoo • Text and Image

Drop it to the Node-RED flow and double-click to edit it. You will see that the first parameter is the API key. Go to the OpenWeather's website >>>, login, and generate a new API key.

Once is validated (it can take between 10 minutes and 2 hours after the successful registration), paste the API key in the node.

OpenWeather - Node-RED Tutorial

Finally, in the location, you can choose either "City, Country" or "Coordinates". Select the option that fits you better. Now:

  1. Add an inject node

  2. Connect it to the openweathermap node

  3. Add a debug node

And see all the information that you receive!

Node-red - Node-RED Tutorial

From there, link the msg.payload with the dashboard nodes, and display the widgets with the weather information as you like. For example:

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

Get the output from the openweathermap node and connect it to this gauge node. 

Odoo • Image and Text

Go to the Dashboard: 
http://<hostname>:1880/ui 
and see the humidity displayed!

Do the same with the rest of the parameters, and create an incredible Dashboard based on the data from OpenWeather!

Test

Now, copy this flows.json below, go to the Node-RED menu, click on Import > Paste this JSON, click on Done. And compare our Node-RED Dashboard with yours!

[{"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

Find what you are looking for
Search in our Blog

Node-RED Tutorial: Build your own Weather Dashboard using Raspberry Pi PLC / Panel PC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
19 January, 2022
Share this post
Archive

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>

Do you want more information?

Just fill the form!

Tell me more!