--- title: "Connecting Wired Phidgets with Edge MC and Node-RED" slug: "connecting-wired-phidgets-with-edge-mc-and-node-red" updated: 2023-11-04T14:54:10Z published: 2023-11-04T14:54:10Z canonical: "support.tulip.co/connecting-wired-phidgets-with-edge-mc-and-node-red" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.tulip.co/llms.txt > Use this file to discover all available pages before exploring further. # 用 Edge MC 和 Node-RED 连接有线 Phidgets ## 用 Edge MC 和 Node-RED 连接有线 Phidgets *了解如何使用 Edge MC 和 Node-RED 将有线 Phidgets 连接到 Tulip* ## 摘要 本文介绍将有线 Phidget 连接到 Edge MC 并通过 Node-RED 流程将数据发送到 Tulip 的工作流程。 本文结束时,您将在 Node-RED 中掌握以下流程,以便将 Phidget 数据从传感器发送到 Tulip 中的机器。 您将完成以下步骤: 1. 将 Phidget 连接到边缘 MC 2. 在 Tulip 中设置机器属性 3. 设置 Node-RED 流程 您需要 - 在[您的 Tulip 账户中注册](https://support.tulip.co/docs/how-to-register-an-edge-mc)的 Edge MC - USB 转 Mini-USB 电缆 - [VINT 集线器 Phidget](https://www.phidgets.com/?tier=3&catid=64&pcid=57&prodid=1202) - [湿度小工具](https://www.phidgets.com/?tier=3&catid=14&pcid=12&prodid=1179) - [Phidget 电缆](https://www.phidgets.com/?tier=3&catid=30&pcid=26&prodid=153) **注**:购买 Tulip 工厂套件将包括所有相关的 Phidget 项目。 ## 1.硬件设置 - 将 Phidget 连接到边缘 MC 1. 使用 Phidget 电缆将**湿度**Phidget 连接到**VINT Hub Phidget**的 0 端口。 2. 用 USB 转 Mini-USB 电缆将**VINT Hub**Phidget 连接到**Edge MC**的一个 USB 端口。 ## 2.机器设置 - 创建机器属性 要从 Phidget 传感器向 Tulip 发送数据,首先要使用 Tulip API 作为数据源设置机器。请参阅 "[如何使用机器属性 API](https://support.tulip.co/docs/how-to-use-the-machine-attributes-api)"一文中的 "**设置新机器**"部分,了解更多详情。 我们需要为该机器创建两个机器属性: 1. **湿度**机器属性,类型设为**浮点**型 2. **温度**机器属性,类型设为**浮点**型 您需要注意将`attributeId`和`machineId`值传递到 Node-RED 流程中。 如果您计划使用 Phidget 传感器来改变机器状态等方面,或根据传感器输出执行任何计数,还可以设置机器类型,将其分配给机器。如果对此感兴趣,请参阅 "[如何设置机器类型](https://support.tulip.co/docs/how-to-set-up-machine-types)"。 ## 3.3. Node-RED 设置 - 构建 Node-RED 流程 在连接到 Phidget 传感器的 Edge MC 上打开 Edge Device Portal。使用以下凭证启动 Node-RED 编辑器: - 用户名: admin - 密码: 您的 Edge IO 密码 请参阅[此处](https://support.tulip.co/docs/using-node-red-with-edge-mc)的更多信息,开始在 Edge MC 上使用 Node-RED。 在 Node-RED 调色板编辑器中 1. 从库中安装**Phidgets**节点集。 *参考[这篇](https://nodered.org/docs/user-guide/runtime/adding-nodes)Node-RED 文章,在 "使用编辑器 "下*1.在 Phidgets 节点下添加一个**连接**节点。2. 添加一个**湿度传感器(HumiditySensor**)和一个**温度传感器(TemperatureSensor**)节点,也位于 Phidgets 节点下。3. 在郁金香节点下添加一个**machine-attr**节点。4. 双击两个 Phidgets 传感器节点。配置如下 ``` ** 名称:** 给它一个与相应传感器相关的名称,例如 **Phidget-Humidity.** ** 设备信息:** 复制并粘贴 Tulip 中与 **Humidity** 机器属性相对应的 ** 设备信息**。 ** 属性来源:** 更改为 **msg.payload.humidity .**![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Connecting%20Wired%20Phidgets%20with%20Edge%20MC%20and%20Node-RED_457400870.png) ``` 1. 添加第二个**机器**属性节点。 2. 与步骤 4 类似,配置第二个**machine-attr**节点。 - ***名称:***给它取一个与温度传感器相关的名称,例如**Phidget-Temperature。** - **设备信息:**复制并粘贴 Tulip 中与**温度**机器属性相对应的**设备信息**。 - **属性源:**更改为**msg.payload.temperature**。![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Connecting%20Wired%20Phidgets%20with%20Edge%20MC%20and%20Node-RED_457401647.png) 3. 在常用节点下添加一个**调试**节点。 4. 按如下方式连接节点。请注意,每个数据流都有自己的 Tulip 节点: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Connecting%20Wired%20Phidgets%20with%20Edge%20MC%20and%20Node-RED_457387412.png) 1. 单击屏幕右上角的 "**部署**",将数据流部署到 Edge MC。 要查看 Phidgets 的运行情况,请导航回 Tulip 中的**机器**。您应该能看到 Phidget 读取的湿度和温度数据的实时显示: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Connecting%20Wired%20Phidgets%20with%20Edge%20MC%20and%20Node-RED_457399742.png) 下面是 Node-RED 的[文档](https://nodered.org/docs/),可供进一步阅读。 您有强大的 Node-RED 使用案例吗?请在[郁金香社区](https://community.tulip.co/c/show-and-tell/9)上分享您的开发成果! 以下是 Node-RED 流程的 JSON - 将其[导入](https://nodered.org/docs/user-guide/editor/workspace/import-export)Node-RED 以用于您的设备。 注意:`%your info here%`应替换为工厂实例中的每个机器属性。 `[{"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":[[]]}])`