Arduino Uno 串行监视器打印垃圾 [英] Arduino Uno serial monitor printing garbage

查看:60
本文介绍了Arduino Uno 串行监视器打印垃圾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目中使用 Arduino Uno 和 GSM sim800l,看起来有些问题,我不知道是什么.这是我的代码:

I am using Arduino Uno and GSM sim800l for a project and looks like something is wrong and I don't know what it is. Here is my code:

#include <AltSoftSerial.h>

AltSoftSerial altSerial;

void setup() {
  Serial.begin(19200);
  Serial.println("AltSoftSerial Test Begin");
  altSerial.begin(19200);
  altSerial.println("Hello World");
}

void loop() {
  char c;

  altSerial.print("altSerial is working.");
  if (Serial.available()) {
    c = Serial.read();
    altSerial.print(c);
  }
  if (altSerial.available()) {
    c = altSerial.read();
    Serial.print(c);
  }
}

它的输出是这样的:

AltSoftSerial Test Begin (linebreak)
 Hello World  (linebreak)
ltSerial is ok⸮⸮M⸮ɥ⸮⸮⸮is okalt //insert long random garbage here

我尝试更改代码和串行监视器的波特率以使其保持匹配,但它不起作用,我尝试将其降低至 300 并尝试高达 19200.
任何想法都会有所帮助.我也试过工具->修复编码并重新加载,但它仍然没有解决问题.这是我第一次使用这种类型的硬件,所以请耐心等待.我的目标是用它来发送 SMS 消息,但现在我正在尝试用它来完成一个较小的任务,以尝试更好地理解它.

I tried changing the baud rate of the code and serial monitor to keep it matched but it is not working, I tried to lower it as low as 300 and tried up to 19200 as well.
Any ideas would help. I also tried Tools-> Fix encoding and reload but it still didn't solve the problem. It is my first time using this type of hardware so please bear with me. My goal is to use it to send SMS messages but right now I'm trying a smaller task with it to try and understand it better.

顺便说一句,我使用的 Arduino IDE 是 1.8.7

Btw, the Arduino IDE I am using is 1.8.7

推荐答案

我意识到这篇文章很旧,但我也是,即使在过去的 40 年里我没有遇到所有可能的 com 端口问题,我也可以可以肯定地说我有几十个.对我来说,这是一棵解决问题的树,不管它的价值,它就在这里..

I realize this post is old, but so am I, and even if I haven't had every possible com port issue in the last 40 years, I can safely say I've had dozens of them. For me, it is a trouble shooting tree, and for what it's worth, here it is..

首先,您没有说明您的系统是什么,您应该始终从那里开始.我将假设 Windows 10,但如果实现它们的方式不同,则基本思想是相同的.

First, you didn't say what your system is, and you should always start there. I am going to assume Windows 10, but the basic ideas are the same if the way to achieve them are different.

  1. 插入您的 arduino.您已经说过您的串行监视器设置为 19200,但请确保您确定,因为这常常是问题所在.
  2. 如果您确定 #1,请打开控制面板 >设备管理器端口
  3. 如果您没有看到端口"在列表中,那么您的计算机没有看到 arduino.这可能是任何东西,从坏的 arduino 到坏的电缆,再到 PC 上坏的 USB 端口.尝试一次将所有这些都切换出去,看看是否可以让任何东西与 com 端口快速通信.由于您在串行监视器中得到了一些信息,因此这不会是您的特殊问题.
  4. 点击端口"展开它,并验证您是否看到列出的 Arduino.右键单击 Arduino,禁用并再次启用它.看看这是否能解决波特率问题.
  5. 查看 Arduino 属性
  6. 它是否表示您的设备工作正常?如果没有,请查看事件,您将看到错误描述.修复它所说的错误.如果是,请继续
  7. 端口设置可能是 9200、8、None、1、None.即使你在串口监视器窗口中的波特率是 19200,你仍然可能会在设备管理器中看到 9200,不用担心.感觉不对,但很正常.Microsoft 似乎喜欢将 9600 保留在这里,即使我对这个端口所做的最后一件事是不同的.上面列出的数据位和其他设置是另一回事.
  8. 接下来,点击高级
  9. 是否显示了您的 Arduino 分配的端口号?它旁边是否写着正在使用"?如果是这样,这是您的问题.我知道.很奇怪吧?相信我,如果它显示正在使用",则意味着 Microsoft 内部的某些东西正在使用该端口,但它不是您的 Arduino.Power Shell 可以帮助您解决问题,但那是另一回事,但现在最好的办法是重新安装驱动程序.
  10. 单击驱动程序选项卡,并验证您的驱动程序提供商是 Arduino LLC.我从来没有见过不是那样的,但如果不是,我会试着找出原因.
  11. 继续更新驱动程序并重新启动您的计算机,即使没有提示您重新启动,也请执行此操作.
  12. 没有解决吗?在驱动程序选项卡中,禁用设备,然后重新启用它.这也可能解决问题.
  13. 没有解决吗?暂时不要卸载驱动程序.
  14. 点击详情.你看到 Arduino 了吗?
  15. 查看事件"标签.如果您看到错误,请修复它.
  16. 仍然无法工作?卸载串行驱动程序,然后重新安装.
  17. 还是没有 19200?如果您有垃圾,则 rx 上的时间与 Arduino tx 不同步.您现在需要一个逻辑分析仪,这里就不多说了.

这篇关于Arduino Uno 串行监视器打印垃圾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆