代码:
[{
"id": "15d4e229.de9d2e",
"type": "function",
"z": "e3aca2b9.00ea7",
"name": "temperature",
"func": "str=msg.payload;\nmsg.payload=str.substring(5,9);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 470,
"y": 296.5,
"wires": [
["7a0ba386.d5fc24"]
]
}, {
"id": "7a0ba386.d5fc24",
"type": "ui_gauge",
"z": "e3aca2b9.00ea7",
"name": "",
"group": "d6ccf1c9.b74398",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "CPU. Temp",
"label": "℃",
"format": "{{value}}",
"min": 0,
"max": "80",
"colors": ["#00b500", "#e6e600", "#ca3838"],
"seg1": "",
"seg2": "",
"x": 679,
"y": 333.5,
"wires": []
}, {
"id": "bf50d228.72e178",
"type": "inject",
"z": "e3aca2b9.00ea7",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 104,
"y": 305.5,
"wires": [
["db3ed94d.c4bdb"]
]
}, {
"id": "db3ed94d.c4bdb",
"type": "exec",
"z": "e3aca2b9.00ea7",
"command": "vcgencmd measure_temp",
"addpay": false,
"append": "",
"useSpawn": "false",
"timer": "",
"oldrc": false,
"name": "temp",
"x": 255,
"y": 312,
"wires": [
["15d4e229.de9d2e"],
[],
[]
]
}, {
"id": "d6ccf1c9.b74398",
"type": "ui_group",
"z": "",
"name": "tem",
"tab": "8d45c1ce.10593",
"disp": true,
"width": "6",
"collapse": false
}, {
"id": "8d45c1ce.10593",
"type": "ui_tab",
"z": "",
"name": "Temp",
"icon": "dashboard"
}]
导入代码过程:
浏览器输入:http://172.16.0.12:1880
IP请根据你自己服务器的IP填写
点击node-red页面右上菜单(红色圈圈),如图:
在弹出的菜单中选择"导入"
粘贴本文上面的代码到下图红框处
粘贴好后点击页面右下角的"导入"按钮即可生成如下"流程图"
在chrome浏览器新建标签页,然后地址栏输入
显示效果如图
程序保存就是"导出" .
本文程序参考了https://blog.csdn.net/hu5566798/article/details/81058485的代码,在此表示感谢!