具有OWFS的Raspberry Pi,带有DS2482-800板的8个DS18B20传感器,运行速度非常慢

时间:2018-08-08 15:38:54

标签: python raspberry-pi raspberry-pi3

我正在安装OWFS的Raspberry Pi 3上使用DS2482-800芯片和64个DS18B20温度传感器。我知道每个传感器应每750毫秒刷新一次。我去过其他论坛,据我所知,与现在的运行方式相比,我拥有的简单代码应该能够相当快地运行。我删除了除8个连接到DS2482的OW0的传感器之外的所有传感器。据我了解,这应该可以在7-10秒内循环播放,但是需要30-40秒。我尝试了多线程,并尝试使OWFS并行运行,而不是按顺序运行,但是一直在努力。任何帮助将不胜感激。

结果:33.83175621025 20.9375 20.7575 20.8125 20.625 20.3755 20.6875 20.687521

import os
import time
while ( True ): 
    T1 = time.time()
    tempfile1 = open("/mnt/1wire/28.36624D0A0000/temperature")
    thetext1 = tempfile1.read()
    tempfile1.close()
    #print(thetext1)

    tempfile2 = open("/mnt/1wire/28.CD624D0A0000/temperature")
    thetext2 = tempfile2.read()
    tempfile2.close()
    #print(thetext2)

    tempfile3 = open("/mnt/1wire/28.BC564D0A0000/temperature")
    thetext3 = tempfile3.read()
    tempfile3.close()
    #print(thetext3)

    tempfile4 = open("/mnt/1wire/28.46594D0A0000/temperature")
    thetext4 = tempfile4.read()
    tempfile4.close()
    #print(thetext4)

    tempfile5 = open("/mnt/1wire/28.FA654D0A0000/temperature")
    thetext5 = tempfile5.read()
    tempfile5.close()
    #print(thetext5)

    tempfile6 = open("/mnt/1wire/28.613F4D0A0000/temperature")
    thetext6 = tempfile6.read()
    tempfile6.close()
    #print(thetext6)

    tempfile7 = open("/mnt/1wire/28.613F4D0A0000/temperature")
    thetext7 = tempfile7.read()
    tempfile7.close()
    #print(thetext7)

    tempfile8 = open("/mnt/1wire/28.9E534D0A0000/temperature")
    thetext8 = tempfile8.read()
    tempfile8.close()


    T0 = time.time()

    deltatime = T0 - T1

    print deltatime, thetext1, thetext2, thetext3, thetext4, thetext5, 
    print thetext6,thetext7, thetext8
    print "-----------------------------------------------------------------"

0 个答案:

没有答案