先说问题:参照教程做了个arduino和openMV通信的demo,运行起来出现问题:openMV可以收到数据,但是数据是乱码(比如arduino发了一个数字1,openmV收到的数据打印出来变成了255),同样,arduino收到的数据也成了乱码。我找了整个论坛没有看到类似的情况,求教大佬帮忙解答。。也许问题很lou,请原谅,我刚开始学这方面的知识。
+++++++++++++++++++++++++++++++++++++
问题截图:

可以看到,串口显示的数据是253,实际上arduino发送的数据是整数1
+++++++++++++++++++++++++++++++++++++
下面给出我的代码:
openmv上的:
# Blob Detection and uart transport
import sensor, image, time
from pyb import UART
import json
uart = UART(3, 19200, timeout_char=1000)
buf=[]
while(True):
print("get from serial:",uart.readchar())
print("get from serial:",uart.readchar())
print("send end");
uart.write('a');
time.sleep(1000)
+++++++++++++++++++++++
arduino上的:
#include <SoftwareSerial.h>
SoftwareSerial softSerial(10, 11); // RX, TX
void setup() {
// put your setup code here, to run once:
softSerial.begin(115200);
Serial.begin(115200);
}
void loop() {
Serial.println("write");
softSerial.write(1);
softSerial.write(2);
Serial.println("read");
Serial.println(softSerial.read());
Serial.println("yougood");
delay(1000);
}
+++++++++++++++
提前感谢!!
你是怎样搭建开发环境的?是同一个电脑两个窗口么?一开始设置波特率了么
先看一下视频:
https://singtown.com/learn/50240/
https://singtown.com/learn/50235/