Test IDE 2.0 rc2,The serial port is garbled

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:

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);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.