Connecting Wired Phidgets with Edge MC and Node-RED
  • 30 Sep 2022
  • 3 Minutes to read
  • Contributors

Connecting Wired Phidgets with Edge MC and Node-RED


Article Summary

Connecting Wired Phidgets with Edge MC and Node-RED

Learn how to connect wired Phidgets to Tulip with an Edge MC and Node-RED

Summary

This article covers the workflow to connect wired Phidgets to an Edge MC and send data to Tulip via a Node-RED flow.

By the end of this article, you will have the following flow within Node-RED to send Phidget data from your sensor to a Machine within Tulip.

You will complete the following steps:

  1. Connecting the Phidgets to an Edge MC
  2. Setting up machine attributes in Tulip
  3. Node-RED flow setup

What you will need is:

Note: Purchasing a Tulip Factory Kit will include all relevant Phidget items.

1. Hardware Setup - Connecting your Phidgets to an Edge MC

  1. Connect the Humidity Phidget to the 0 port on the VINT Hub Phidget using the Phidget cable.
  2. Connect the VINT Hub Phidget to one of the USB ports on your Edge MC with a USB to Mini-USB cable.

2. Machine Setup - Creating Machine Attributes

To send data from the Phidget sensor to Tulip, let's first set up a Machine using the Tulip API as its data source. Refer to the Setting up a New Machine section of the How to use the Machine Attributes API article for an in-depth overview.

We'll need to create two machine attributes for this machine:

  1. A machine attribute for Humidity and type set to Float
  2. A machine attribute for Temperature and type set to Float

You'll want to note the attributeId and machineId values to pass into the Node-RED flow.

You can also set up a Machine Type to assign to the Machine if you plan to use the Phidget sensor(s) to change aspects such as the state of the machine or perform any counts based on the sensor outputs. Refer to How to Set Up Machine Types if this is of interest.

3. Node-RED Setup - Building Node-RED Flow

Open the Edge Device Portal on the Edge MC connected to the Phidget sensor(s). Launch the Node-RED Editor using the following credentials:

  • Username: admin
  • Password: Your Edge IO password

See more information here to get started with Node-RED on Edge MC.

In the Node-RED Palette Editor:

  1. Install the Phidgets set of nodes from the Library.

Reference this Node-RED article, under "Using the Editor"

  1. Add a Connect node, located under the Phidgets nodes.

  2. Add a HumiditySensor and a TemperatureSensor node, also located under Phidgets nodes.

  3. Add a machine-attr node, located under the Tulip nodes.

  4. Double click on the two Phidgets Sensor nodes. Configure as follows:

    • Name: Give it a name associated with the corresponding sensor, for example Phidget-Humidity.
    • Device Info: Copy and paste the Device Info corresponding to the Humidity Machine Attribute from your machine in Tulip.
    • Attribute Source: Change to msg.payload.humidity .
  5. Add a second machine-attr node.

  6. Similar to step 4, configure the second machine-attr node.

    • Name: Give it a name associated with the temperature sensor, for example Phidget-Temperature.
    • Device Info: Copy and paste the Device Info corresponding to the Temperature Machine Attribute from your machine in Tulip.
    • Attribute Source: Change to msg.payload.temperature .

  7. Add a debug node, located under common nodes.

  8. Connect the nodes as follows. Note that each data stream has its own Tulip node:

  1. Click Deploy in the top right of your screen to deploy the flow to your Edge MC.

To see your Phidgets in action, navigate back to your Machine in Tulip. You should see a live display of the humidity and temperature data your Phidget is reading:

Here is Node-RED's documentation for further reading.

Have a powerful Node-RED use case? Share your development on Tulip Community!

Here is the JSON for this Node-RED flow - import it into Node-RED for use on your device.

Note: %your info here% should be replaced with each of the machine attributes from your factory instance.

[{"id":"c8373720.e62f4","type":"tab","label":"Phidget Flow","disabled":false,"info":""},{"id":"9ca3e9dc.929e38","type":"phidget22-connect","z":"c8373720.e62f4","port":"5661","hostname":"0.0.0.0","debug":true,"x":90,"y":240,"wires":[["72614446.57e55c","f247f156.11f5a"]]},{"id":"72614446.57e55c","type":"phidget22-humiditysensor","z":"c8373720.e62f4","channel":0,"deviceSerialNumber":-1,"debug":true,"dataInterval":"5000","hubPort":0,"humidityChangeTrigger":0,"x":310,"y":160,"wires":[["46cb0ce3.25c094","a241d898.d84ed8"]]},{"id":"a241d898.d84ed8","type":"debug","z":"c8373720.e62f4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":240,"wires":[]},{"id":"f247f156.11f5a","type":"phidget22-temperaturesensor","z":"c8373720.e62f4","channel":0,"deviceSerialNumber":-1,"hubPort":0,"debug":true,"dataInterval":"5000","temperatureChangeTrigger":0,"RTDWireSetup":3,"RTDType":2,"thermocoupleType":2,"x":320,"y":320,"wires":[["42a73f38.a98fa","a241d898.d84ed8"]]},{"id":"46cb0ce3.25c094","type":"tulip-machine-attribute","z":"c8373720.e62f4","name":"Phidget-Humidity","useCustomApiAuth":false,"apiAuth":"","keepAlive":true,"keepAliveMsecs":10000,"deviceInfo":"{%your info here%}","payloadSource":"payload.humidity","payloadType":"msg","x":590,"y":160,"wires":[[]]},{"id":"42a73f38.a98fa","type":"tulip-machine-attribute","z":"c8373720.e62f4","name":"Phidget-Temperature","useCustomApiAuth":false,"apiAuth":"","keepAlive":true,"keepAliveMsecs":10000,"deviceInfo":"{%your info here%}","payloadSource":"payload.temperature","payloadType":"msg","x":600,"y":320,"wires":[[]]}]

Was this article helpful?