The serial port is garbled, and IDE 1.8 is normal
Hi @greatelec . Please post a small sketch that produces garbled output for you.
/*
DS3231_Serial_Hard
版权所有 (C)2015 Rinky-Dink Electronics, Henning Karlsen.版权所有
网: http://www.RinkyDinkElectronics.com/
如何使用我的 DS3231 库进行快速演示
检索时间和日期数据供您操作。
要使用Arduino的硬件I2C(TWI)接口,您必须连接
引脚如下:
Arduino Uno/2009:
----------------------
DS3231:SDA引脚->Arduino Analog 4或专用SDA引脚
SCL 引脚 -> Arduino Analog 5 或专用 SCL 引脚
Arduino Leonardo:
----------------------
DS3231:SDA引脚->Arduino Digital 2或专用SDA引脚
SCL 引脚 -> Arduino Digital 3 或专用的 SCL 引脚
Arduino Mega:
----------------------
DS3231:自动评估引脚->Arduino Digital 20 (SDA)或专用的SDA引脚
SCL 引脚 -> Arduino Digital 21 (SCL) 或专用 SCL 引脚
Arduino Due:
----------------------
DS3231:SDA引脚->Arduino Digital 20 (SDA)或专用SDA1 (数字70)引脚
SCL 引脚 -> Arduino Digital 21 (SCL) 或专用 SCL1 (数字 71) 引脚
内部上拉电阻器将在使用硬件 I2C 接口。
您可以将DS3231连接到任何可用的引脚,但如果您使用任何引脚
除了上面描述的内容之外,库将回退到
基于软件的类似 TWI 的协议,需要独占访问权限
到使用的引脚,您还必须使用适当的外部
数据和时钟信号上的上拉电阻。
*/
#include <DS3231.h>
DS3231 rtc(SDA, SCL); //使用硬件接口初始化DS3231
Time t; //初始化时间数据结构
void setup() {
pinMode(2, INPUT_PULLUP); //设置管脚2为输入
pinMode(9, OUTPUT); //设置管脚13为输出
pinMode(13, OUTPUT);
Serial.begin(115200); //设置串行连接
//取消注释下一行,如果您使用的是Arduino Leonardo
//while (!Serial) {}
rtc.begin(); //初始化 rtc 对象
//可以取消注释以下行以设置日期和时间
//rtc.setDOW(SUNDAY); //将星期几设置为星期日
//rtc.setTime(12,0,0); //将时间设置为 12:00:00(24 小时格式)
//rtc.setDate(1,1,2016); //将日期设置为日/月/年
}
void loop() {
int Val = digitalRead(2); //读pin2清按钮状态
t = rtc.getTime(); //从DS3231获取数据
Serial.println("当前时间:"); //通过串行连接发送日期
Serial.print("日期: ");
Serial.print(t.date, DEC);
Serial.print("/");
Serial.print(t.mon, DEC);
Serial.print("/");
Serial.print(t.year, DEC);
Serial.println();
Serial.print("星期: "); //发送星期几和时间
Serial.print(t.dow, DEC);
Serial.println();
Serial.print("时间: ");
Serial.print(t.hour, DEC);
Serial.print(":");
Serial.print(t.min, DEC);
Serial.print(":");
Serial.print(t.sec, DEC);
Serial.println();
Serial.println("--------------------------------");
delay(1000); //延迟用于以 1 秒的间隔显示时间。
if (t.mon == 12 && t.date == 12 && t.hour == 11 && t.min == 41 && t.sec == 00) { //在每 2:32:53pm 设置定时报警,换句话说,您可以在每个星期四插入 t.dow?,t.date 为特定日期?
digitalWrite(9, HIGH); //假设您的组件连接到引脚 9
digitalWrite(13, HIGH);
}
if (Val == 0) {
digitalWrite(9, LOW);
digitalWrite(13, LOW);
}
}
Thanks! I believe it is the same bug as is being tracked here:
opened 02:10PM - 02 Nov 21 UTC
closed 08:01AM - 13 Dec 22 UTC
conclusion: resolved
topic: code
type: imperfection
topic: serial monitor
### Describe the problem
🐛 When Serial Monitor is used to display characters … past the ASCII range printed by a non-native USB board, corruption occurs at various non-fixed positions in the output.
### To reproduce
1. Upload a sketch that prints characters past the ASCII range to serial:
```cpp
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println("ASCII: !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
Serial.println("> ASCII: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛ");
delay(200);
}
```
1. Open Serial Monitor.
🐛 Some of the characters are replaced by `�`:
```text
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡��£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»��½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓ��ÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´��¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌ��ÎÏÐÑÒÓÔÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª«¬��¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅ��ÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦��¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿��ÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×��ÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸��º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐ��ÒÓÔÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª«¬®¯°±²��´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊ��ÌÍÎÏÐÑÒÓÔÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª��¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃ��ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤��¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½��¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕ��רÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶��¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎ��ÐÑÒÓÔÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª«¬®¯��±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ��ÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨��ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁ��ÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙ��Û
```
### Expected behavior
All characters to be printed correctly by Serial Monitor all the time:
```
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛ
ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
> ASCII: ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛ
```
### Arduino IDE version
#### Original report
2.0.0-beta.12-nightly.20211028
#### Last verified with
d6a4b0f (with [**serial-monitor** 0.11.0](https://github.com/arduino/serial-monitor/releases/tag/v0.11.0))
### Operating system
Windows
### Operating system version
10
### Additional context
I originally suspected the corruption might be caused by https://github.com/arduino/arduino-ide/issues/375, but this bug persists even though that one has been resolved.
---
The delay duration has an influence on the position of the corruption and the manifestation is different from one board to another (less corruption on Leonardo and MKR, more on Nano Every).
---
The issue does not occur when using the Arduino IDE 1.8.19 Serial Monitor, even when the board is running the binary that produced the corrupted output in Arduino IDE 2.x (i.e., it's not related to the sketch having been compiled in Arduino IDE 2.x).
---
Originally reported at https://forum.arduino.cc/t/serial-monitor-difficulties-with-german-umlauts/870541
---
Additional reports:
- https://github.com/arduino/arduino-ide/issues/1405
- https://forum.arduino.cc/t/serial-monitor-difficulties-with-german-umlauts/870541/7
- https://forum.arduino.cc/t/serial-read-and-serial-available-are-working-not-as-expected-in-the-code/925823
- https://forum.arduino.cc/t/using-v-2-0-serial-monitor-print/1034093
- https://forum.arduino.cc/t/question-marks-in-serial-monitor/1023531
- https://forum.arduino.cc/t/serial-monitor-detect-interferes-with-sketch-on-promicro/1017659
- https://forum.arduino.cc/t/degree-symbol-on-serial-monitor/1015370
- https://forum.arduino.cc/t/serial-monitor-produces-gibberish/950416/1
- https://forum.arduino.cc/t/serial-monitor-produces-gibberish/950416/15
- https://forum.arduino.cc/t/serial-monitor-issues-with-arduino-due/975247
- https://forum.arduino.cc/t/test-ide-2-0-rc2-the-serial-port-is-garbled/935697
### Issue checklist
- [X] I searched for previous reports in [the issue tracker](https://github.com/arduino/arduino-ide/issues?q=)
- [X] I verified the problem still occurs when using the latest [nightly build](https://www.arduino.cc/en/software#nightly-builds)
- [X] My report contains all necessary details
Do you mean that the format may be damaged by printing Chinese? However, the output English format error still exists, and there is no problem in IDE 1.8. Tested several files, which has nothing to do with the output format.
Yes. That is the bug tracked at https://github.com/arduino/arduino-ide/issues/589
Please post one of them.
If possible, make the most minimal possible sketch that demonstrates the issue.
For example, in your previous sketch none of the DS3231 stuff was at all relevant to the issue. A minimal complete example would be:
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println("当前时间:");
delay(1000);
}
system
Closed
June 12, 2022, 6:20am
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.