Using Node.RED to get weather data from Insights for Weather (Bluemix) service every 3 hours and save it in NoSQL db

This flow uses IBM Bluemix Insights for Weather service REST API to pull current weather information.

Starts with an inject node that sends a blank message every 3 hours to the HTTP (GET) node in order to invoke the Weather Company API.

The GET node is configured to call the REST API URL of the Bluemix Service : Insights for Weather (using the Free service). Note: Authentication parameters from Bluemix are used to configure the Basic Authentication fields in the HTTP node. For this demo, I have used International Falls, MN's geolocation code. Substitute your specific code in the URL where it reads &geocode=...&

The results of the HTTP node (HTTP page) are sent to a JSON converter node setting the stage for further processing.

From JSON converter node, one path extracts the metric section of Weather Company results coupled with the timestamp from Observations section, sent to Cloudant (NoSQL) for storing / historical analysis. Note: You may have to use your own database/credentials copied and pasted from your Bluemix application for this to work.

The second path from Converter node extracts just the temperature from the JSON msg and prints it to show individual attributes can be extracted and say attached to other data like IoT.

(The Insights for Weather service in Bluemix lets you integrate historical and real-time weather data from The Weather Company into your IBM Bluemix application. You can retrieve weather data for an area specified by a geolocation. The data allows you to forecast, detect, and visualize disruptive weather events that might affect decision making in your application. Details of the REST API and tutorials for using this service can be found at :

[{"id":"1431baaf.ebce45","type":"http request","z":"62b2e92c.9d4d18","name":"LocalWeatherSNS","method":"GET","ret":"txt","url":"","x":136,"y":455,"wires":[["d7d486f8.282b78"]]},{"id":"a5f4aca5.5a0b5","type":"debug","z":"62b2e92c.9d4d18","name":"","active":true,"console":"false","complete":"false","x":863,"y":329,"wires":[]},{"id":"1f886975.e07797","type":"inject","z":"62b2e92c.9d4d18","name":"Trigger a call to Weather Channel every hour","topic":"","payload":"","payloadType":"none","repeat":"10800","crontab":"","once":true,"x":230,"y":303,"wires":[["1431baaf.ebce45"]]},{"id":"d7d486f8.282b78","type":"json","z":"62b2e92c.9d4d18","name":"WeatherToJSON","x":368,"y":448,"wires":[["93ab2ea7.6c54d","6a4f7256.95b08c"]]},{"id":"c00ba9e6.3ff458","type":"cloudant out","z":"62b2e92c.9d4d18","service":"snsiot-cloudantNoSQLDB","cloudant":"","name":"SNSCloudantWeatherdb","database":"snsweatheringest","payonly":false,"operation":"insert","x":900,"y":374,"wires":[]},{"id":"93ab2ea7.6c54d","type":"function","z":"62b2e92c.9d4d18","name":"Get Temperature data from Weather api rest call","func":"var temp\nvar newMsg = {payload: msg.payload.observation.metric};\nnewMsg.payload.obs_time_local = msg.payload.observation.obs_time_local;\n\nreturn newMsg;","outputs":1,"noerr":0,"x":504,"y":379,"wires":[["a5f4aca5.5a0b5","c00ba9e6.3ff458"]]},{"id":"6a4f7256.95b08c","type":"function","z":"62b2e92c.9d4d18","name":"Todays temperature in celcius","func":"var anotherMsg = {payload: msg.payload.observation.metric.temp};\nreturn anotherMsg;","outputs":1,"noerr":0,"x":473,"y":552,"wires":[["67fb656e.98049c"]]},{"id":"70925f97.8f6da","type":"debug","z":"62b2e92c.9d4d18","name":"Weather channel temperature today","active":true,"console":"false","complete":"payload","x":824,"y":555,"wires":[]},{"id":"67fb656e.98049c","type":"template","z":"62b2e92c.9d4d18","name":"Weather Channel Temperature in Celcius","field":"payload","format":"text","template":"Temperature now from Weather Channel: {{payload}} degree Celcius!","x":710,"y":442,"wires":[["70925f97.8f6da"]]}]

Flow Info

created 2 years, 8 months ago

Node Types

  • debug (x2)
  • function (x2)
  • http request (x1)
  • inject (x1)
  • json (x1)
  • template (x1)
  • cloudant out (x1)


  • weatherchannel
  • bluemix
  • cloudant
  • weathercompany
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option