Sending Data from Node-RED to Tulip with Tulip Nodes
  • 15 Feb 2024
  • 3 Minutes to read
  • Contributors

Sending Data from Node-RED to Tulip with Tulip Nodes


Article summary

Overview

Three main methods exist to send data from Node-RED (such as device or external-system data) to Tulip:

  1. via the Tulip Machine API
  2. via the Tulip Tables API
  3. via a Connector Response
    *Note: Requires a Connector first, originating from Tulip.

To streamline communications over methods 1 and 2, Tulip has created three first-party Nodes:

  1. tulip-tag: Send data to Machine Attributes API with advanced functionality - Tulip Edge Device Only
  2. machine-attribute: Send data to Machine Attributes API from any device
  3. tables: Send & receive data to/from the Tables API from any device

All three nodes listed above are pre-installed on Tulip Edge Devices. Additionally, Nodes 2 and 3 above are published to the Node-RED Library for download to any device. They can be found here.


Sending Data to a Tulip Machine Attribute

Note: This section assumes a Tulip Machine Attribute has been created. For more information, refer to this guide.

From a Tulip Edge Device: the tulip-tag Node

The tulip-tag Node is compatible with Tulip Edge Devices running software version 51 or higher.

  1. To use the tulip-tag Node, first drag it onto the editor pane from the Palette. Double-click the node to open its configuration pane.
  2. Click the pencil to add a new Tag List:
Warning! Tag Lists

Only one active Tag List is supported per Edge Device. Be sure to disable any Flows running other Tag Lists before beginning.

<put in the photo from the existing article here>

  1. Click +add to add a new Tag. Each tag has three parts: an ID, label, and type.
  • Tag ID: a unique code-like identifier for the tag. Once created, it should not change. Valid characters are letters, digits (cannot start with a digit), and underscores. Examples: part_count, myState1.
  • Tag Label: the human-readable label for the tag. To rename the tag, simply update the label - not the ID. Example: "Part Count".
  • Type: The data type - String, Integer, Float, or Boolean. Must match the type of the mapped Machine Attribute.

A sample Tag List configuration can be found below:

image.png

  1. Once all tags are added, click Add to save all changes.
    Note that all tags will show Unmapped - this is to be expected, as the tags do not yet have an associated Tulip Machine Attribute.

  2. Once the Tag List is created, there are two methods to associate Flow contents with List entries. Both depend on the Tag Config checkbox in the tulip-tag node:

  • If Tag Config is checked (true), one Tag Node is needed for each Machine Attribute. Connect the Node to the tulip-tag node, and select the relevant Machine Attribute with the Tag Node's Select Tag drop-down. Note that the Tag Node will take whatever is found in msg.payload as the intended input.
    For example, the flow below uses two inject nodes to input either hello or world. Each has its own tulip-tag node, with the Select Tag field mapped appropriately:
    image.png

  • If Tag Config is unchecked (false), one Tag Node is needed for all Machine Attributes. The node will take a full Object of all Tag values and map them automatically to their respective Machine Attribute. Note that the input Object must match the Tag List exactly, or the Node will throw an error.
    For example, the flow below uses one inject Node. The Node passes the Object shown to the Tag Node, which then maps helloworld1 to the Tag List itemhello, and helloworld2 to the Tag List item world:
    image.png

Data is now being sent successfully to Tulip. Tags can be found as Machine Data Sources - to associate with a Machine Attribute, find each one under the Edge Device as a Machine Data Source.
The image below shows three Tags present on an Edge Device:
How to Send Data to Machines from Edge Devices using Node-RED and Tulip Tags_566767591.png


From any device with Node-RED: the machine-attr Node

  1. To use the machine-attr Node, first navigate to the Machine Attribute in Tulip.

  2. Click to open possible Data Sources, and select "Tulip API". Copy the information shown:
    image.png

  3. In Node-RED, add a Tulip machine-attr node. If not previously configured, configure a new Tulip Authentication (link needed - copy from here: https://support.tulip.co/docs/using-node-red-with-the-tulip-api).

  4. Paste the Machine Attribute data from Tulip in the Device Info field.

The Machine Attribute Node is now configured. Any data (of the same type as the Machine Attribute) present in msg.payload once input to the Node will appear at the Machine Attribute in Tulip.


Was this article helpful?