int()参数必须是字符串或数字,而不是“NoneType”

2024-10-01 09:29:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我在编程方面几乎没有什么技能,但我需要使用各种传感器进行测量,这些传感器连接到我的raspberry pi 3,并将它们发送给thingspeak。我用它作为参考:https://iotdesignpro.com/projects/iot-based-raspberry-pi-weather-station-using-dht11-and-bmp180-sensor。我得到的错误是:enter image description here

我的代码与链接上的代码相同,唯一的区别是api键和gpio引脚

第128行是main(),在最末尾

第114行是(humi, temp)= readDHT()

最后,第104行是return (str(int(humi)), str(int(temp)))

多谢各位


Tags: 代码https技能编程pi传感器tempraspberry
1条回答
网友
1楼 · 发布于 2024-10-01 09:29:10

您无法从以下行中获取信息:

humi, temp = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, DHTpin)
return (str(int(humi)), str(int(temp)))

例如,humi没有收到任何价值。您应该验证DHTpin(当前为针脚22)的定义是否与您连接传感器的定义相同

相关问题 更多 >