Skip to content

Instantly share code, notes, and snippets.

@karthhic
Created April 1, 2016 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karthhic/2adf4986be13dbbbba81f000b71d4d8b to your computer and use it in GitHub Desktop.
Save karthhic/2adf4986be13dbbbba81f000b71d4d8b to your computer and use it in GitHub Desktop.
Data Log Weather SQLite

This is a simple flow which will get the weather information whenever it changes and extract the temperature in Celsius, humidity, look, details about the look.

For this a Database file is created with name as weather

Database Structure:

weather [Filename] | |======temperature [tablename] | |==== date [col 1] |==== temperature [col 2] |==== humidity [col 3] |==== look [col 4] |==== detail [col 5]

the moment node is used for the date. and the date format is date month year without space.

any changes in the weather information will triggers a data injection.

since only 4 data was taken for storage its possible that same information can be stored twice because of the change of the hidden values.

An another version with Dashboard and retrieval will be added soon.

required nodes: [other than base nodes]

sqlite http://flows.nodered.org/node/node-red-node-sqlite moment http://flows.nodered.org/node/node-red-contrib-moment

[{"id":"9cb4c385.634b4","type":"sqlitedb","db":"/home/karthhic/weather"},{"id":"2c320d48.59ff02","type":"openweathermap in","name":"","lon":"","lat":"","city":"Tampere","country":"Finland","x":86.5,"y":388,"z":"7ed71e0a.377cd8","wires":[["da4a1d3f.077c8"]]},{"id":"537e7081.111108","type":"debug","name":"","active":true,"console":"false","complete":"topic","x":708,"y":388,"z":"7ed71e0a.377cd8","wires":[]},{"id":"6e7cc218.88ea54","type":"template","name":"","field":"topic","format":"handlebars","template":"INSERT INTO temperature (date,temperature,humidity,look,detail)\nVALUES ({{date}},{{payload.tempc}},{{payload.humidity}},\"{{payload.weather}}\",\"{{payload.detail}}\");","x":446,"y":389,"z":"7ed71e0a.377cd8","wires":[["88876ba0.6da6f8"]]},{"id":"da4a1d3f.077c8","type":"moment","name":"","topic":"","input":"payload","format":"DDMMYY","locale":"","output":"date","x":283,"y":387,"z":"7ed71e0a.377cd8","wires":[["6e7cc218.88ea54"]]},{"id":"88876ba0.6da6f8","type":"sqlite","mydb":"9cb4c385.634b4","name":"db","x":571,"y":388,"z":"7ed71e0a.377cd8","wires":[["537e7081.111108"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment