【问题标题】:How to get the device id of Raspberry Pi while sending data to IBM Bluemix as a gateway如何在将数据发送到 IBM Bluemix 作为网关时获取 Raspberry Pi 的设备 ID
【发布时间】:2016-07-23 18:05:31
【问题描述】:

我正在通过 Raspberry Pi(网关)将数据从 Sense HAT(设备)发送到我的 Bluemix 应用程序。我的 Pi 还将 Raspberry Pi 的 CPU 温度发送到 Bluemix。我有一个 IBM IoT 节点接收这两种数据。我无法区分 Sense HAT 数据和 Raspberry Pi 数据。下面是函数节点代码:

var v;
if(msg.deviceId==="raspberryID")
{
    v= "From Raspberry Pi";
}
  else if (msg.deviceId=="senseHatid")
{
  v= "From Sense Hat";
}
return {payload:v}

返回值始终是“来自 Sense Hat”,但我能够在调试中接收到这两个数据。如果我在 if else 语句中使用msg.deviceType,我会得到相同的结果。

【问题讨论】:

  • 我测试了你的代码,它工作正常。我能够区分 Sense Hat 和 Raspberry Pi。仔细检查设备 ID 并查看。

标签: ibm-cloud node-red raspberry-pi3 watson-iot


【解决方案1】:

您似乎正在使用 senseHatid 发布来自 Raspberry Pi 和 SenseHAT 的所有数据。

您是否使用 Node-RED 发布来自 Raspberry Pi 的读数?如果是这样,请确保将出站 Watson IoT 节点的 msg.deviceType 和 msg.deviceId 值设置到 Raspberry Pi 网关以获取 CPU 温度,并将 SenseHit 设备设置为 senseHat 数据。

【讨论】:

    猜你喜欢
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-23
    相关资源
    最近更新 更多