【发布时间】:2017-03-30 13:37:46
【问题描述】:
这是我的脚本有错误的部分:
while:
sensorIn = 8
sensorOut = 5
sensorAC = 7
blue = 0
white = 1
[tempIn, humIn] = grovepi.dht(sensorIn, 1)
print("tempIn = %.02f C humIn =%.02f%%"%(tempIn, humIn))
[tempOut, humOut] = grovepi.dht(sensorOut, 1)
print("tempOut = %.02f C humOut =%.02f%%"%(tempOut, humOut))
[tempAC, humAC] = grovepi.dht(sensorAC, 1)
print("tempAC = %.02f C humAC =%.02f%%"%(tempAC, humAC))
它随机出错:
TypeError: 'int' object not iterable on the line: [tempAC, humAC] = grovepi.dht(sensorAC, 1)
这与 Raspberry Pi 和 GrovePi 板一起使用,以获取来自温度和湿度传感器的读数。它会循环播放,读取读数,然后对这些读数做一些事情,然后休眠 15 分钟,然后重新开始。
也许 while 循环是问题所在...我曾经在没有 while 循环的情况下运行它,并且会在 crontab 中将其设置为每 15 分钟运行一次。有时读数会出现错误,但会以 0 的形式通过脚本,脚本不会停止并出错,它会继续并仅将值报告为 0。
我查看了很多关于此错误的不同帖子,但我只遇到过总是出现错误并且根本不允许脚本运行完成的帖子,就我而言,它只是偶尔发生。
【问题讨论】:
标签: python raspberry-pi grovepi+