0

members

Easy Raspberry basics: Project 04a Raspberry PI 3 Model B board with Node-RED

of Lex C. in Raspberry Pi 3

Raspberry basics: Project 04a

Project name: Raspberry PI 3 Model B board with Node-RED

Tags: Raspberry, Raspberry PI 3 model B board, Red node, Node-RED

In this project, you need these parts :

1.Raspberry PI 3 model B 1 pc

2. Micro SD card with NOOBS and SD card adapter 1 pc

3. Micro USB power supply (2.1 A, max 2.5 A) 1 pc

4. USB keyboard 1 pc

5. USB mouse 1 pc

6. TV or PC monitor 1 pc

General

We will learn about Node-RED, how to install it, how to use the visual interface to create a simple flow.

Understanding the Raspberry PI 3 model B

The Raspberry Pi 3 is the third-generation Raspberry Pi. It replaced the Raspberry Pi 2 Model B in February 2016.

Specification:

  • Quad Core 1.2GHz Broadcom BCM2837 64bit CPU
  • 1GB RAM
  • BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board
  • 40-pin extended GPIO
  • 4 USB 2 ports
  • 4 Pole stereo output and composite video port
  • Full size HDMI
  • CSI camera port for connecting a Raspberry Pi camera
  • DSI display port for connecting a Raspberry Pi touchscreen display
  • Micro SD port for loading your operating system and storing data
  • Upgraded switched Micro USB power source up to 2.5A

Understanding the Node-RED

Node-RED is a powerful open source tool for building Internet of Things (IoT) applications with the goal of simplifying the programming component. It's developed by IBM. The Raspberry Pi runs Node-RED perfectly. With Node-RED you can spend more time making cool stuff, rather than spending countless hours writing code.

Programs in Node-RED are called flows. You can see that your blank page is labelled as Flow 1 in the tab at the top. You can create as many flows as you want and they can all run at the same time. 

Node-RED makes it easy to:

  • Access your RPi GPIOs;
  • Establish an MQTT connection with other boards (Arduino, ESP8266, etc);
  • Create a responsive graphical user interface for your projects;
  • Communicate with third-party services (IFTTT.com, Adafruit.io, Thing Speak, etc);
  • Retrieve data from the web (weather forecast, stock prices, emails. etc);
  • Create time triggered events;
  • Store and retrieve data from a database.

You can find the Node-RED Library here.

The coloured blocks on the left side of the interface are the nodes. Scroll right down to the bottom of the list and you will see some nodes labelled Raspberry Pi.

It uses a visual programming that allows you to connect code nodes together to perform a task. The nodes when wired together make flows.

Signals and connections of the Raspberry PI 3 model B


Step by Step instruction

1.Installing Node-RED and making autostart

  1. We will use the PC with MS Windows 10 OS and Raspberry PI 3 board with Rasbian OS installed.
  2. Connect the TV or PC monitor Display port (HDMI Port) to your Raspberry PI 3 board HDMI Port (HDMI cable required).
  3. Make sure that your monitor or TV is turned on, and that you have selected the right input (e.g. HDMI 1,  etc).
  4. Plug in your USB mouse and USB keyboard to Raspberry PI 3 board USB ports.
  5. Connect Micro USB power supply to Raspberry PI 3 board micro USB input.
  6. The Raspberry PI desktop will start up.
  7. Go to Terminal.
  8. In the Terminal window, type the following command: sudo raspi-config
  9. You should see the Raspberry Pi software configuration tool. Select the Interfacing Options.
  10. Select P2 SSH and Yes to enable it and Finish.Reboot your Raspberry Pi 3.
  11. Go to Terminal.
  12. In the Terminal window, type this command to install Node-RED: bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
  13. In order to get Node-RED run automatically after Raspberry Pi 3 boots up use this command: sudo systemctl enable nodered.service
  14. Restart your Pi so the autostart takes effect - use this command: sudo reboot

2. If Node-RED preinstalled

  1. When the Raspberry PI desktop start up. Click on the Raspberry icon, then the Programming menu to open Node-RED.
  2. You should see a window displaying information about Node-RED starting up.
  3. You need to know your Raspberry Pi 3 IP address. Go to Terminal and use this command: ifconfig
  4. You will see some information together with Raspberry Pi 3 IP address. In our case it is 192.168.0.124.
  5. Go to Web browser.
  6. Locate the address bar at the top and type in localhost:1880, then press Enter button. This will display the Node-RED interface. (Your Raspberry Pi does not need to be connected to the internet to use Node-RED: localhost is the address the Raspberry Pi uses to refer to itself and :1880 means that it is looking at port 1880.) or type http://your_Raspberry_Pi_IP_address:1880 (in our case that is http://192.168.0.124:1880
  7. You will see similar page.
  8. On the left-side, you can see a list with a bunch of blocks. These blocks are nodes and they are separated by their functionality. If you select a node, you can see how it works in the info tab.
  9. In the center, you have the Flow and this is where you place the nodes.

3. How to create a simple flow

  1. Drag an Inject node to your flow. 
  2. Drag a Debug node to your flow.
  3. Connect your nodes together. You can drag them to confirm that they are connected.
  4. Edit the inject node. Double-click on the node. It has different settings which you can change.
  5. Select string and type Hello World. Press OK button.
  6. To save your application, you need to click the Deploy button on the top right corner.Your application is saved.
  7. Let’s test our flow. Open the Debug and click the Inject node to trigger the “Hello World” string.
  8. Our message has printed in the Debug window. It is a basic example. 

Summary

We have learnt about Node-RED, how to install it, how to use the visual interface to create a simple flow.

Library

  • No libraries needed in this project

Sketch

  • No sketches needed in this project


Other projects of Lex C.

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 16-05-2018
Viewed: 761 times