01 node-red basic

22
01 Node-RED Play some Flow

Upload: mrnukoon-phimsen

Post on 21-Jul-2015

160 views

Category:

Technology


1 download

TRANSCRIPT

01 Node-REDPlay some Flow

Node-RED• Node-RED is a visual tool for wiring the Internet of

Things (IoT).

• Traditional IoT development can be very technical, but Node-RED takes care of the technicalities and lets you concentrate on the logic of your workflow.

• While most programming in Node-RED is done visually using pre-defined functions (“nodes”), any additional functionality can be added in JavaScript

Open Node-REDhttp://pi-ip:1880

Nodes

Create a First FlowAdd inject and debug node

Create a First FlowWiring two node and click deploy

Create a First FlowClick on the Inject button

Create a First FlowPlace function between inject and debug and wiring

Create a First FlowCreate a function to convert timestamp to date format

Create a First FlowDeploy and press inject node again

Create a Twitter Flow

• Create inject, debug, httpRequest, function, and twitter nodes.

• Create tweet some informations about the live UK total electricity consumption

Create a Twitter Flow• Add a inject node and change its parameter, by

double click

Create a Twitter Flow• Change the repeat into “interval” and every 5 minutes

to allow inject automatically every 5 minutes

Automatic every 5 minutes

Create a Twitter Flow• Add httpRequest node (in part “function”) to request

to web site, then double click to change parameter

Create a Twitter Flow• Enter URL : http://www.nationalgrid.com/ngrealtime/realtime/systemdata.aspx

• To request UK electricity consumption

Request URL

Create a Twitter Flow• Add a function node with and change output to 2

output by double click to change parameter

Create a Twitter Flow• Create function to parse the http response output to extract power

demand, frequency and time msg to output 1 , frq50 to output 2

Produce 2 Output

Create a Twitter Flow• Wiring all nodes and click deploy

Create a Twitter Flow• Add a twitter node (part “social”) and double click to

edit property by double click (you need twitter account)

Set Account

Create a Twitter Flow• The twitter account added

The Account

Create a Twitter Flow• Modify function to send some data to twitter by create 3rd

variable and change output to 3, the 3rd output will tweet

The 3rd output to twitter

Create a Twitter Flow• Wire the 3rd of UK electricity to twitter then deploy

The tweet data