星瞳实验室APP,快速收到回复
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 脱机运行为何串口无法发送?



    • 本问题不涉及代码,我使用了WIFI扩展板,OPENMV直接插在电脑上供电可以在串口上打印值,但是接在充电宝上虽然仍可连接WIFI,仍可看到图像,但是串口无法打印数值。同样的代码同样的操作重复多次仍是如此,是因为电压问题吗?该如何解决呢?



    • 应该是代码的问题。请提供你的代码。



    • import sensor, image, time, math, network, usocket, sys
      from pyb import UART
      uart = UART(3, 9600, timeout_char=1000)
      SSID ='OPENMV_AP'
      KEY  ='1234567890'
      HOST = ''
      PORT = 8080
      threshold_index = 0
      thresholds = [(20, 93, -59, -22, -5, 32)]
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False)
      sensor.set_auto_whitebal(False)
      sensor.set_contrast(1)
      sensor.set_brightness(1)
      sensor.set_saturation(1)
      sensor.set_gainceiling(16)
      wlan = network.WINC(mode=network.WINC.MODE_AP)
      wlan.start_ap(SSID, key=KEY, security=wlan.WEP, channel=2)
      def start_streaming(s):
      	print ('Waiting for connections..')
      	client, addr = s.accept()
      	client.settimeout(2.0)
      	print ('Connected to ' + addr[0] + ':' + str(addr[1]))
      	data = client.recv(1024)
      	client.send("HTTP/1.1 200 OK\r\n" \
      				"Server: OpenMV\r\n" \
      				"Content-Type: multipart/x-mixed-replace;boundary=openmv\r\n" \
      				"Cache-Control: no-cache\r\n" \
      				"Pragma: no-cache\r\n\r\n")
      	clock = time.clock()
      	while (True):
      		clock.tick()
      		frame = sensor.snapshot()
      		cframe = frame.compressed(quality=35)
      		header = "\r\n--openmv\r\n" \
      				 "Content-Type: image/jpeg\r\n"\
      				 "Content-Length:"+str(cframe.size())+"\r\n\r\n"
      		client.send(header)
      		client.send(cframe)
      		img = sensor.snapshot()
      		clock.tick()
      		for blob in img.find_blobs([thresholds[threshold_index]], pixels_threshold=200, area_threshold=200, merge=True):
      			img.draw_rectangle(blob.rect())
      			middle = blob.cx()
      			print(middle)
      			if middle>=0 and middle<=70:
      				feedback = '0x02'
      				id = int('0x02',16)
      				uart.writechar(id)
      			elif middle>=90 and middle<=160:
      				id = int('0x00',16)
      				uart.writechar(id)
      			else :
      				id = int('0x06',16)
      				uart.writechar(id)
      while (True):
      	s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
      	try:
      		s.bind([HOST, PORT])
      		s.listen(5)
      		s.settimeout(3)
      		start_streaming(s)
      	except OSError as e:
      		s.close()
      		print("socket error: ", e)
      
      


    • 这个是代码,经反复测试在电脑端供电可正常使用,用充电宝供电虽WIFI模块正常工作,但串口无数据发送,急求解决办法,谢谢