° Degree symbol on serial monitor

Hi All.

Have been all through this thread:

I have a Nano Every with Arduino ide V2.0.0 -rc9

My code below:
everything commented out with Serial.print or Serial.write
I have tried and it does not work in the serial monitor.

Any help will be appreciated.

#include <Wire.h>
// Date and time functions using a DS3231 RTC connected via I2C and Wire lib
#include "RTClib.h"

RTC_DS3231 rtc;

char daysOfTheWeek[7][12] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };

void setup() {
  Serial.begin(115200);
  Wire.begin();

#ifndef ESP8266
  while (!Serial)
    ;  // wait for serial port to connect. Needed for native USB
#endif

  if (!rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    while (1) delay(10);
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }

  // When time needs to be re-set on a previously configured device, the
  // following line sets the RTC to the date & time this sketch was compiled
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  // This line sets the RTC with an explicit date & time, for example to set
  // January 21, 2014 at 3am you would call:
  // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}

void loop() {
  DateTime now = rtc.now();

  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(" (");
  Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
  Serial.print(") ");
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();
  Serial.print("Temperature: ");
  Serial.print(rtc.getTemperature());
  //Serial.print("°");
  //Serial.write("°");
  //Serial.write(0xC2);
  //Serial.write(0xB0);
  //Serial.print("\xC2\xB0");
  //Serial.print("\u00b0");
  //Serial.print(byte(223));
  //Serial.print((byte)223);
  //Serial.print(F("\xB0""C"));
  Serial.println("C");

  Serial.println();
  delay(1000);
}

Regards
Charles

Have you tried:

Serial.print((char)176);

Hi.

2022/7/23 (Saturday) 20:11:17
Temperature: 21.25�C

Is displayed...

It could be a V2.0 thing.

Is there a way to maybe report it as a bug?

I am obviously not the sharpest tool in the shed.. :sweat_smile:

Look around over here --
Latest Software/Arduino IDE 2.0 beta topics - Arduino Forum

Maybe it's been noted.
If not, ask.

Thanks will check into it thank you.

Tried PuTTY or TeraTerm ?

Tried PuTTY or TeraTerm ?

No, am not familiar with either Still very much a noob in Arduino..... Well, any coding platform..

They are 'terminal emulators'.
SerialMonitor is limiting.

don't such symbols use UTF-8(?) coding, multiple bytes.

_Others od -x tmp
0000000 b0c2 000a
0000003
_Others cat tmp
°

This particular one is in the extended ASCII table.

Hi @Charles_Gibbs. The Arduino IDE developers are tracking this bug here:

If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments related to this subject.

For a more simple demonstration:

void setup() {
  Serial.begin(115200);
}
void loop() {
  Serial.println("Temperature: 42 °C");
  delay(1000);
}

gives me this sort of output in Serial Monitor:

Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 °C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 °C
Temperature: 42 °C
Temperature: 42 °C
Temperature: 42 °C
Temperature: 42 °C
Temperature: 42 °C
Temperature: 42 °C
Temperature: 42 ��C
Temperature: 42 °C
Temperature: 42 °C
Temperature: 42 °C
Temperature: 42 ��C

Yes, It seems this is a serial monitor thing;
I copied your code:

void setup() {
  Serial.begin(115200);
}
void loop() {
  Serial.println("Temperature: 42 °C");
  delay(1000);
}

My results are far worse I'm afraid:

Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 °C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 °C
Temperature: 42 ��C
Temperature: 42 ��C
Temperature: 42 ��C

Have subbed, hope there's a fix soon.
thanks

Try this:

void setup()
{
   Serial.begin(115200);
}
void loop()
{
   static unsigned long timer = 0;
   unsigned long interval = 1000;
   if (millis() - timer >= interval)
   {
      timer = millis();
      Serial.print("Temperature: 42");
      Serial.write(0xC2); Serial.write(0xB0);  // degree symbol
      Serial.println("C");      
   }
}

Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C
Temperature: 42°C

Hi @groundFungus

Sorry does not work. If you look at the OP you will see that I have already tried that, this seems to be an IDE specific fault on serial monitor.
IDE V2.0.0-rc9..

Regards

@runaway_pancake

I have loaded putty up.

Serial output works floorlessly So it must be a serial bug.


2022/7/24 (Sunday) 11:54:21
Temperature: 20.55°C

2022/7/24 (Sunday) 11:54:22
Temperature: 20.30°C

2022/7/24 (Sunday) 11:54:23
Temperature: 20.55°C

2022/7/24 (Sunday) 11:54:24
Temperature: 20.55°C

2022/7/24 (Sunday) 11:54:25
Temperature: 20.55°C

2022/7/24 (Sunday) 11:54:26
Temperature: 20.55°C

2022/7/24 (Sunday) 11:54:27
Temperature: 20.30°C

2022/7/24 (Sunday) 11:54:28
Temperature: 20.55°C


Hope there is a bug fix soon...

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