node.js - Arduino 中的未知输出字符

标签 node.js arduino serial-port 3dr

我实际上正在使用 FPVDrone 3DR radio 遥测连接我的笔记本电脑和 arduino。我的连接是

ARDUINO tx- FPV Air module rx
ARDUINO rx- FPV Air module tx
ARDUINO 5v- FPV Air module 5v
ARDUINO GND- FPV Air module GND

当我的 FPV 地面模块连接到我的笔记本电脑时。我有一个使用 Node JS 运行的应用程序,其脚本如下

const SerialPort = require('serialport');
const Readline = SerialPort.parsers.Readline;
const port = new SerialPort('COM3');
port.write('hello');

我的arduino代码是

void setup() {

  Serial.begin(57600);

}

void loop() {

  if (Serial.available()) {

    Serial.print((char) Serial.read());

    delay(10);

  }

}

我很确定他们正在通信,因为我的arduino正在接收一些输出,但是输出是一些我不知道的字符,

arduino output

有人可以告诉我应该做什么,以便我可以将字符串“hello”接收到我的arduino吗?

最佳答案

尝试在node.js脚本中设置波特率

const port = new SerialPort(path, { baudRate: 57600 })

由于发送和接收波特率不同,字符变得困惑。

关于node.js - Arduino 中的未知输出字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58928230/

相关文章:

php - 通过 PHP 和 cURL 访问 NodeJS/Socket.io

javascript - 在 Mongoose 的字段中定义一个函数作为默认值

arduino - "exit status 1 ' 微秒到英寸 ' was not declared in this scope"

c++ - 如何为 Arduino 的接近传感器使用外部电源

javascript - 将字符串转换为有效的 json

arduino - RFID RC522 是否能够读取 NFC 标签?

c++ - Unix:如何清除串口I/O缓冲区?

python - Pyserial 持久配置

node.js - 在 package.json 中包含模块安装参数

javascript - 在 JavaScript 中压缩数组