Working With Node Red (LAB-V)
Working With Node Red (LAB-V)
Aedes broker
Error with Mosca Broker
• Schema error
• https://stackoverflow.com/questions/64189045/node-js-mosca-broker-error-
expected-schema-to-be-an-object-or-boolean
• Solution
• Use aedes broker
• Install the above broker
Broker install
Publish Node (MQTT Out)
• To publish a Message to an MQTT broker use the
MQTT publish node in the workspace.
Aedes broker
Configuration of Nodes in Node
Red
Inject Node
Aedes Broker
Publisher
Subscriber
Automatically set
once the
publisher is
connected
MQTT Scenario (Practice-II)
Multiple Topics using Single
Publisher
Function 37,38 & 39
• msg.topic="a";
• return msg;
Function node (40)
if(msg.topic=="a")
msg.payload=msg.payload+ " Topic A";
if (msg.topic == "b")
msg.payload = msg.payload + " Topic B";
if (msg.topic == "c")
msg.payload = msg.payload + " Topic C";
return msg;
Practice-III
• Multiple Subscribers with single topic
• Multiple topics and multiple subscribers
Exercise to submit
• Multiple topics with single subscriber
• Addition of two numbers
• String Upper
• Finding number of words
References
1. Arshdeep Bahga, Vijay Madisetti, “Internet of Things A Hands-On
Approach”, (Chapter 1), 2015.
2. Greg Dunko, Joydeep Misra,Josh Robertson, Tom Snyder,”A
reference Guide to The Internet of Things”, 2017 Bridgera LLC,RIoT.
3. Link used :
1. http://www.steves-internet-guide.com/configuring-the-mqtt-publish-node/.
2. https://www.youtube.com/watch?v=C7v8TQLIsE8: local broker
CoAP
• It allows simple electronic devices to communicate over the Internet.
• It is designed for small devices with low-power sensors and actuators that
need to be controlled or supervised remotely, through standard Internet
networks.
• It is an efficient protocol that connects gateways with sensor nodes and
with servers or cloud platforms for Web integration and global access.
• HTTP is expensive, but CoAP is a simple, less expensive protocol that meets
all affordable needs with resource constraints.
• This protocol is designed for environments like low-end microcontrollers
and constrained networks with critical bandwidth and a high error rate
such as 6LowPANs.
• It is defined by the IETF.
• CoAP is based on the request-response communication model.
• CoAP resembles HTTP in terms of the REST model with GET, POST,
PUT and DELETE methods, URIs, response codes, MIME types, etc
Topics covered
• CoAP node installation
• Editing CoAP nodes
• Sample Example
• Practice Examples
node-red-contrib-coap
• Functionality
• "coap request" and "coap in" nodes
• Install
• cd $NODE_RED_HOME
• npm install node-red-contrib-coap
• or
• Manage palette
COAP Nodes
• COAP Request node
• COAP In node.
Practice -1
Server
Client COAP
Practice-I
COAP Server
On cl
icking
edit o
pti on
Function Node
COAP Request Node
Practice-II
Client 1
Server
COAP
Client 2
COAP
Client 2
Server 2