我使用的是t型热电偶,需要在Raspberry Pi3上使用python读取温度数据。我使用Adafruit MAX31856将热电偶连接到Pi,并尝试使用this module读取它。在
我想长时间地读取温度,所以我试图用while loop
打印出来,但是,每当我运行代码时,我只得到几个“正确”的读数,然后温度重置为0,直到我再次运行代码-见所附图像。在
我不知道是什么原因造成的,我不认为这是连接问题,因为当我重新运行代码时,它会打印出正确的温度,而不接触设置。在
有人知道为什么读数重置为0吗?在
这是我的代码:
from Adafruit_MAX31856 import MAX31856
import time
# Raspberry Pi software SPI configuration.
CLK = 4
CS = 22
DO = 17
DI = 27
sensor = MAX31856(clk=CLK, cs=CS, do=DO, di=DI)
while True:
temp = sensor.readTempC()
print('Thermocouple Temperature: {0:0.3F}*C'.format(temp))
time.sleep(1.0)
尝试通过将
sensor = MAX31856(clk=CLK, cs=CS, do=DO, di=DI)
放入while循环来重置传感器。在相关问题 更多 >
编程相关推荐