Outdoor Temperature Data from Weather Underground to Emoncms & MQTT
One way is to monitor external temperature is to install your own external emonTH wireless temperature node or use a commercial web-connected weather station. However a cheaper way is to tap into the Internet of Things and connect to another weather station in your area. Weather Underground have over 18K weather stations online in the USA and a free API for non commercial use.
Here's an example of using nodeRED to poll the Weather Underground API and post to Emoncms (using nodeRED Emoncms flow) and MQTT. See bottom of the post for nodeRED flow export which you can import into your nodeRED by pasting into the import box.
NodRED included pre-installed on the latest emonPi image (currently in release-candidate). The Emoncms flow is pre-installed, you will need to add the nodeRED Weather Underground flow by connecting via SSH and running :
$ rpi-rw
$ cd ~/data/node-red
$ sudo npm install node-red-node-weather-underground
$ rpi-rw
$ exit
Once installed you will need to paste in your API key and latitude and longitude (or city) into the Weather Underground node.
Example NodeRED flow pulling temperature data from Weather Underground to Emoncms and MQTT |
Emoncms Internal & External Temperature Multigraph |
My openHAB dashboard displaying outdoor temperature and emonPi data from MQTT |
Example nodeRED flow:
[{"id":"14e3d598.a7352a","type":"emoncms-server","z":"4cd40f47.6c38f","server":"http://192.168.0.35/emoncms","name":"emonpi"},{"id":"286b0130.d794fe","type":"mqtt-broker","z":"","broker":"192.168.0.35","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"8e40f136.25c8c","type":"inject","z":"4cd40f47.6c38f","name":"Poke every 30min","topic":"","payload":"","payloadType":"str","repeat":"1800","crontab":"","once":true,"x":293.33331298828125,"y":616.3333740234375,"wires":[["801e0088.7a2eb"]]},{"id":"1d8fc53b.c7453b","type":"mqtt out","z":"4cd40f47.6c38f","name":"MQTT: weather/temp","topic":"weather/temp","qos":"","retain":"","broker":"286b0130.d794fe","x":840,"y":479,"wires":[]},{"id":"9dfe39d9.afac48","type":"debug","z":"4cd40f47.6c38f","name":"","active":true,"console":"false","complete":"payload","x":772,"y":395,"wires":[]},{"id":"c647a520.c30618","type":"debug","z":"4cd40f47.6c38f","name":"View full output","active":true,"console":"false","complete":"payload","x":581.3333129882812,"y":589.3333740234375,"wires":[]},{"id":"17551590.ce038a","type":"function","z":"4cd40f47.6c38f","name":"Return temp deg C","func":"context.global.outdoor_temp = msg.payload.tempc; \nreturn {payload:context.global.outdoor_temp};","outputs":1,"noerr":0,"x":533.3333129882812,"y":454.3333435058594,"wires":[["1d8fc53b.c7453b","9dfe39d9.afac48","50f404a6.f89bac"]]},{"id":"801e0088.7a2eb","type":"wunderground","z":"4cd40f47.6c38f","name":"","lon":"-4.1716485","lat":"53.1429426","city":"","country":"","x":321,"y":529,"wires":[["17551590.ce038a","c647a520.c30618"]]},{"id":"50f404a6.f89bac","type":"emoncms","z":"4cd40f47.6c38f","name":"Emoncms","emonServer":"14e3d598.a7352a","nodegroup":"weather","x":800,"y":539,"wires":[]}]
To engage in discussion regarding this post, please post on our Community Forum.