为什么我的SDS011传感器不发送正确的字节?
我尝试通过连接到Raspberry Pi的SDS011来测量空气质量。因此,我使用我在此处找到的脚本: https://forum-raspberrypi.de/forum/thread/32634-nova-pm2-5-pm2-5-pm10-feinstaub-sensor-sensor-sensor-sensor-sss011-am-am-am-pi-anschlie%c3% 9fen/
我将其更改为python3(ser.write(b.encode())
而不是ser.write(b)
)。
脚本本身正在运行,但我想
def sensor_read():
byte = 0
while byte != "\xaa":
byte = ser.read(size=1)
d = ser.read(size=10)
if d[0] == "\xc0":
process_frame(byte + d)
创建了一个无限的循环,因为“字节”似乎从未成为“ \ xaa”。
我是否只需要等待更长的时间(大约几分钟),或者代码有问题?
非常感谢您的帮助!
I try to measure air quality with an sds011 connected to a raspberry Pi. Therefore I use a script I found here: https://forum-raspberrypi.de/forum/thread/32634-nova-pm2-5-pm10-feinstaub-sensor-sds011-am-pi-anschlie%C3%9Fen/
I changed it to python3 (ser.write(b.encode())
instead of ser.write(b)
).
The script itself is running, but I guess
def sensor_read():
byte = 0
while byte != "\xaa":
byte = ser.read(size=1)
d = ser.read(size=10)
if d[0] == "\xc0":
process_frame(byte + d)
creates an infinite loop because "byte" never seems to become "\xaa".
Do I just have to wait even longer (about several minutes) or is something wrong with the code?
Thanks a lot for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论