Practical Node-RED Programming

Book description

Use a low-code programming approach to create event-driven applications from scratch by wiring together hardware devices, APIs, and online services

Key Features

  • Discover how you can automate the Internet of Things (IoT) without writing huge blocks of code
  • Learn how to wire together flows using a browser-based visual editor
  • Handle IoT data with little to no coding knowledge

Book Description

Node-RED is a free and open source flow-based programming tool used to handle IoT data that allows programmers of any level to interconnect physical I/O, cloud-based systems, databases, and APIs to build web applications without code.

Practical Node-RED Programming is a comprehensive introduction for anyone looking to get up to speed with the Node-RED ecosystem in no time. Complete with hands-on tutorials, projects, and self-assessment questions, this easy-to-follow guide will help you to become well versed in the foundations of Node-RED. You'll learn how to use Node-RED to handle IoT data and build web applications without having to write complex code. Once you've covered the basics, you'll explore various visual programming techniques and find out how to make sample flows as you cover web development, IoT development, and cloud service connections, and finally build useful real-world applications.

By the end of this book, you'll have learned how to use Node-RED to develop a real-world application from scratch, which can then be implemented in your business.

What you will learn

  • Understand the history of Node-RED and why you need to learn a flow-based programming tool
  • Use Node-RED to build Node.js-based applications
  • Handle data for IoT devices using Node-RED flows
  • Explore advanced Node-RED features such as connecting repositories and customizing the flow editor
  • Find out what the MQTT protocol is and how it relates to Node-RED
  • Create and publish your own nodes and flows using the Node-RED library

Who this book is for

This Node-RED book is for web developers and IoT engineers with some background in JavaScript and Node.js. Although not necessary, familiarity with the concepts of electronics will help you to make the most out of this book.

Publisher resources

Download Example Code

Table of contents

  1. Practical Node-RED Programming
  2. Foreword
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Reviews
  7. Section 1: Node-RED Basics
  8. Chapter 1: Introducing Node-RED and Flow-Based Programming
    1. What is FBP?
      1. Workflows
      2. Flow-based programming (FBP)
    2. What is Node-RED?
      1. Overview
      2. Flow editor and runtime
      3. History and origin of Node-RED
    3. Node-RED benefits
      1. Simplification
      2. Efficiency
      3. Common
      4. High quality
      5. Open source
      6. Node-RED library
      7. Various platforms
    4. Node-RED and IoT
      1. Node-RED and IoT
    5. Summary
  9. Chapter 2: Setting Up the Development Environment
    1. Technical requirements
    2. Installing npm and Node.js for Windows
    3. Installing npm and Node.js for Mac
    4. Installing npm and Node.js for Raspberry Pi
    5. Installing Node-RED for Windows
    6. Installing Node-RED for Mac
    7. Installing Node-RED for Raspberry Pi
    8. Summary
  10. Chapter 3: Understanding Node-RED Characteristics by Creating Basic Flows
    1. Technical requirements
    2. Node-RED Flow Editor mechanisms
      1. Using the Flow Editor
    3. Making a flow for a data handling application
    4. Importing and exporting a flow definition
    5. Summary
  11. Chapter 4: Learning the Major Nodes
    1. Technical requirements
    2. What is a node?
    3. How to use nodes
      1. Common category
      2. Function category
    4. Getting several nodes from the library
    5. Summary
  12. Section 2: Mastering Node-RED
  13. Chapter 5: Implementing Node-RED Locally
    1. Technical requirements
    2. Running Node-RED on a local machine
    3. Using the standalone version of Node-RED
    4. Using IoT on edge devices
    5. Making a sample flow
      1. Use case 1 – light sensor
      2. Use case 2 – temperature/humidity sensor
      3. Making a flow for use case 1 – light sensor
      4. Making a flow for use case 2 – temperature/humidity sensor
    6. Summary
  14. Chapter 6: Implementing Node-RED in the Cloud
    1. Technical requirements
    2. Running Node-RED on the cloud
    3. What is the specific situation for using Node-RED in the cloud?
    4. IoT case study spot on the server side
      1. Use case 1 – Storing data
      2. Use case 2 – Temperature/humidity sensor
    5. Making a sample flow
      1. Making a flow for use case 1 – storing data
      2. Making a flow for use case 2 – visualizing data
    6. Summary
  15. Chapter 7: Calling a Web API from Node-RED
    1. Technical requirements
    2. Learning about the RESTful API
    3. Learning about the input/output parameters of a node
    4. How to call the web API on a node
      1. Creating an account
      2. Creating an API key
      3. Checking the API endpoint URL
      4. Checking that the API can run
      5. Creating the flow calling the API
    5. How to use the IBM Watson API
      1. Logging in to IBM Cloud
      2. Starting Node-RED on IBM Cloud
      3. Creating the Watson API
      4. Connecting Node-RED and the Tone Analyzer service
      5. Creating the flow by calling the Tone Analyzer API
      6. Testing the flow
    6. Summary
  16. Chapter 8: Using the Project Feature with Git
    1. Technical requirements
    2. Enabling the project feature
    3. Using the Git repository
      1. Accessing project settings
    4. Connecting a remote repository
    5. Summary
  17. Section 3: Practical Matters
  18. Chapter 9: Creating a ToDo Application with Node-RED
    1. Technical requirements
    2. Why you should use Node-RED for web applications
    3. Creating a database
    4. How to connect to the database
      1. Configuring Node-RED
      2. Cloning the Node-RED Project
      3. Configuring the Node-RED and CouchDB connection
    5. Running the application
    6. Summary
  19. Chapter 10: Handling Sensor Data on the Raspberry Pi
    1. Technical requirements
    2. Getting sensor data from the sensor module on the Raspberry Pi
      1. Preparing the devices
      2. Checking Node-RED to get data from the sensor device
    3. Learning the MQTT protocol and using an MQTT node
    4. Connecting to an MQTT broker
      1. Mosquitto
      2. Preparing Mosquitto on your Raspberry Pi
      3. Making a flow to get sensor data and send it to the MQTT broker
    5. Checking the status of data on the localhost
    6. Summary
  20. Chapter 11: Visualize Data by Creating a Server-Side Application in the IBM Cloud
    1. Technical requirements
    2. Preparing a public MQTT broker service
    3. Publishing the data from Node-RED on an edge device
    4. Subscribing and visualizing data on the cloud-side Node-RED
      1. Preparing Node-RED on the IBM Cloud
      2. Visualization of the data on the IBM Cloud
    5. Summary
  21. Chapter 12: Developing a Chatbot Application Using Slack and IBM Watson
    1. Technical requirements
    2. Creating a Slack workspace
    3. Creating a Watson Assistant API
    4. Enabling the connection to Slack from Node-RED
    5. Building a chatbot application
    6. Summary
  22. Chapter 13: Creating and Publishing Your Own Node on the Node-RED Library
    1. Technical requirements
    2. Creating your own node
      1. Node program development
      2. Node packaging
    3. Testing your own node in a local environment
      1. Node installation
      2. Node customization
    4. Publishing your own node as a module in the Node-RED Library
      1. Publishing the node you created
      2. Deleting the node you published
      3. Installing the node you published
    5. Summary
  23. Appendix: Node-RED User Community
    1. Node-RED Community Slack
    2. Node-RED Forum
    3. Japan User Group
    4. Why subscribe?
  24. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Leave a review - let other readers know what you think

Product information

  • Title: Practical Node-RED Programming
  • Author(s): Taiji Hagino, Nick O'Leary
  • Release date: March 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781800201590