加入距离传感器 和 串口通信传感器,串口可以通信,但是获取距离的时候,距离传感器报错,
-
Uart error: [Errno 110] ETIMEDOUT
Traceback (most recent call last):
File "", line 96, in
File "", line 49, in start_streaming
File "vl53l1x.py", line 144, in read
OSError: [Errno 110] ETIMEDOUT
-
# Blob Detection and uart transport import sensor, image, time from pyb import UART import json import sys from machine import I2C from vl53l1x import VL53L1X import time i2c = I2C(2) distance = VL53L1X(i2c) print("range: mm ", distance.read()) sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.VGA) # Set frame size to QVGA (320x240) sensor.skip_frames(time = 2000) sensor.set_auto_whitebal(True) sensor.set_auto_gain(True) #srnsor.set_ sensor.set_hmirror(True) #水平方向翻转 sensor.set_vflip(True) #垂直方向翻转 uart = UART(3, 115200) while (True): try: if uart.any(): recv_data = uart.read().decode() print("range: mm ", distance.read()) uart.write(distance.read()) except OSError as e: print("Uart error: ", e) sys.print_exception(e)
-
单独运行获取距离是可以的
range: mm 282通过串口获取的时候报错
Uart error: [Errno 110] ETIMEDOUTTraceback (most recent call last):
File "", line 101, in
File "vl53l1x.py", line 144, in read
OSError: [Errno 110] ETIMEDOUT
-
串口扩展板型号 CP2102
-
测距扩展板和串口冲突了。测距扩展板使用了P4P5,和你的串口是相同的引脚,不能同时使用。