Serial port 使用python的SDI-12 Raspberry Pi数据记录器

Serial port 使用python的SDI-12 Raspberry Pi数据记录器,serial-port,pyserial,sdi-12,Serial Port,Pyserial,Sdi 12,我正在研究一个树莓pi系统有一段时间了。我的几个传感器仍然有问题。我正在尝试使用SDI-12命令和设置控制科学传感器 首先,我使用1200波特的标准,7个数据位,1个奇偶校验位(偶数奇偶校验位)和一个停止位 ##### #pySerial python library import serial ##### import time ##### #sonde is the name of the sensor sonde=serial.Serial('/dev/ttyUSB0') sonde.

我正在研究一个树莓pi系统有一段时间了。我的几个传感器仍然有问题。我正在尝试使用SDI-12命令和设置控制科学传感器

首先,我使用1200波特的标准,7个数据位,1个奇偶校验位(偶数奇偶校验位)和一个停止位

#####
#pySerial python library
import serial

#####
import time

#####
#sonde is the name of the sensor
sonde=serial.Serial('/dev/ttyUSB0')
sonde.parity=serial.PARITY_EVEN
sonde.bytesize=serial.SEVENBITS
sonde.stopbits=serial.STOPBITS_ONE
sonde.baudrate=1200

#####
# Sometimes the devices take a while to respond, this is the standard mentioned 
# in the  devices manual. 
sonde.timeout=30

sonde.break(12000)


#####
# The devices address is 0
sonde.write('0I!')

##### 
# Wait 30 seconds before reading from the sensor
time.sleep(30)

for line in sonde:
    print(line)
    print('\n')
所有这些都符合标准,除了SDI-12使用1个起始位,但pySerial没有该字段。我应该以其他方式考虑这一点吗

该设备具有制造商提供的接线线束,可将SDI-12接线转换为RS-232。我用一个标准的串行usb适配器将设备连接到pi,该适配器与其他传感器一起工作

当我在pi上运行此代码时,终端显示的字符或符号我知道是不正确的。我的第一个想法是可能会出现波特率关闭的问题,但我已经尝试了所有广泛使用的波特率

我真的不知道下一步要做什么,除了尝试更多的设置,不是SDI-12标准的一部分。使用回车符('\r')、新行('\n')或两者的组合('\r\n')对响应没有影响


我应该怎么做才能看到这个命令的正确响应,而不是胡言乱语

请提供您正在使用的RS-232至SDI-12接口设备的更多详细信息。它是否具有使用SDI-12所需的精确毫秒定时传输SDI-12命令的逻辑,并根据需要进行唤醒中断和失效?通常,rs232转换器将在作为串行端口枚举的一端以9600波特的速度运行。。。。顺便提一下,我为SDI-12和Arduino写了一个库。。。额外的起始位通常很重要,没有它sdi将无法正常工作。。。所以它的修复有些不简单(所以你不能用pyserial直接与传感器对话)。。。。