element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Industrial Automation
  • Technologies
  • More
Industrial Automation
Blog Connect to AVNET iotconnect.io with Node-RED - part 7: messages and commands from the cloud
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Industrial Automation to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 31 Mar 2021 7:51 PM Date Created
  • Views 684 views
  • Likes 2 likes
  • Comments 0 comments
Related
Recommended

Connect to AVNET iotconnect.io with Node-RED - part 7: messages and commands from the cloud

Jan Cumps
Jan Cumps
31 Mar 2021

AVNET's iotconnect.io cloud platform is an online service that you can use to send data to, and then show it on a dashboard*. In this blog series I'm learning how to talk to it with Node-RED.

In this post: Messages and commands from the cloud to the Thing.

image

This is the last post in the series.

 

iotconnect.io supports 3 types of messages:

  • simple one-way communication from the cloud
  • communication with acknowledgement back from the Thing
  • firmware updates over the cloud

 

I'm experimenting with the first two.

 

Set up the commands

 

You can only use commands that are defined in the template for the thing. That's good.

I'll set up two simple commands, that send a "desired temperature" to the Thing.

It's up to the thing to decide what to do with it.

My thing logs the info to a debug window image. The easiest way to learn and share on a blog post.

In the real word, this could be a command for a temperature control thing

 

Here you can see the two commands. Both request to the thing to "set the desired temperature. One with, the other without confirmation.

.image

 

This is the one without receipt:

It will send and forget.

The Node-RED flow is also simple. Just take the payload out of the IoTConnect connection node.

 

image

 

And this the one with acknowledgement:

This one behaves differently. The Node-RED flow will have to send an acknowledgement back for a full success.

You can monitor missing acknowledgements on IoTConnect the cloud pages.

I have not found an option yet where you can act on missing ACKs.

image

 

Node-RED flow that can deal with both types

 

The data coming out of the Node-RED IoTConnect node, when receiving a command, has an attribute that tells if an ACK is needed.

msg.payload.ack [true|false]

 

For a complex flow, where you need functional checks before confirming, you'd make a dedicated flow to validate, then ACK.

In my case, I just want to confirm that the message (any message) has been received. So I created a generic flow:

 

image

 

This flow always sends the received data out, as payload.

It also checks the data for the msg.payload.ack attribute.

image

 

If false, nothing happens.

If true, the ACK is generated and injected (with the IoTConnect injector) in that same IoTConnect node.

image

 

 

Since the version the Node-RED SDK of May 21, 2021, you need to set 2 attributes in the payload before injecting the ACK:

 

image

image

source: IoTConnect Client Libraries & SDKs (requires an account)

 

That's then the input to the ACK injector:

 

image

 

 

 

Actual Examples

 

The first one sends a command that does not request an ACK.

The desired temperature is given as 30.

 

image

The command is received at the Thing. The Node-RED flow dumps the payload to the debug window, and does not call the ACK flow.

image

The cloud portal shows success when the message was sent. It does not know if it arrived.

image

 

The second test sends a command that requests an ACK.

The desired temperature is given as 25.

image

The command is received at the Thing. The Node-RED flow dumps the payload to the debug window.

Because the msg.payload.ack == true , it sends and acknowledgement.

image

image

 

In this case, the flow only reports good if the ACK arrived:

image

 

The third test deliberately does not send an ACK, to show that this works.

I broke the flow for this. I removed the ACK block. Just to show that you can see in the cloud portal if a message was not correctly handled at the Thing side.

image

You can see that the portal only knows that the message departed. It will not show success.

That's the point of the ACKs. Getting feedback.

 

Should you use ACKs all the time?

 

No. An application that relies on unconfirmed messages (and unreliable connections) is - in the long run - more stable than one that needs an acknowledgement.

It's a skill to design processes that can deal with uncertainty, bad connections, no replies.

But if you deal with it, your software will be much more resilient to real life. And for a thing that's out there, not in a server room with reliable redundant connectivity, real life will matter.

 

Try to design flows that can deal with failed messages from both sides. Accept that that will be the reality once you have 11.000 of them out there in the wild. Don't expect return values. Don't expect that a message (either way) went fine.

It will make your design stronger.

 

That said: the ACK mechanism will help you:

You can use it in non-real-time (ASYNC). It can be a mechanism to show that a flow failed over a long time. That's useful.

 

In several of the other posts in this series, you will see that I use different ACK  design.

Always refer back to this blog post for the correct ACK setup.

 

 

The Python SDK with On Semiconductor RSL10 BLE article seriesIndustry
part 1: overview and goal
part 2: WiFi Provisioning
part 3: Adding a Module (RSL10)
part 4: Talk BLE to the On Semi RSL10 Sensor Kit
part 5: A Cloud User Experience Example
part 6: Register as a Gateway Device
part 7: Register a Gateway and Client Devices
The NODE-Red SDK article seriesIndustry
part 1: overview and goal
register a Thing and connect to IoTConnect.io cloud
part 2: create an account and log on to the portal
part 3: set up the thing and its interface in the cloud
part 4: set up Node-RED and first exchange
interact with IoTConnect.io cloud
part 5: online dashboard
part 6: rules and alerts
part 7: messages and commands from the cloud
safer connections with certificates
part 8a: safer connect with Self Signed Certificates
part 8b: safer connect with CA certificatesY
commercial and industrial scale: outsource certificate generation and programming to subcontractors and suppliers
part 9a: Outsource Certificate Signing in IIoT Supply ChainY
part 9b: IIoT supply chain and Certificates - Create Ca Root certificate, Load to IoTConnect Cloud and ValidateY
part 9c: IIoT supply chain and Certificates - Create an Intermediate CA Certificate for your SubcontractorY
part 9d: IIoT supply chain and Certificates - Subcontractor Generates a Thing Certificate for Your DeviceY
part 9e: IIoT supply chain and Certificates - Test!Y
commercial and industrial scale: Trusted Platform Module (TPM) Authentication
part 10: Trusted Platform Module (TPM) SecurityY
Infineon SLx9670 Trusted Platform Module (TPM) for IoT SecurityY
The Automate Device Provisioning and Cloud Configuration article seriesIndustry
Automatic Provisioning with REST APIY
  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube