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

查看:130
本文介绍了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,无,1,无.即使您在串行监视器窗口中的波特率是19200,您也可能会在设备管理器中看到9200,不必担心.感觉错了,但这是正常的.微软似乎喜欢将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天全站免登陆