Building Arduino Projects for the Internet of Things

(Steven Felgate) #1

© Adeel Javed 2016 51
A. Javed, Building Arduino Projects for the Internet of Things,
DOI 10.1007/978-1-4842-1940-9_4


CHAPTER 4


Complex Flows: Node-RED


Now that you understand the basics of Arduino, including the different connectivity
options available and the communication protocols, you are going to use that knowledge
to prototype IoT applications.
This chapter starts with a hypothetical scenario. Imagine that you are responsible
for monitoring noise levels around an animal sanctuary. Whenever noise levels cross
a certain threshold, you are required to send an SMS to the supervisor and log noise
information in a database for future trends analysis. Let’s look at what will it take to
implement this IoT application:



  • Connect a sound sensor to Arduino

  • Write code that sends an HTTP request to a server whenever
    noise levels exceed a threshold

  • Create a service on a server that receives HTTP requests

  • Write a service to send an SMS to the supervisor

  • Write a service to store sensor data in a database


Looking at these tasks, you can see that a lot of code needs to be developed to
create this application. Most IoT applications require implementation of tasks such as
HTTP request/response, MQTT publish/subscribe, e-mails, SMS, tweets, and storing/
loading data. Engineers at IBM faced this same issue. Every time they had to create a
new prototype they were required to code the flow and tasks from scratch, even though
they were repetitive. So, they developed Node-RED, which is an excellent drag-and-drop
toolkit of reusable code that does these tasks and many more.
Node-RED is an event-processing engine that helps IoT developers avoid reinventing
the wheel. You still need to write code but the amount of code required is significantly
reduced. Figure  4-1 shows the Node-RED development environment.

Free download pdf