Getting started with Node-RED and IoT
Node-Red in its simplest form is an open source visual editor for wiring the internet of things produced by IBM. What does this mean? Well for someone lazy like me it means I can spend more time making stuff "talk" to each other than worrying about all of the interfacing code I will need to write.
The system contains "Nodes" which look simply to be icons that you drag and drop on to the canvas and wire together. Each Node offers different functionality which can range from a simple debug node to be able to see what's going on in your flow, through to a Raspberry Pi node which allows you to read and write to the GPIO pins of your Pi.
What Is Node-RED?
Node-RED as its name reflects was developed using Node.js framework to bring out a light-weight and browser oriented user interface. It comes with a highly inoperable design which allows it to link both physical and digital type of things together.
For using Node-RED one doesn’t need to be a seasoned programmer. Software engineers with less coding expertise can also contribute to the growth of this field. Most of the programming tasks in Node-RED, you can do visually using the pre-defined function nodes. You can perform drag and drop operation on these nodes and place them on canvas to create the desired workflow. Also, it supports new functionality with the help of JavaScript files.
Example of use ?!
To give an example of what can be done here is my home twitter account telling me about the weather today in Tunisia .
The flow to produce something like this within Node-Red is shown below and it took me
literally 15 minutes to have everything set up.
To summarize the flow:
1. Get the current weather state from open weather map
2. Extract the request and customize the return msg
3. The message is then sent to a Tweet node and tweeted for me.
4. Sent the message also to the Debug window to verify the functionality
So now I've sold you the idea.. lets get to the installation!
1. Get the current weather state from open weather map
2. Extract the request and customize the return msg
3. The message is then sent to a Tweet node and tweeted for me.
4. Sent the message also to the Debug window to verify the functionality
So now I've sold you the idea.. lets get to the installation!
Let’s Start The Node-RED Installation.
This installation is for Ubuntu Desktop 14.04,you can find the other guides in the internet if you are going to install it on RPI or Ubuntu 16.04
1- Setup Node.Js Before Node-RED Installation.
NodeJS
Run commands to install the latest version of Node.js.
Here is the command which will install and add node js support.
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
Then install the Node.js package.
sudo apt-get install -y nodejs
Verify the version
node -v
Verify the version
After setting up node js server, move to install the Node Package Manager i.e. , run the below command.
sudo apt-get install npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
Test the Node.js installation by executing the following commands:
2. Setting Up Node-RED
Installation
There are two approaches of installation- Using git and node-red installation
- Install from npm packages sources
To make it pretty easy we are going to install it through the npm
sudo npm install -g node-red
Run the server
$ node-red
You will see a lot of information print out on to the screen, errors about missing packages
and all of the good stuff. However the one line you are looking for is related to Node-Red
being available on the default 1880 port.
So next you need to navigate to your Pi’s IP address and port to see Node-Red in all of its glory.
So next you need to navigate to your Pi’s IP address and port to see Node-Red in all of its glory.
http://127.0.0.1:1880/
You should be welcomed to a blank canvas with all of the “nodes” available on the left hand
of the screen. You can drag and drop these to start wiring things together. We will next be
discussing how to create your first "flow" using these nodes.
Building your first App
After you have launched the server ,a new empty flow comes up
Click on the input section ,then drag, the inject node to the flow
Now click twice on the node inject ,customize your settings.
Change time stamp to string
Now go ahead ,to the output section ,then drag the debug node to the flow
Great ! now everything is almost ready ,what's we need now is to connect the nodes ! and that's set ! .Am definitely in love with this framework !
Good ! now let's deploy and see the results ! .Click on the deploy button
The results are shown on the debug side section . After deploy ,click on injectME node in the flow :D
Congratulations! that's was your first app with node-red
Why IOT(Internet of things ) ?!
IOT core idea is basically the interaction between objects ,and the interaction is built on the message exchange between nodes ,through ,a different protocols ,such as ,MQTT,HTTP,SSH ...... ,the implementation of one prototype takes you months of coding and hard working to integrate the different aspects of the objects and to make the system solid ,but ,with Node-Red the implementation would be very easy ,in fact it's funny too to work with the different layers ,protocols and per-build features .
How to add another Nodes ?!
Fir-stable check out the Node-Red flows ,it's huge collection of the flows ,include almost everything you need to build any idea .Let's try to install the Arduino Node .
Open up your terminal
Open up your terminal
$ cd ~/.node-red/
Now install the new package
sudo npm install node-red-node-arduino
New node
Resources
You can find anything in the official web site https://nodered.org/
for the node-red flows https://flows.nodered.org/
for the RPI node-red ,follow this guide :Adafruit guide
good tuto that have helped me : http://www.techbeamers.com/getting-started-with-node-red/
for the node-red flows https://flows.nodered.org/
for the RPI node-red ,follow this guide :Adafruit guide
good tuto that have helped me : http://www.techbeamers.com/getting-started-with-node-red/
What's next .....?!
Am working in new project called "Litsy" using the node red platform for the implementation .In the next post I will shared with you :D .
It's your turn NOW
It's your turn NOW