ICP 4 - Gnkhakimova/CS5590-IoT GitHub Wiki
ICP 4
Introduction
Node Red is UI tool which is used to write Internet of Things applications. It is very easy to use and user friendly since developer need to concentrate on logical flow instead of technical part of application. Node - Red has "Nodes" which represents different functions, if user wants to add more complex logic it can be extended using JavaScript. A lot of major companies also prefer to use Node-Red which does not require to write code.
Objectives
Purpose if this in class project was to create a flow using Node-Red to read data from OpenWeatherMap API and display weather condition on twitter. Which would help to introduce Node-Red tool and different functionalities which can be used in Node-Red.
Approach/Method
In order to complete in class project I started from simple small projects, like displaying string on debug console in order to understand how Node-Red tool works. I found examples on how to display payload in dashboard and worked on implementation of that small project first which helped me to complete in class project.
Steps
- First we need to install Node.js - I already had it installed on my machine so I skipped this step.
- In order to use Node-Red tool we need to install it using cmd line. It took couple seconds to install.
- Type Node-Red in order to run UI tool and then open: http://127.0.0.1:1880/ in browser - which will launch Node Red tool where we can create our flow.
- First added Inject input node which will trigger our flow.
- Installed OnpenWeatherMap node by running:
npm install openweathermap-apis
. - Added OpenWeatherMap node to my flow and connected it to Inject.
- Created account in OpenWeatherMap and received API keys.
- Configured OpenWeatherMap node by adding API keys.
- Added dashboard - text nodes to display weather condition in UI. Added weather, humidity, temperature and location values. Open http://127.0.0.1:1880/UI in order to see dashboard UI.
- Added Function node which will receive response from OpenWeatherMap and get description field and assign it to
msg.payload
. - Added Twitter Node to the flow so I could post tweets in my Twitter account.
- Created application in Twitter developer account and received all keys.
- Configured Twitter Node by adding all needed keys.
- Deployed flow and triggered it by clicking on Inject.
- Displaying output on debug console, UI Dashboard and posting tweet on my Twitter account.
Flow Diagram
Outputs
Debug console - displaying data which was received from OpenWeatherMap on Json format.
Dashboard UI - displaying temperature, humidity, weather and location from API call into Dashboard UI under Weather group.
Twitter - displaying tweet regarding weather condition in current location which was taken from API call to OpenWeatherMap.
Workflow
Node red is running
Open Weather Map Node
Payload Node - debug
Temperature Dashboard text field
Humidity Dashboard text field
Weather Dashboard Text field
Location Dashboard Text field
Function Node to get weather description
Twitter Node
Parameters
In order to complete in class project, I had to install Node.js, Node-Red, OpenWeatherMap Node, create account in OpenWeatherMap and obtain keys, create account in Twitter Developer and create application to get access tokens and keys.
Evaluation/Discussion
I had to go over lecture in order to understand how Node Red works, since I did not have any previous experience in using Node-Red. Also searched for little example how different functions can be implemented using Node Red tool, watched few videos regarding posting a tweet on Twitter account. Lectures helped me to understand basic operations and how to design a flow in order to complete a task. Did not have a change to discuss it in class. Had to complete work individually.
Conclusion
It was very interesting to create application using Node-Red tool which was very easy to understand and follow, ad to read little bit more about functionality of different Nodes. Successfully completer in class project by getting data from OpenWeatherMap and displaying it in three different places - Debug Console, Dashboard UI and Twitter. In future thinking to add more functionalities, such as sending email with weather update or integrate with other social networks.