logo

加入距离传感器 和 串口通信传感器,串口可以通信,但是获取距离的时候,距离传感器报错,

2023-08-07 11:00
U
Kevin

Uart error: [Errno 110] ETIMEDOUT

Traceback (most recent call last):

File "<stdin>", line 96, in <module>

File "<stdin>", line 49, in start_streaming

File "vl53l1x.py", line 144, in read

OSError: [Errno 110] ETIMEDOUT

c3f71edb-9096-4b42-b147-20038e4705fc.jpg
fd92ef70-c0b2-4f4d-92e7-b03b2d32e480.jpg
0df4f235-0454-49ff-9da3-eb83fb3fcb64.jpg
2023-08-07 11:08
U
Kevin

# 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)
2023-08-07 11:19
U
Kevin

单独运行获取距离是可以的

range: mm 282

通过串口获取的时候报错

Uart error: [Errno 110] ETIMEDOUT

Traceback (most recent call last):

File "<stdin>", line 101, in <module>

File "vl53l1x.py", line 144, in read

OSError: [Errno 110] ETIMEDOUT

U
Kevin

串口扩展板型号 CP2102

2023-08-08 16:19
I
网红小智智 星瞳科技

测距扩展板和串口冲突了。测距扩展板使用了P4P5,和你的串口是相同的引脚,不能同时使用。

https://singtown.com/product/50448/openmv-distance-shield/