使用Node-Red接收传感器数据处理并显示(串口)
Node-Red介绍
Node-RED是一个基于浏览器的可视化编程工具,它允许用户通过拖拽和连接不同的节点来构建自己的物联网应用程序、自动化流程和数据处理管道等。Node-RED使用JavaScript编写,可扩展性强,支持各种设备和服务的集成。
Node-RED的工作方式是将输入(例如传感器读数、传入的数据等)传递到一个流程(Flow)中,由一系列节点(Nodes)进行处理、转换和分发。节点之间通过线(Wires)相连,从一个节点到另一个节点传递消息(Messages),最终将结果输出到终端或者其他设备或服务。
Node-RED内置了大量的节点,包括传感器节点、数据库节点、网络节点等等。此外,还有众多的第三方节点,用户可以通过npm安装并集成到Node-RED中,从而更方便地实现自己的应用场景。
Node-RED还支持用户编写自己的节点和流程模板,用户可以将它们分享到社区中,供其他用户使用。
Node-Red的安装
官方安装教程在此:https://nodered.17coding.net/docs/getting-started/installation
首先先安装node.js,Windows 安装工具: 32-bit or 64-bit
之后安装Node-RED,打开命令行工具(Windows下为命令提示符,macOS和Linux下为终端),输入以下命令安装Node-RED:
npm install -g --unsafe-perm node-red
安装完成后,输入以下命令启动Node-RED:
node-red
打开浏览器,在地址栏中输入 http://localhost:1880
,即可进入Node-RED的编辑界面。
基本操作
当打开Node-RED编辑器时,你会看到一个工作区和一系列工具栏和选项卡。以下是Node-RED的基本操作:
-
添加节点:在左侧工具栏中,有各种类型的节点,例如输入节点(Input Nodes)、处理节点(Processing Nodes)、输出节点(Output Nodes)等。你可以将这些节点从工具栏拖放到工作区中,并通过线连接它们。
-
连接节点:通过将线从一个节点的输出端口拖动到另一个节点的输入端口,可以将节点连接起来。在连接节点时,你可以看到线上面显示的是传输的数据(payload)类型。
-
节点编辑器:当你选择一个节点时,右侧会显示该节点的编辑器。你可以在此处配置节点的详细信息,例如输入节点的传输类型、输出节点的目标位置等。
-
Debug节点:Debug节点可用于检查数据的流向以及它们的内容。将Debug节点添加到工作区,并将其连接到要检查的节点上。当数据通过连接的节点时,Debug节点将记录并显示其内容。
-
部署:在你完成工作流程的设计后,需要单击右上角的“Deploy”按钮来将其部署到Node-RED运行环境中。这会将工作流程保存到磁盘,并使其可供运行。
-
导入/导出:你可以使用“Import”和“Export”选项在Node-RED中导入和导出工作流程。这使得在不同的Node-RED实例之间共享工作流程变得更加容易。
-
Node-RED库:Node-RED库是一组可在你的工作流程中使用的节点。你可以通过“Manage Palette”选项来安装和管理库中的节点。选择“Install”选项卡,并输入要安装的节点的名称,即可将其添加到你的Node-RED编辑器中。
这些是Node-RED的基本操作,通过这些操作,大家可以轻松地创建复杂的自动化工作流程,而无需编写任何代码。
和树莓派进行串口通信
树莓派通过串口发送传感器数据
之前介绍过树莓派读取DHT11温湿度传感器的实现方法,具体见上一篇文章:https://blog.youkuaiyun.com/HeX_Maker/article/details/130119821
在此基础上增加功能,把树莓派读取到的数据通过串口发送到PC端。
硬件连接
我们需要一个“USB to TTL” 的连接线,如下图所示:
把线的TXD端连接到树莓派上的GPIO15(RXD),RXD连接到树莓派上的GPIO14(TXD), GND连GND。树莓派上的引脚接口如下图所示:
树莓派程序代码
import RPi.GPIO as GPIO
import time
import serial
ser = serial.Serial("/dev/ttyAMA0",9600)
def delayMicrosecond(t):
start,end=0,0
start=time.time()
t=(t-3)/1000000
while end-start<t:
end=time.time()
tmp0=[] # Used to store the read data
tmp1=[]
tmp2=[]
data0 = 17 # DHT11 BCM
data1 = 27
data2 = 22
a,b=0,0
def DHT11_0():
GPIO.setup(data0, GPIO.OUT) # GPIO OUTPUT
GPIO.output(data0,GPIO.HIGH)
delayMicrosecond(10*1000) # delay 10ms
GPIO.output(data0,GPIO.LOW)
delayMicrosecond(25*1000) # delay 25ms
GPIO.output(data0,GPIO.HIGH)
GPIO.setup(data0, GPIO.IN) # GPIO INPUT
a=time.time() # Recording cycle start time
while GPIO.input(data0):
b=time.time() # time the record ended
if (b-a)>0.1: #Determine whether the cycle time exceeds 0.1 seconds to avoid the program from entering an infinite loop and getting stuck
break
a=time.time()
while GPIO.input(data0)==0:
b=time.time()
if (b-a)>0.1:
break
a=time.time()
while GPIO.input(data0):
b=time.time()
if (b-a)>=0.1:
break
for i in range(40):
a=time.time()
while GPIO.input(data0)==0:
b=time.time()
if (b-a)>0.1:
break
delayMicrosecond(28) # delay 28 microseconds
if GPIO.input(data0): # After more than 28 microseconds, it is judged whether it is still at a high level
tmp0.append(1) # Record the received bit as 1
a=time.time()
while GPIO.input(data0): # Loop until the input is low
b=time.time()
if (b-a)>0.1:
break
else:
tmp0.append(0) # Record the received bit as 0
def DHT11_1():
GPIO.setup(data1, GPIO.OUT)
GPIO.output(data1,GPIO.HIGH)
delayMicrosecond(10*1000)
GPIO.output(data1,GPIO.LOW)
delayMicrosecond(25*1000)
GPIO.output(data1,GPIO.HIGH)
GPIO.setup(data1, GPIO.IN)
a=time.time()
while GPIO.input(data1):
b=time.time()
if (b-a)>0.1:
break
a=time.time()
while GPIO.input(data1)==0:
b=time.time()
if (b-a)>0.1:
break
a=time.time()
while GPIO.input(data1):
b=time.time()
if (b-a)>=0.1:
break
for i in range(40):
a=time.time()
while GPIO.input(data1)==0:
b=time.time()
if (b-a)>0.1:
break
delayMicrosecond(28)
if GPIO.input(data1):
tmp1.append(1)
a=time.time()
while GPIO.input(data1):
b=time.time()
if (b-a)>0.1:
break
else:
tmp1.append(0)
def DHT11_2():
GPIO.setup(data2, GPIO.OUT)
GPIO.output(data2,GPIO.HIGH)
delayMicrosecond(10*1000)
GPIO.output(data2,GPIO.LOW)
delayMicrosecond(25*1000)
GPIO.output(data2,GPIO.HIGH)
GPIO.setup(data2, GPIO.IN)
a=time.time()
while GPIO.input(data2):
b=time.time()
if (b-a)>0.1:
break
a=time.time()
while GPIO.input(data2)==0:
b=time.time()
if (b-a)>0.1:
break
a=time.time()
while GPIO.input(data2):
b=time.time()
if (b-a)>=0.1:
break
for i in range(40):
a=time.time()
while GPIO.input(data2)==0:
b=time.time()
if (b-a)>0.1:
break
delayMicrosecond(28)
if GPIO.input(data2):
tmp2.append(1)
a=time.time()
while GPIO.input(data2):
b=time.time()
if (b-a)>0.1:
break
else:
tmp2.append(0)
while True:
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
del tmp0[0:] #delete list
del tmp1[0:]
del tmp2[0:]
time.sleep(1) # Delay 1 second
DHT11_0()
DHT11_1()
DHT11_2()
humidity0_bit=tmp0[0:8] # Delimited list, bits 0 to 7 are humidity integer data
humidity0_point_bit=tmp0[8:16]# Humidity Decimals
temperature0_bit=tmp0[16:24] # Integer temperature
temperature0_point_bit=tmp0[24:32] # temperature decimal
check0_bit=tmp0[32:40] # check data
humidity1_bit=tmp1[0:8]
humidity1_point_bit=tmp1[8:16]
temperature1_bit=tmp1[16:24]
temperature1_point_bit=tmp1[24:32]
check1_bit=tmp1[32:40]
humidity2_bit=tmp2[0:8]
humidity2_point_bit=tmp2[8:16]
temperature2_bit=tmp2[16:24]
temperature2_point_bit=tmp2[24:32]
check2_bit=tmp2[32:40]
humidity0_int=0
humidity0_point=0
temperature0_int=0
temperature0_point=0
humidity1_int=0
humidity1_point=0
temperature1_int=0
temperature1_point=0
humidity2_int=0
humidity2_point=0
temperature2_int=0
temperature2_point=0
check0=0
check1=0
check2=0
for i in range(8): # convert binary to decimal
humidity0_int+=humidity0_bit[i]*2**(7-i)
humidity1_int+=humidity1_bit[i]*2**(7-i)
humidity2_int+=humidity2_bit[i]*2**(7-i)
humidity0_point+=humidity0_point_bit[i]*2**(7-i)
humidity1_point+=humidity1_point_bit[i]*2**(7-i)
humidity2_point+=humidity2_point_bit[i]*2**(7-i)
temperature0_int+=temperature0_bit[i]*2**(7-i)
temperature1_int+=temperature1_bit[i]*2**(7-i)
temperature2_int+=temperature2_bit[i]*2**(7-i)
temperature0_point+=temperature0_point_bit[i]*2**(7-i)
temperature1_point+=temperature1_point_bit[i]*2**(7-i)
temperature2_point+=temperature2_point_bit[i]*2**(7-i)
check0+=check0_bit[i]*2**(7-i)
check1+=check1_bit[i]*2**(7-i)
check2+=check2_bit[i]*2**(7-i)
humidity0=humidity0_int+humidity0_point/10
temperature0=temperature0_int+temperature0_point/10
humidity1=humidity1_int+humidity1_point/10
temperature1=temperature1_int+temperature1_point/10
humidity2=humidity2_int+humidity2_point/10
temperature2=temperature2_int+temperature2_point/10
check0_tmp0=humidity0_int+humidity0_point+temperature0_int+temperature0_point
check1_tmp1=humidity1_int+humidity1_point+temperature1_int+temperature1_point
check2_tmp2=humidity2_int+humidity2_point+temperature2_int+temperature2_point
if check0==check0_tmp0 and temperature0!=0 and temperature0!=0 and check1==check1_tmp1 and temperature1!=0 and temperature1!=0 and check2==check2_tmp2 and temperature2!=0 and temperature2!=0 : # Determine if the data is normal
print("Temperature0 is ", temperature0,"C\nHumidity0 is ",humidity0,"%")# Print the temperature and humidity data
print("Temperature1 is ", temperature1,"C\nHumidity1 is ",humidity1,"%")
print("Temperature2 is ", temperature2,"C\nHumidity2 is ",humidity2,"%")
#ser.write(temperature0_int)
temperature00 = str(temperature0)
humidity00 = str(humidity0)
#th00 = temperature00 + ";" + humidity00
#ser.write(th00.encode())
#ser.write(temperature00.encode())
temperature11 = str(temperature1)
humidity11 = str(humidity1)
#th11 = temperature11 + ";" + humidity11
#ser.write(th11.encode())
temperature22 = str(temperature2)
humidity22 = str(humidity2)
th = temperature00 + ";" + humidity00 + ";" + temperature11 + ";" + humidity11 + ";" + temperature22 + ";" + humidity22
ser.write(th.encode())
else:
print("error")
time.sleep(1)
GPIO.cleanup()
运行结果如下图所示:
接下来就是在PC端用Node-Red来读取数据了
Node-Red接收来自串口的数据
建立同树莓派串口通信的通道
首先点击右侧菜单节点管理,搜寻并找到node-red-node-serialport然后安装。
安装完成以后,输入控件与输出控件区都会增加名为“serial”的控件:
随后拖动一个serial in 进入工作区双击可以设置com口。这样就可以开始接收树莓派发送来的串口数据了。
在右面点击小甲虫按钮可以看到调试窗口,如图下图所示:
拆分收到的数据
通过树莓派的程序以及发送过来的数据可以得知,数据形式为:”第一个传感器温度数值“ +“;” + “第一个传感器湿度数值” + “;” + “第二个传感器温度数值” +“;” + “第二个传感器湿度数值” + ”第三个传感器温度数值“ +“;” + “第三个传感器湿度数值” 每个数值之间用分号隔开。所以在node-red接收到数据后必须把数据进行拆分,这里使用“function节点”,双击打开编辑函数:
var inputStr = msg.payload; // 获取输入的字符串
var nums = inputStr.split(";"); // 使用分号分隔符拆分字符串
var num0 = Number(nums[0]); // 将第一个数字字符串转换为数字
var num1 = Number(nums[1]); // 将第二个数字字符串转换为数字
var num2 = Number(nums[2]); // 将第三个数字字符串转换为数字
var num3 = Number(nums[3]);
var num4 = Number(nums[4]);
var num5 = Number(nums[5]);
var num6 = nums[6];
//msg.payload = "Number 1: " + num1 + " | Number 2: " + num2; // 将两个数字组合成一个输出字符串
var msg0 = { payload: num0 };
var msg1 = { payload: num1 };
var msg2 = { payload: num2 };
var msg3 = { payload: num3 };
var msg4 = { payload: num4 };
var msg5 = { payload: num5 };
var msg6 = { payload: num6 };
return [msg0, msg1, msg2, msg3, msg4, msg5, msg6];
这段代码的作用就是拆分数据,此时function节点的效果如下图所示:
左侧是串口的数据输入,经过拆分可以分成多个数据进行输出。
在面板上显示
现在我们需要把数据显示出来,需要安装“node-red-dashboard”节点,安装步骤和之前一样,在“节点管理”中搜索安装即可。
安装好之后左侧会如下图所示:
在http://localhost:1880/ui页面下就可以看到所使用的节点仪表面板效果
这些都是可玩性很高的仪表面板,具体功能大家可以自己尝试。这里我们用“gauge”和“chart”来显示温度和湿度数据。同时连接上debug方便在右侧实时查看原始数据。
整体流程以及效果
为了记录数据,还可以加入“write file”节点还有“csv”节点保存传感器的数据到电脑,方便后面的数据分析。
node-red 整体流程图是这样的:
仪表面板效果如下图所示:
node-red可以把整个流程用代码的形式导出,复制以下的代码并导入就可以直接生成和上图一样的流程
[
{
"id": "d529edefff1e10d5",
"type": "tab",
"label": "串口",
"disabled": false,
"info": "",
"env": []
},
{
"id": "2b17534a10cc9099",
"type": "serial in",
"z": "d529edefff1e10d5",
"name": "",
"serial": "f47941d9832b654f",
"x": 110,
"y": 420,
"wires": [
[
"9397710ac1e79629",
"13901c9ba93eb885",
"43e3df8fe415a464",
"aa50c7a9c8b3fae8"
]
]
},
{
"id": "9397710ac1e79629",
"type": "function",
"z": "d529edefff1e10d5",
"name": "function 3",
"func": "var inputStr = msg.payload; // 获取输入的字符串\nvar nums = inputStr.split(\";\"); // 使用分号分隔符拆分字符串\nvar num0 = Number(nums[0]); // 将第一个数字字符串转换为数字\nvar num1 = Number(nums[1]); // 将第二个数字字符串转换为数字\nvar num2 = Number(nums[2]); // 将第三个数字字符串转换为数字\nvar num3 = Number(nums[3]);\nvar num4 = Number(nums[4]);\nvar num5 = Number(nums[5]);\nvar num6 = nums[6];\n//msg.payload = \"Number 1: \" + num1 + \" | Number 2: \" + num2; // 将两个数字组合成一个输出字符串\n\nvar msg0 = { payload: num0 };\nvar msg1 = { payload: num1 };\nvar msg2 = { payload: num2 };\nvar msg3 = { payload: num3 };\nvar msg4 = { payload: num4 };\nvar msg5 = { payload: num5 };\nvar msg6 = { payload: num6 };\nreturn [msg0, msg1, msg2, msg3, msg4, msg5, msg6];\n",
"outputs": 7,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 420,
"y": 380,
"wires": [
[
"b07f0fa28b58235c",
"ab884e71b62abed2",
"d46e3892995fb455"
],
[
"8ddd21b6c1063dba",
"04d52b047eaf7fd3",
"f7144f0a4837db1c",
"3ef5baebbe514715"
],
[
"8c23abefddd32e66",
"fce2be4d94a0f953",
"d85ab65e2217a951",
"27b17b0659da0c8b"
],
[
"1267df5a8be4dd46",
"b33d42667ab855a4",
"b81a440fd8e87b27",
"a140591aa58653d1"
],
[
"b17065195f5e4829",
"156b4d8d00d94de0",
"5aa2e6bf13141b96",
"a75fe38c6aafefca"
],
[
"fc38d1675f184b69",
"0ad798cd21ca8504",
"30fd34cacc3b2f77",
"18c514229437319d"
],
[
"8f1ea131644be4fa",
"0957119266f2258d"
]
]
},
{
"id": "b07f0fa28b58235c",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "t0",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 850,
"y": 280,
"wires": []
},
{
"id": "8ddd21b6c1063dba",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "h0",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 850,
"y": 320,
"wires": []
},
{
"id": "8c23abefddd32e66",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "t1",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 850,
"y": 360,
"wires": []
},
{
"id": "04d52b047eaf7fd3",
"type": "ui_gauge",
"z": "d529edefff1e10d5",
"name": "",
"group": "5283c2abfc1b5a75",
"order": 3,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "humidity0",
"label": "%",
"format": "{{value}}",
"min": "-100",
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 700,
"y": 320,
"wires": []
},
{
"id": "fce2be4d94a0f953",
"type": "ui_gauge",
"z": "d529edefff1e10d5",
"name": "",
"group": "3e841485a4d36b4a",
"order": 2,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Temperatur1",
"label": "C",
"format": "{{value}}",
"min": "-10",
"max": "50",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 710,
"y": 360,
"wires": []
},
{
"id": "b17065195f5e4829",
"type": "ui_gauge",
"z": "d529edefff1e10d5",
"name": "",
"group": "6ebeb9ec1ee1d0b6",
"order": 2,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Temperatur2",
"label": "C",
"format": "{{value}}",
"min": "-10",
"max": "50",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 710,
"y": 440,
"wires": []
},
{
"id": "1267df5a8be4dd46",
"type": "ui_gauge",
"z": "d529edefff1e10d5",
"name": "",
"group": "3e841485a4d36b4a",
"order": 3,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "humidity1",
"label": "%",
"format": "{{value}}",
"min": "-100",
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 700,
"y": 400,
"wires": []
},
{
"id": "fc38d1675f184b69",
"type": "ui_gauge",
"z": "d529edefff1e10d5",
"name": "",
"group": "6ebeb9ec1ee1d0b6",
"order": 3,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "humidity2",
"label": "%",
"format": "{{value}}",
"min": "-100",
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 700,
"y": 480,
"wires": []
},
{
"id": "b33d42667ab855a4",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "h1",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 850,
"y": 400,
"wires": []
},
{
"id": "156b4d8d00d94de0",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "t2",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 850,
"y": 440,
"wires": []
},
{
"id": "0ad798cd21ca8504",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "h2",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 850,
"y": 480,
"wires": []
},
{
"id": "ab884e71b62abed2",
"type": "ui_gauge",
"z": "d529edefff1e10d5",
"name": "",
"group": "5283c2abfc1b5a75",
"order": 2,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Temperatur0",
"label": "C",
"format": "{{value}}",
"min": "-10",
"max": "50",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 710,
"y": 280,
"wires": []
},
{
"id": "13901c9ba93eb885",
"type": "file",
"z": "d529edefff1e10d5",
"name": "",
"filename": "D:\\Iot\\DHT11_0.txt",
"filenameType": "str",
"appendNewline": true,
"createDir": false,
"overwriteFile": "false",
"encoding": "none",
"x": 430,
"y": 500,
"wires": [
[
"6c28225d157aa707"
]
]
},
{
"id": "6c28225d157aa707",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "text",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 670,
"y": 580,
"wires": []
},
{
"id": "d46e3892995fb455",
"type": "ui_chart",
"z": "d529edefff1e10d5",
"name": "",
"group": "5283c2abfc1b5a75",
"order": 2,
"width": 0,
"height": 0,
"label": "",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": true,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1030,
"y": 280,
"wires": [
[
"6f2e05e4476d3016"
]
]
},
{
"id": "6f2e05e4476d3016",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "t0",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 280,
"wires": []
},
{
"id": "8f1ea131644be4fa",
"type": "ui_text",
"z": "d529edefff1e10d5",
"group": "c9e8ea402253a271",
"order": 0,
"width": 0,
"height": 0,
"name": "time",
"label": "",
"format": "{{msg.payload}}",
"layout": "row-left",
"className": "",
"x": 690,
"y": 520,
"wires": []
},
{
"id": "0957119266f2258d",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "time",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 850,
"y": 520,
"wires": []
},
{
"id": "aa50c7a9c8b3fae8",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "debug 12",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 420,
"y": 720,
"wires": []
},
{
"id": "f7144f0a4837db1c",
"type": "ui_chart",
"z": "d529edefff1e10d5",
"name": "",
"group": "5283c2abfc1b5a75",
"order": 3,
"width": 0,
"height": 0,
"label": "",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": true,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1030,
"y": 320,
"wires": [
[]
]
},
{
"id": "3ef5baebbe514715",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "h0",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 320,
"wires": []
},
{
"id": "d85ab65e2217a951",
"type": "ui_chart",
"z": "d529edefff1e10d5",
"name": "",
"group": "3e841485a4d36b4a",
"order": 2,
"width": 0,
"height": 0,
"label": "",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": true,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1030,
"y": 360,
"wires": [
[]
]
},
{
"id": "b81a440fd8e87b27",
"type": "ui_chart",
"z": "d529edefff1e10d5",
"name": "",
"group": "3e841485a4d36b4a",
"order": 3,
"width": 0,
"height": 0,
"label": "",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": true,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1030,
"y": 400,
"wires": [
[]
]
},
{
"id": "5aa2e6bf13141b96",
"type": "ui_chart",
"z": "d529edefff1e10d5",
"name": "",
"group": "6ebeb9ec1ee1d0b6",
"order": 2,
"width": 0,
"height": 0,
"label": "",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": true,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1030,
"y": 440,
"wires": [
[]
]
},
{
"id": "30fd34cacc3b2f77",
"type": "ui_chart",
"z": "d529edefff1e10d5",
"name": "",
"group": "6ebeb9ec1ee1d0b6",
"order": 3,
"width": 0,
"height": 0,
"label": "",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": true,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 1030,
"y": 480,
"wires": [
[]
]
},
{
"id": "27b17b0659da0c8b",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "t1",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 360,
"wires": []
},
{
"id": "a140591aa58653d1",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "h1",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 400,
"wires": []
},
{
"id": "a75fe38c6aafefca",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "t2",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 440,
"wires": []
},
{
"id": "18c514229437319d",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "h2",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 480,
"wires": []
},
{
"id": "43e3df8fe415a464",
"type": "csv",
"z": "d529edefff1e10d5",
"name": "",
"sep": ";",
"hdrin": "",
"hdrout": "none",
"multi": "one",
"ret": "\\r\\n",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 410,
"y": 660,
"wires": [
[
"a642610e5cdb79b3"
]
]
},
{
"id": "a642610e5cdb79b3",
"type": "file",
"z": "d529edefff1e10d5",
"name": "",
"filename": "D:\\Iot\\DHT11_csv.csv",
"filenameType": "str",
"appendNewline": true,
"createDir": false,
"overwriteFile": "false",
"encoding": "none",
"x": 620,
"y": 660,
"wires": [
[
"93ee12c4a6e3bdf4"
]
]
},
{
"id": "93ee12c4a6e3bdf4",
"type": "debug",
"z": "d529edefff1e10d5",
"name": "csv",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 850,
"y": 660,
"wires": []
},
{
"id": "f47941d9832b654f",
"type": "serial-port",
"serialport": "COM3",
"serialbaud": "9600",
"databits": "8",
"parity": "none",
"stopbits": "1",
"waitfor": "",
"dtr": "none",
"rts": "none",
"cts": "none",
"dsr": "none",
"newline": "1000",
"bin": "false",
"out": "time",
"addchar": "",
"responsetimeout": "10000"
},
{
"id": "5283c2abfc1b5a75",
"type": "ui_group",
"name": "DHT11_0",
"tab": "e9c8b1a4dfca7d61",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "3e841485a4d36b4a",
"type": "ui_group",
"name": "DHT11_1",
"tab": "e9c8b1a4dfca7d61",
"order": 2,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "6ebeb9ec1ee1d0b6",
"type": "ui_group",
"name": "DHT11_2",
"tab": "e9c8b1a4dfca7d61",
"order": 3,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "c9e8ea402253a271",
"type": "ui_group",
"name": "Time",
"tab": "e9c8b1a4dfca7d61",
"order": 4,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "e9c8b1a4dfca7d61",
"type": "ui_tab",
"name": "Sensor",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]
下期预告
不用串口直接让node-red和树莓派接入物联网进行通讯,不但不用连线而且可以远程监控